/*
 * Projukti ERP styles. The tokens are the Projukti Dashboard's (its DESIGN.md, section 2),
 * so the two apps look like one. Plain CSS, no build step, no nesting.
 *
 * 1. Font  2. Tokens  3. Base  4. Shell  5. Guest pages  6. Components  7. Phone
 */

/* 1. Font */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/inter/inter-latin.woff2') format('woff2');
}

/* 2. Tokens */
:root {
    --page: #F4F7FE;
    --surface: #FFFFFF;
    --surface-sunken: #F1F5FB;
    --surface-hover: #F6F9FF;
    --border: #E4E9F2;
    --border-soft: #EEF2F9;
    --border-button: #C9D3E4;
    --input: #7D8AA0;
    --text-strong: #12233A;
    --text-body: #3F5673;
    --text-muted: #56677E;
    --link: #1D56D6;
    --link-hover: #1747B5;
    --primary: #2263EE;
    --primary-hover: #1B55D9;
    --primary-gradient: linear-gradient(180deg, #4274F0, #1B55D9);
    --primary-soft: #E8EFFE;
    --ring: #2263EE;
    --danger: #C8283E;
    --success-text: #146A39;
    --success-soft: #E5F5EC;
    --success-border: #A9DDBF;
    --warning-text: #8A5300;
    --warning-soft: #FFF4DB;
    --warning-border: #F5CF7A;
    --danger-text: #B4232F;
    --danger-soft: #FDECEE;
    --danger-border: #F3B4BD;
    --info-text: #1D55D0;
    --info-soft: #E8EFFE;
    --info-border: #B8CCF8;
    --neutral-text: #3F5673;
    --neutral-soft: #EEF2F9;
    --sidebar: #0F1E30;
    --sidebar-foreground: #C3CDDB;
    --sidebar-accent: #1A2B41;
    --sidebar-muted: #93A3BA;
    --sidebar-ring: #6B91FF;
    --code-surface: #0F1E30;
    --shadow-soft: 0 1px 2px rgba(18, 35, 58, 0.05), 0 4px 16px rgba(18, 35, 58, 0.05);

    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --fs-xs: 13px;
    --fs-sm: 14px;
    --fs-base: 15px;
    --fs-md: 16px;
    --fs-lg: 18px;
    --fs-2xl: 28px;
    --radius-sm: 8px;
    --radius-control: 10px;
    --radius-card: 16px;
    --radius-pill: 999px;
    --control-height: 44px;
    --sidebar-width: 264px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --page: #111113;
        --surface: #151A1E;
        --surface-sunken: #1B2026;
        --surface-hover: #1C2229;
        --border: #2D3138;
        --border-soft: #23272E;
        --border-button: #3A414B;
        --input: #6B7380;
        --text-strong: #F5F7FA;
        --text-body: #D4D9E1;
        --text-muted: #A3ABB8;
        --link: #88BAFF;
        --link-hover: #B3D1FF;
        --primary: #2F64FF;
        --primary-hover: #2559F5;
        --primary-gradient: linear-gradient(180deg, #3F6EFF, #1350FF);
        --primary-soft: #18233D;
        --ring: #5095FF;
        --danger: #D92D42;
        --success-text: #38C976;
        --success-soft: #13251A;
        --success-border: #1F4A31;
        --warning-text: #F0AD4E;
        --warning-soft: #2A2113;
        --warning-border: #5A4520;
        --danger-text: #FF6B6B;
        --danger-soft: #2C1517;
        --danger-border: #5C2A2E;
        --info-text: #88BAFF;
        --info-soft: #15213A;
        --info-border: #2A3F66;
        --neutral-text: #C5CCD6;
        --neutral-soft: #222831;
        --sidebar: #0A0F1A;
        --sidebar-foreground: #B9C4D4;
        --sidebar-accent: #161E2C;
        --sidebar-ring: #5095FF;
        --code-surface: #0A0D12;
        --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    }
}

/* 3. Base */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--page);
    color: var(--text-body);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

h1, h2 { color: var(--text-strong); line-height: 1.25; margin: 0; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-lg); font-weight: 650; }
p { margin: 0; max-width: 75ch; }
strong { color: var(--text-strong); font-weight: 600; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
code { font-family: var(--font-mono); font-size: var(--fs-sm); }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.muted { color: var(--text-muted); font-size: var(--fs-sm); }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 16px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }

