/* Invoice Import — shared styles. Source design: openspec "apply-new-design". */

:root {
    --bg-page: oklch(0.975 0.003 260);
    --bg-subtle: oklch(0.97 0.003 260);
    --bg-canvas: oklch(0.95 0.003 260);
    --bg-footer: oklch(0.985 0.002 260);
    --surface: #fff;
    --header-bg: oklch(0.2 0.008 260);
    --header-divider: oklch(0.38 0.01 260);
    --header-muted: oklch(0.75 0.005 260);
    --header-text: oklch(0.85 0.005 260);

    --text: oklch(0.22 0.01 260);
    --text-label: oklch(0.35 0.01 260);
    --text-secondary: oklch(0.4 0.01 260);
    --text-muted: oklch(0.5 0.01 260);
    --text-faint: oklch(0.6 0.01 260);
    --text-section: oklch(0.55 0.01 260);

    --border-strong: oklch(0.88 0.005 260);
    --border: oklch(0.9 0.005 260);
    --border-soft: oklch(0.92 0.004 260);
    --border-faint: oklch(0.93 0.004 260);

    --accent: oklch(0.55 0.19 258);
    --accent-hover: oklch(0.5 0.19 258);
    --accent-ring: oklch(0.55 0.19 258 / 0.15);
    --accent-tint: oklch(0.95 0.025 258);
    --accent-tint-text: oklch(0.42 0.15 258);

    --success: oklch(0.5 0.13 155);
    --success-bg: oklch(0.55 0.13 155);
    --success-tint: oklch(0.96 0.03 155);

    --warning: oklch(0.6 0.14 65);
    --warning-border: oklch(0.82 0.08 75);
    --warning-field: oklch(0.99 0.01 80);
    --warning-tint: oklch(0.97 0.035 80);
    --warning-text: oklch(0.42 0.09 65);
    --warning-dot: oklch(0.72 0.15 70);

    --danger: oklch(0.5 0.17 25);
    --danger-tint: oklch(0.95 0.03 25);
    --danger-border: oklch(0.8 0.09 25);

    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html, body { margin: 0; }

body {
    min-height: 100vh;
    background: var(--bg-page);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.4;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hover); }
a:hover { color: oklch(0.42 0.19 258); }

input, select, textarea, button { font-family: inherit; }

[hidden] { display: none !important; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

/* ---------- Wordmark ---------- */

.wordmark {
    display: flex;
    flex-direction: column;
    line-height: 1;
    gap: 3px;
    color: inherit;
    text-decoration: none;
}
.wordmark:hover { color: inherit; }
.wordmark-name { font-weight: 600; font-size: 13px; letter-spacing: 0.28em; }
.wordmark-sub { font-weight: 500; font-size: 9px; letter-spacing: 0.5em; color: var(--header-muted); }

.wordmark-lg { align-items: center; gap: 4px; }
.wordmark-lg .wordmark-name { font-size: 16px; letter-spacing: 0.3em; padding-left: 0.3em; }
.wordmark-lg .wordmark-sub { font-size: 10px; letter-spacing: 0.55em; padding-left: 0.55em; color: var(--text-muted); }

/* ---------- Header ---------- */

.app-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--header-bg);
    color: #fff;
}
.app-header-left, .app-header-right { display: flex; align-items: center; }
.app-header-left { gap: 20px; }
.app-header-right { gap: 16px; }
.app-header-divider { width: 1px; height: 22px; background: var(--header-divider); }
.app-header-title { font-size: 14px; color: var(--header-text); }
.app-header-user { font-size: 13px; color: var(--header-muted); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.btn-primary { background: var(--accent); color: #fff; padding: 0 16px; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }

.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: oklch(0.3 0.01 260); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); color: oklch(0.3 0.01 260); }

