/* Bilti — editorial logistics / document archive */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,400;1,9..144,500&family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg: #F2EDE3;
    --bg-2: #ECE5D7;
    --bg-3: #E2D9C5;
    --ink: #1B1815;
    --ink-2: #4A4338;
    --ink-3: #8A8170;
    --rule: #C9BFA8;
    --accent: #B6471C;
    --accent-deep: #8B3514;
    --accent-tint: #F5D9C7;
    --success: #4A6B3A;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body {
    position: relative;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(182, 71, 28, 0.06), transparent 60%),
        radial-gradient(ellipse 70% 50% at 90% 100%, rgba(74, 67, 56, 0.07), transparent 60%);
    mix-blend-mode: multiply;
    pointer-events: none;
    z-index: 0;
}

main, .topbar, .toast { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); }

/* ---------- Typography ---------- */
h1, h2, h3 {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144;
    font-weight: 500;
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.01em;
}
h1 { font-size: 44px; line-height: 1.05; }
h2 { font-size: 26px; line-height: 1.15; }
h3 { font-size: 18px; line-height: 1.2; }

.italic { font-style: italic; font-family: var(--font-display); }
.mono   { font-family: var(--font-mono); }

.kicker {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-3);
}

/* ---------- Top bar ---------- */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 22px 40px;
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
}
.brand-mark {
    width: 28px; height: 28px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--bg);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 17px;
    display: grid; place-items: center;
    line-height: 1;
}
.brand-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.02em;
}
.brand-name .dot { color: var(--accent); }

.topnav {
    display: flex;
    gap: 28px;
    justify-content: center;
}
.topnav a {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
}
.topnav a.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.topnav a:hover { color: var(--ink); }

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-2);
}
.status-dot {
    width: 8px; height: 8px;
    border-radius: 999px;
    background: var(--success);
    animation: pulse 2.4s ease-in-out infinite;
}
.status[data-state="reading"] .status-dot { background: var(--accent); }
.status[data-state="review"]  .status-dot { background: var(--accent-deep); }
.status[data-state="saved"]   .status-dot { background: var(--success); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ---------- Layout ---------- */
main {
    padding: 48px 40px 120px;
    max-width: 1320px;
    margin: 0 auto;
    animation: rise 0.5s ease-out both;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.stage { display: block; }
.stage[hidden] { display: none !important; }

/* ---------- Stage: Upload ---------- */
.upload-head {
    text-align: center;
    margin-bottom: 32px;
}
.upload-head .kicker { display: block; margin-bottom: 12px; }
.upload-head h1 { max-width: 720px; margin: 0 auto 12px; }
.upload-head h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.upload-head p { color: var(--ink-2); max-width: 560px; margin: 0 auto; }

.dropzone {
    margin: 0 auto;
    max-width: 760px;
    height: 320px;
    border: 1.5px dashed var(--rule);
    border-radius: 6px;
    background-color: var(--bg-2);
    background-image: repeating-linear-gradient(
        135deg,
        transparent 0 14px,
        rgba(74, 67, 56, 0.045) 14px 15px
    );
    display: grid;
    place-items: center;
    text-align: center;
    padding: 24px;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}
.dropzone:hover, .dropzone.is-drag {
    transform: translateY(-2px);
    border-color: var(--accent);
    background-color: var(--bg-3);
}
.dropzone-inner { display: grid; gap: 14px; justify-items: center; }
.dropzone-icon {
    width: 48px; height: 48px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--rule);
    display: grid; place-items: center;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 24px;
}
.dropzone h2 { font-size: 22px; }
.dropzone .hint { color: var(--ink-3); font-size: 13px; }
.dropzone .btn { margin-top: 4px; }

.tips {
    margin-top: 56px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}
.tip {
    padding: 24px 28px;
    border-right: 1px solid var(--rule);
}
.tip:last-child { border-right: none; }
.tip .kicker { display: block; margin-bottom: 8px; }
.tip h3 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 500;
    margin-bottom: 4px;
}
.tip p { color: var(--ink-2); font-size: 13.5px; margin: 0; }

/* ---------- Stage: Loading ---------- */
.loading-wrap {
    max-width: 520px;
    margin: 80px auto 0;
    text-align: center;
}
.loading-wrap .kicker { display: block; margin-bottom: 14px; }
.loading-wrap h2 { margin-bottom: 28px; }
.loading-wrap h2 em { font-style: italic; color: var(--accent); font-weight: 500; }
.loader-bar {
    height: 2px;
    background: var(--rule);
    overflow: hidden;
    position: relative;
}
.loader-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent);
    transform-origin: left;
    animation: slide 1.6s ease-in-out infinite;
}
@keyframes slide {
    0%   { transform: translateX(-100%) scaleX(0.4); }
    50%  { transform: translateX(0%)    scaleX(0.6); }
    100% { transform: translateX(100%)  scaleX(0.4); }
}
.loader-sub {
    margin-top: 18px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    min-height: 18px;
}

/* ---------- Stage: Verify ---------- */
.verify-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--rule);
}
.verify-head .kicker { display: block; margin-bottom: 4px; }
.verify-head h2 em { font-style: italic; color: var(--accent); font-weight: 500; }
.verify-head .filename {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-3);
}

.verify-split {
    display: grid;
    grid-template-columns: 0.95fr 1.15fr;
    gap: 40px;
    align-items: start;
}
@media (max-width: 980px) {
    .verify-split { grid-template-columns: 1fr; }
    .preview-panel { position: static !important; }
}

