/* ===== Modern Theme - Estimate Online ===== */

:root {
    --bg: #f8f9fb;
    --bg-card: #ffffff;
    --bg-hover: #f1f3f7;
    --text: #1a1d23;
    --text-secondary: #4a5066;
    --text-muted: #8b91a5;
    --accent: #4f6ef7;
    --accent-hover: #3d5ce5;
    --accent-light: #eef1fe;
    --border: #e2e5ec;
    --border-light: #f0f1f5;
    --danger: #e54d4d;
    --danger-hover: #d43b3b;
    --success: #2eaa5e;
    --success-light: #edf7f0;
    --warning: #f0a030;
    --warning-light: #fef7ec;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --transition: 150ms ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Navbar ===== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 15px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: color var(--transition);
}

.nav-links a:hover { color: var(--accent); }

.nav-user {
    color: var(--text-muted);
    font-size: 13px;
    padding-left: 1rem;
    border-left: 1px solid var(--border);
}

.btn-link {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
}

/* ===== Container ===== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    gap: .5rem;
    flex-shrink: 0;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:hover { background: var(--bg-hover); border-color: #ccd0da; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline:hover { background: var(--accent-light); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }

.btn-sm { padding: .35rem .7rem; font-size: 12px; }

.btn-full { width: 100%; justify-content: center; }

/* ===== Cards ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: .75rem;
    gap: .5rem;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.badge {
    display: inline-flex;
    padding: .2rem .6rem;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.card-meta {
    margin-bottom: 1rem;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.card-actions {
    display: flex;
    gap: .5rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border-light);
}

/* ===== Tables ===== */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: var(--bg);
    padding: .6rem .75rem;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}

.data-table tr:hover td { background: var(--bg-hover); }

.row-material td { background: #fafbff; }
.row-material .original-name { font-style: italic; }
.row-excluded td { opacity: .4; }

.col-check { width: 36px; text-align: center; }
.col-num { width: 40px; text-align: center; color: var(--text-muted); }
.col-section { width: 100px; font-size: 12px; color: var(--text-muted); }
.col-date { width: 140px; }
.col-original { width: 30%; max-width: 320px; }
.col-text { width: 40%; min-width: 280px; }

.original-name {
    display: block;
    font-size: 12px;
    line-height: 1.4;
}

.original-meta {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: .2rem;
}

.editable {
    cursor: pointer;
    padding: .2rem .3rem;
    border-radius: 4px;
    transition: background var(--transition);
    display: block;
    line-height: 1.5;
}

.editable:hover { background: var(--accent-light); }

.inline-edit {
    width: 100%;
    min-height: 60px;
    padding: .4rem;
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

.input-date {
    padding: .3rem .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text);
}

.input-date:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, .15);
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 13px;
}

.toolbar label { color: var(--text-secondary); font-weight: 500; }

/* ===== Flash Messages ===== */
.flash-messages { margin-bottom: 1.5rem; }

.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: .5rem;
}

.flash-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.flash-success { background: var(--success-light); color: var(--success); border: 1px solid #b6e5c8; }
.flash-warning { background: var(--warning-light); color: #946200; border: 1px solid #f0d48a; }

/* ===== Auth ===== */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 1.25rem;
    margin-top: .75rem;
    font-weight: 700;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: .25rem;
}

.auth-form .form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: .35rem;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, .15);
}

.form-inline {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.form-inline .form-group { margin-bottom: 0; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state svg { margin-bottom: 1rem; }
.empty-state h2 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--text-secondary); }
.empty-state p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ===== Upload ===== */
.upload-zone {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    transition: all var(--transition);
}

.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
}

.upload-content { display: flex; flex-direction: column; align-items: center; gap: 1rem; }

.upload-text { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.upload-hint { font-size: 13px; color: var(--text-muted); }

.upload-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 14px;
    font-weight: 500;
}

/* ===== Journal Preview ===== */
.journal-preview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.journal-page { max-width: 800px; margin: 0 auto; }

.journal-header { text-align: center; margin-bottom: 1.5rem; }
.journal-ref { font-size: 12px; color: var(--text-muted); margin-bottom: .25rem; }
.journal-header h2 { font-size: 1.1rem; font-weight: 600; }

.journal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.journal-table th,
.journal-table td {
    border: 1px solid var(--text);
    padding: .5rem .75rem;
}

.journal-table th {
    font-weight: 500;
    font-size: 12px;
    text-align: center;
    background: none;
    color: var(--text);
}

.th-sub { font-weight: 400; font-size: 10px; color: var(--text-secondary); }

.tr-colnum th {
    padding: .2rem;
    font-size: 11px;
    color: var(--text-muted);
}

.jt-date { width: 15%; text-align: center; }
.jt-desc { line-height: 1.6; }

/* ===== Utility ===== */
.text-muted { color: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .nav-links { gap: .75rem; }
    .container { padding: 1rem; }
    .page-header { flex-direction: column; }
    .card-grid { grid-template-columns: 1fr; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .toolbar { flex-direction: column; align-items: stretch; }
}