/* 4. Shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px 16px;
    background: var(--sidebar);
    color: var(--sidebar-foreground);
}
.sidebar :focus-visible { outline-color: var(--sidebar-ring); }

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: #FFFFFF; text-decoration: none; font-weight: 700; letter-spacing: 0.04em; }
.sidebar-brand img { display: block; height: 35px; width: auto; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-control);
    color: var(--sidebar-foreground);
    font-weight: 500;
    text-decoration: none;
}
.sidebar-nav a:hover { background: var(--sidebar-accent); color: #FFFFFF; }
.sidebar-nav a[aria-current="page"] { background: var(--primary-gradient); color: #FFFFFF; }

.sidebar-foot { display: flex; flex-direction: column; gap: 12px; padding: 0 8px; }
.sidebar-who { color: #FFFFFF; font-weight: 600; font-size: var(--fs-sm); }
.sidebar-who span { color: var(--sidebar-muted); font-weight: 400; font-size: var(--fs-xs); }

.page { flex: 1; min-width: 0; max-width: 1180px; padding: 32px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-direction: column; gap: 8px; }
.lead { font-size: var(--fs-md); color: var(--text-body); }

/* 5. Guest pages */
.guest { display: flex; align-items: flex-start; justify-content: center; min-height: 100vh; padding: 48px 16px; }
.guest-card {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}
.guest-logo { height: 40px; width: auto; align-self: flex-start; }
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
    .logo-light { display: none; }
    .logo-dark { display: block; }
}
.eyebrow { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.hint { font-size: var(--fs-sm); color: var(--text-muted); }
.divider { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); border-top: 1px solid var(--border-soft); padding-top: 16px; max-width: none; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; }