.preview-panel {
    position: sticky;
    top: 24px;
    background: var(--bg-2);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 18px;
}
.preview-panel .kicker { display: block; margin-bottom: 10px; }
.preview-panel img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--rule);
    background: var(--bg);
}
.preview-meta {
    margin-top: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-3);
    display: flex;
    justify-content: space-between;
}

/* Form */
.form-panel { display: grid; gap: 28px; }

fieldset {
    border: none;
    border-top: 1px solid var(--rule);
    padding: 18px 0 4px;
    margin: 0;
}
fieldset:first-child { border-top: none; padding-top: 4px; }

legend {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 500;
    color: var(--ink);
    padding: 0;
    margin-bottom: 14px;
}
legend .roman {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--accent);
    margin-right: 10px;
    vertical-align: 2px;
}

.subsection-title {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin: 6px 0 8px;
}

.row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
}
.row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row .full  { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.field input,
.field textarea,
.field select {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--rule);
    padding: 6px 0 7px;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--ink);
    width: 100%;
    border-radius: 0;
    outline: none;
    transition: border-color 0.15s ease;
}
.field textarea { resize: vertical; min-height: 44px; }
.field input::placeholder,
.field textarea::placeholder { color: var(--ink-3); opacity: 0.6; }
.field input:focus,
.field textarea:focus,
.field select:focus { border-bottom-color: var(--accent); }
.field input.is-auto,
.field textarea.is-auto,
.field select.is-auto {
    color: var(--accent);
    font-weight: 600;
}

/* Actions */
.action-bar {
    position: sticky;
    bottom: 16px;
    margin-top: 32px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 14px 18px;
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 6px;
    box-shadow: 0 1px 0 var(--bg-3);
    grid-column: 1 / -1;
}

.btn {
    appearance: none;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--bg);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 14px;
    padding: 11px 22px;
    border-radius: 2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    color: var(--ink-2);
    border-color: var(--rule);
}
.btn-ghost:hover {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn .check {
    width: 16px; height: 16px;
    display: inline-grid; place-items: center;
}

/* ---------- Stage: Done ---------- */
.done-wrap {
    max-width: 560px;
    margin: 80px auto 0;
    text-align: center;
}
.done-check {
    width: 80px; height: 80px;
    border-radius: 999px;
    background: var(--bg-2);
    border: 1px solid var(--rule);
    color: var(--success);
    display: grid; place-items: center;
    margin: 0 auto 24px;
    font-size: 36px;
}
.done-wrap .kicker { display: block; margin-bottom: 10px; }
.done-wrap h2 em { font-style: italic; color: var(--accent); font-weight: 500; }
.done-actions {
    margin-top: 28px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink);
    color: var(--bg);
    padding: 12px 20px;
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
    border: 1px solid var(--ink);
}
.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.is-error {
    background: #2A1410;
    border-color: var(--accent);
    color: var(--accent-tint);
}

/* ---------- Records page ---------- */
.records-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--rule);
}
.records-head .kicker { display: block; margin-bottom: 6px; }
.records-head h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.records-head .meta {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-3);
}

.records-panel {
    background: var(--bg-2);
    border: 1px solid var(--rule);
    border-radius: 6px;
    overflow: hidden;
}
.records-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.records-table thead th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 500;
    padding: 14px 14px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}
.records-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
    color: var(--ink);
}
.records-table tbody tr:last-child td { border-bottom: none; }
.records-table tbody tr:hover td { background: var(--accent-tint); transition: background 0.15s ease; }
.records-table .mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); }
.records-table .num  { text-align: right; font-family: var(--font-mono); }
.records-table .dim  { color: var(--ink-3); font-family: var(--font-mono); font-size: 11.5px; }
.records-table .id-cell { color: var(--accent); font-weight: 600; font-family: var(--font-mono); }
.records-table .route-arrow { color: var(--ink-3); margin: 0 6px; }
.records-table .preview-link { color: var(--ink-3); }
.records-table .preview-link:hover { color: var(--accent); }
.records-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* ---------- Row actions ---------- */
.row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    white-space: nowrap;
}
.action-btn {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 5px 10px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    background: var(--bg);
    color: var(--ink-2);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.action-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--bg);
}
.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.action-btn.action-danger:hover {
    color: var(--bg);
    background: var(--accent);
    border-color: var(--accent);
}

/* ---------- Login page ---------- */
.login-main {
    display: grid;
    place-items: center;
    padding: 60px 20px 120px;
    max-width: 1320px;
    margin: 0 auto;
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-2);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 36px 32px 28px;
}
.login-card .kicker { display: block; margin-bottom: 10px; }
.login-card h1 {
    font-size: 36px;
    margin-bottom: 6px;
}
.login-card h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.login-sub {
    color: var(--ink-2);
    font-size: 14px;
    margin: 0 0 22px;
}
.login-form { display: grid; gap: 18px; }
.login-form .action-bar {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}
.login-error {
    margin-bottom: 18px;
    padding: 10px 12px;
    border: 1px solid var(--accent);
    background: var(--accent-tint);
    color: var(--accent-deep);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
    border-radius: 3px;
}

/* ---------- Edit page preview placeholder ---------- */
.preview-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border: 1px dashed var(--rule);
    background: var(--bg);
}