.btn-ghost-dark { height: 32px; background: transparent; border-color: oklch(0.4 0.01 260); color: #fff; font-weight: 400; }
.btn-ghost-dark:hover { background: oklch(0.28 0.01 260); color: #fff; }

.btn-lg { height: 40px; padding: 0 16px; border-radius: 8px; font-size: 14px; }
.btn-lg.btn-primary { padding: 0 22px; }
.btn-xl { height: 44px; border-radius: 8px; font-size: 15px; width: 100%; }

.btn-success, .btn-success:hover:not(:disabled) { background: var(--success-bg); color: #fff; }

.btn-link {
    height: 28px;
    padding: 0 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-link:hover { background: var(--bg-canvas); color: var(--text-secondary); }

/* ---------- Import page layout ---------- */

.page {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 32px 32px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 24px;
    align-items: start;
}

.doc-column { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.page-title { display: flex; flex-direction: column; gap: 4px; }
.page-title h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.page-title p { margin: 0; font-size: 14px; color: var(--text-muted); }

@media (max-width: 1099px) {
    .page { grid-template-columns: minmax(0, 1fr); }
    .panel { position: static !important; }
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

/* Upload bar */
.upload-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 12px 12px 16px;
}
.file-badge {
    width: 36px; height: 36px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--danger-tint);
    color: var(--danger);
    display: flex; align-items: center; justify-content: center;
    font: 600 10px var(--font-mono);
}
.file-badge.is-empty { background: var(--bg-canvas); color: var(--text-faint); }
.file-badge.is-xlsx { background: var(--success-tint); color: var(--success); }
.file-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.file-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-name.is-empty { font-weight: 400; color: var(--text-muted); }
.file-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 8px; align-items: center; min-height: 16px; }
.file-meta-dot { width: 3px; height: 3px; border-radius: 50%; background: oklch(0.7 0.01 260); }
.status-recognized { color: var(--success); font-weight: 500; }
.status-pending { color: var(--accent-hover); font-weight: 500; }
.status-failed { color: var(--danger); font-weight: 500; }

/* Document preview */
.doc-card { overflow: hidden; }
.doc-toolbar {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px 0 16px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
    color: var(--text-secondary);
}
.doc-toolbar-name { font: 12px var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.doc-canvas {
    position: relative;
    background: var(--bg-canvas);
    height: calc(100vh - 220px);
    min-height: 600px;
}
.doc-canvas embed,
.doc-canvas iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.doc-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 14px;
}
.doc-empty-sheet {
    width: 84px; height: 110px;
    background: var(--surface);
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 6px 20px rgba(0,0,0,.06);
    margin-bottom: 8px;
}

/* ---------- Details panel ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 16px;
}
.panel-head {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-faint);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.panel-head-row { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.panel-counter { font: 500 12px var(--font-mono); color: var(--text-muted); }

.panel-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 22px; }
.panel-section { display: flex; flex-direction: column; gap: 14px; }
.section-title { font: 500 11px var(--font-mono); letter-spacing: 0.08em; color: var(--text-section); }
.panel-divider { height: 1px; background: var(--border-faint); }

.panel-foot {
    padding: 16px 24px;
    border-top: 1px solid var(--border-faint);
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    background: var(--bg-footer);
    border-radius: 0 0 12px 12px;
}

/* ---------- Fields ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-label);
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-currency { grid-template-columns: 110px 1fr; }
.field-group { display: flex; flex-direction: column; gap: 14px; }

.input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: var(--surface);
    font-size: 14px;
    color: var(--text);
}
select.input {
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237a7f88' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
textarea.input { height: auto; padding: 9px 12px; line-height: 1.45; resize: vertical; }
textarea.input-2 { resize: none; line-height: 1.4; }
.input-amount { font: 500 14px var(--font-mono); text-align: right; }
.input:disabled, .input[readonly] {
    background: var(--bg-subtle);
    border-color: var(--border-soft);
    color: oklch(0.45 0.01 260);
}
.input:focus, .chip-box:focus-within {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Marks next to labels */
.mark { font-size: 12px; font-weight: 400; white-space: nowrap; }
.mark-recognized { color: var(--success); }
.mark-required { color: var(--warning); }

/* Required-but-empty field after upload */
.field.needs-input .input,
.field.needs-input .chip-box {
    border-color: var(--warning-border);
    background-color: var(--warning-field);
}

/* Validation error from submit */
.input.is-invalid, .chip-box.is-invalid {
    border-color: var(--danger-border);
    background-color: var(--danger-tint);
}

/* ---------- Period chips ---------- */

.chip-field { position: relative; }
.chip-box {
    min-height: 38px;
    padding: 4px 6px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: var(--surface);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 6px 0 10px;
    border-radius: 5px;
    background: var(--accent-tint);
    color: var(--accent-tint-text);
    font-size: 13px;
    font-weight: 500;
}
.chip-remove {
    width: 18px; height: 18px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}
.chip-remove:hover { background: oklch(0.9 0.04 258); }
.chip-add {
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--text-faint);
    padding: 0 6px;
    height: 26px;
    cursor: pointer;
    border-radius: 5px;
}
.chip-add:hover { color: var(--text-secondary); background: var(--bg-subtle); }
.chip-add:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.popover {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}
.popover-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
.popover-option:hover { background: var(--bg-subtle); }
.popover-option input { accent-color: var(--accent); margin: 0; }

/* ---------- Alerts ---------- */

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
}
.alert::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}
.alert-warning { background: var(--warning-tint); color: var(--warning-text); }
.alert-warning::before { background: var(--warning-dot); }
.alert-success { background: var(--success-tint); color: var(--success); }
.alert-success::before { background: var(--success); }
.alert-danger { background: var(--danger-tint); color: var(--danger); }
.alert-danger::before { background: var(--danger); }

#result-message:empty { display: none; }

/* ---------- Auth pages (sign in / forbidden) ---------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 32px 16px;
}
.auth-card {
    width: 380px;
    max-width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 36px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    box-shadow: 0 8px 30px rgba(0,0,0,.05);
}
.auth-text { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.auth-text h1 { margin: 0; font-size: 21px; font-weight: 600; }
.auth-text p { margin: 0; font-size: 14px; color: var(--text-muted); }
.auth-email { color: var(--text); font-weight: 500; word-break: break-all; }
.auth-footer { font-size: 12px; color: var(--text-section); }