/* 6. Components */
.card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
}
.card-help { color: var(--text-muted); font-size: var(--fs-sm); }
.empty { color: var(--text-muted); padding: 24px 0; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--control-height);
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary-gradient); color: #FFFFFF; }
.btn-primary:hover { background: var(--primary-hover); color: #FFFFFF; }
.btn-secondary { background: var(--surface); border-color: var(--border-button); color: var(--text-strong); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text-strong); }
.btn-danger { background: var(--danger); color: #FFFFFF; }
.btn-quiet { background: transparent; border-color: var(--sidebar-accent); color: var(--sidebar-foreground); width: 100%; }
.btn-quiet:hover { background: var(--sidebar-accent); color: #FFFFFF; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form-row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1 1 200px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .form > label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-strong); }
.field-help { font-size: var(--fs-xs); color: var(--text-muted); }
.field-error { font-size: var(--fs-sm); color: var(--danger-text); }

.form-input, .form-select {
    width: 100%;
    min-height: var(--control-height);
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--input);
    border-radius: var(--radius-control);
    color: var(--text-strong);
    font: inherit;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-input[aria-invalid="true"], .form-select[aria-invalid="true"] { border-color: var(--danger-text); }
.form-input-code { font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.3em; text-align: center; }

.secret {
    display: block;
    margin: 8px 0;
    padding: 12px 16px;
    background: var(--code-surface);
    border-radius: var(--radius-control);
    color: #FFFFFF;
    overflow-wrap: anywhere;
    user-select: all;
}

.notice { display: flex; flex-direction: column; gap: 8px; padding: 16px 20px; border: 1px solid; border-radius: 14px; max-width: none; }
.notice-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.notice-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.notice-info { background: var(--info-soft); border-color: var(--info-border); color: var(--text-body); }

.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--neutral-text); font-size: var(--fs-xs); font-weight: 600; }
.pill-danger { background: var(--danger-soft); color: var(--danger-text); }
.pill-warning { background: var(--warning-soft); color: var(--warning-text); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; padding: 10px 12px; background: var(--surface-sunken); color: var(--text-strong); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.table td { padding: 12px; border-top: 1px solid var(--border-soft); vertical-align: top; overflow-wrap: anywhere; }

.row-actions summary { cursor: pointer; color: var(--link); font-weight: 600; min-height: 40px; display: inline-flex; align-items: center; }
.row-actions[open] { display: flex; flex-direction: column; gap: 16px; min-width: 240px; }
.row-actions .form { padding-top: 12px; border-top: 1px solid var(--border-soft); align-items: flex-start; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: right; }
.table tfoot td, .table .total td { font-weight: 600; color: var(--text-strong); border-top: 2px solid var(--border); }
.table .group td { background: var(--surface-sunken); font-weight: 600; color: var(--text-strong); }
.pill-success { background: var(--success-soft); color: var(--success-text); }
.pill-info { background: var(--info-soft); color: var(--info-text); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border: 1px solid var(--border-button); border-radius: var(--radius-pill); color: var(--text-strong); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 0; }
.facts dt { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.facts dd { margin: 0; color: var(--text-strong); overflow-wrap: anywhere; }
.stat { font-size: 34px; font-weight: 700; color: var(--text-strong); line-height: 1.2; font-variant-numeric: tabular-nums; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.form-textarea { width: 100%; min-height: 88px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--input); border-radius: var(--radius-control); color: var(--text-strong); font: inherit; }
.line-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 2fr; gap: 8px 12px; align-items: center; }
.line-grid .head { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }

.form-file { padding: 9px 12px; height: auto; }
.match { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.match .btn, .table td form .btn { min-height: 40px; }
.boxes { display: grid; grid-template-columns: auto 1fr auto; gap: 0; }
.boxes > * { padding: 12px; border-top: 1px solid var(--border-soft); }
.boxes .box-no { font-weight: 700; color: var(--text-strong); }
.payslip { max-width: 560px; }

.pay-sheet td:first-child { min-width: 170px; overflow-wrap: normal; white-space: nowrap; }
.pay-sheet td .form-input { min-width: 84px; }
.pay-sheet td .form-input + .form-input { margin-top: 6px; }

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.checks li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 0; border-top: 1px solid var(--border-soft); }
.checks li .btn { min-height: 40px; }

/* 7. Phone */
@media (max-width: 1024px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
    .sidebar-nav a { min-height: 40px; }
    .sidebar-foot { flex-direction: row; align-items: center; margin-left: auto; padding: 0; }
    .sidebar-who span { display: none; }
    .btn-quiet { width: auto; min-height: 40px; }
    .page { padding: 20px 16px; }
}

@media (max-width: 640px) {
    h1 { font-size: 24px; }
    .card, .guest-card { padding: 16px; }
    .guest { padding: 16px; }
    .form-input, .form-select { font-size: var(--fs-md); }
    .form-row .btn { width: 100%; }

    .line-grid { grid-template-columns: 1fr 1fr; }
    .line-grid .head { display: none; }
    .num { text-align: left; }
    .table-stack thead { position: absolute; left: -9999px; }
    .table-stack tr { display: block; padding: 12px 0; border-top: 1px solid var(--border-soft); }
    .table-stack td { display: block; padding: 4px 0; border: 0; }
    .table-stack td::before { content: attr(data-label); display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
}

@media (prefers-reduced-motion: no-preference) {
    .btn, .sidebar-nav a { transition: background-color 0.15s, color 0.15s; }
}

/* Preview mode: a fixed note on every page, so made-up figures are never taken for real ones. */
.preview-bar {
    position: fixed; right: 16px; bottom: 16px; z-index: 50; margin: 0; max-width: calc(100vw - 32px);
    padding: 8px 14px; border: 1px solid var(--warning-border); border-radius: 999px;
    background: var(--warning-soft); color: var(--warning-text); font-size: 0.875rem; font-weight: 600;
}
@media print { .preview-bar { position: static; border-radius: 0; } }

/* Printing (the investor pack): the page only, black on white, no menu or forms. */
@media print {
    :root { color-scheme: light; }
    body, .shell, .page, .card { background: #FFFFFF !important; color: #000000 !important; }
    .sidebar, .skip-link, .no-print { display: none !important; }
    .page { max-width: none; padding: 0; gap: 14px; }
    .card { border: 0; box-shadow: none; padding: 0; break-inside: avoid; }
    .stat { font-size: 22px; }
    .table-wrap { overflow: visible; }
    .table td, .table th { padding-top: 4px; padding-bottom: 4px; color: #000000 !important; }
}
