/*
 * ACTVET Course Quotations — hand-written stylesheet (no build step).
 * Implements handoff/design_handoff_course_quotations/design-system/design-tokens.json.
 * Desktop-first (1440px); tables and the matrix scroll horizontally.
 */

:root {
    /* Brand */
    --color-primary-light: #00658f;
    --color-blue: #0084ad;
    --color-blue-light: #00bbe6;
    --color-green: #b8db55;
    --color-red: #e34123;
    --color-yellow: #fee300;
    --color-gold: #ae7e30;

    /* Semantic (light values are authoritative) */
    --background: #f7f7f8;
    --foreground: #1a1c23;
    --card: #ffffff;
    --card-foreground: #1a1c23;
    --popover: #ffffff;
    --primary: #003764;
    --primary-foreground: #fafafa;
    --secondary: #f1f2f4;
    --secondary-foreground: #2a2d36;
    --muted: #f1f2f4;
    --muted-foreground: #6b7280;
    --destructive: #991b1b;
    --destructive-soft: #fef2f2;
    --warning-foreground: #a16207;
    --warning-soft: #fefce8;
    --warning-text: #854d0e;
    --success: #bbf7d0;
    --success-foreground: #15803d;
    --success-soft: #f0fdf4;
    --border: #e5e7eb;
    --input: #e5e7eb;
    --ring: #a1a1aa;

    --radius: 10px;
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    --sidebar-width: 256px;
    --header-h: 64px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans', ui-sans-serif, system-ui, sans-serif;
    font-size: 13.5px;
    color: var(--foreground);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- app shell */

.app { display: flex; min-height: 100vh; }

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-stripe {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: 4px;
    flex: none;
}
.brand-stripe span:nth-child(1) { background: var(--primary); }
.brand-stripe span:nth-child(2) { background: var(--color-blue); }
.brand-stripe span:nth-child(3) { background: var(--color-red); }
.brand-stripe span:nth-child(4) { background: var(--color-yellow); }

.app-header {
    height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    flex: none;
}

.breadcrumb {
    font-size: 13.5px;
    color: var(--muted-foreground);
    white-space: nowrap;
}
.breadcrumb .sep { color: #d1d5db; margin: 0 6px; }
.breadcrumb .current { color: var(--foreground); font-weight: 600; }

.app-header .spacer { flex: 1; }

.scope-pill {
    height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 12.5px;
    color: var(--secondary-foreground);
    background: var(--card);
    white-space: nowrap;
}

main.page {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
}

.app-footer {
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    font-size: 12px;
    color: var(--muted-foreground);
    display: flex;
    justify-content: space-between;
    background: var(--card);
}

/* ------------------------------------------------------------------ sidebar */

.sidebar {
    width: var(--sidebar-width);
    flex: none;
    background: var(--primary);
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar-brand .brand-logo { width: 185px; height: auto; display: block; }
.sidebar-brand .sub { font-size: 12px; color: rgba(255, 255, 255, 0.6); margin-top: 8px; }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.nav-group-label {
    font-size: 10.9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    padding: 12px 8px 6px;
}

.nav-row {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
    font-size: 13.5px;
    text-decoration: none;
}
.nav-row:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.nav-row .dot {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.4);
    flex: none;
}
.nav-row.is-active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-weight: 600;
}
.nav-row.is-active .dot { background: var(--color-yellow); }

.sidebar-user {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user .avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex: none;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who .n {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user .who .r { color: rgba(255, 255, 255, 0.55); font-size: 11.5px; }

.btn-exit {
    height: 30px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: transparent;
    color: #fff;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
}
.btn-exit:hover { background: rgba(255, 255, 255, 0.08); }

/* --------------------------------------------------------------- typography */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-title { font-size: 24px; font-weight: 600; margin: 0; }
.page-sub { font-size: 13.5px; color: var(--muted-foreground); margin: 4px 0 0; }
.muted { color: var(--muted-foreground); }
.text-xs { font-size: 12px; }

/* ------------------------------------------------------------------ buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: #00457d; }
.btn-primary:disabled,
.btn-primary.is-disabled {
    background: var(--secondary);
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-outline { background: var(--card); color: var(--foreground); border-color: var(--border); }
.btn-outline:hover { background: var(--background); border-color: #d1d5db; }

.btn-ghost-destructive { background: transparent; color: var(--destructive); box-shadow: none; }
.btn-ghost-destructive:hover { background: var(--destructive-soft); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-lg { height: 40px; }

/* -------------------------------------------------------------------- cards */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
}
.card-header {
    padding: 16px 18px;
    border-bottom: 1px solid #f1f2f4;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0; }
.card-desc { font-size: 12.5px; color: var(--muted-foreground); margin: 3px 0 0; }
.card-body { padding: 18px; }
.card-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.card-accent { border-top: 4px solid var(--primary); }

/* ------------------------------------------------------------------- alerts */

.alert {
    border: 1px solid;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
}
.alert .alert-title { font-weight: 600; margin: 0 0 2px; }
.alert-success { border-color: var(--success-foreground); background: var(--success-soft); color: var(--success-foreground); }
.alert-error { border-color: var(--destructive); background: var(--destructive-soft); color: var(--destructive); }
.alert-warning { border-color: var(--warning-foreground); background: var(--warning-soft); color: var(--warning-text); }
.alert-warning .alert-title { color: var(--warning-foreground); }
.alert p { margin: 0; }

/* ------------------------------------------------------------------- badges */

.badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: 8px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-active { background: var(--success); color: var(--success-foreground); }
.badge-inactive { background: var(--secondary); color: var(--muted-foreground); }
.badge-navy { background: var(--primary); color: #fff; }

.chip {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 12px;
    border-radius: 9999px;
    background: var(--secondary);
    font-size: 12px;
    font-weight: 600;
    color: var(--secondary-foreground);
    white-space: nowrap;
}

/* -------------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted-foreground); }

.input, .textarea, select.input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--input);
    border-radius: 8px;
    background: var(--card);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--foreground);
    box-shadow: var(--shadow-xs);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus, .textarea:focus, select.input:focus {
    outline: 2px solid var(--ring);
    outline-offset: -1px;
}
.input::placeholder, .textarea::placeholder { color: #9ca3af; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }

.input-group { position: relative; }
.input-group .toggle-eye {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 4px 8px;
}

/* Toggle switch (40×22 track, 16px knob) */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
}
.switch-row .lbl { font-size: 13.5px; font-weight: 500; }
.switch-row .sub { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: var(--secondary);
    border: 1px solid var(--border);
    transition: background 0.15s;
    pointer-events: none;
}
.switch .track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 9999px;
    background: #fff;
    box-shadow: var(--shadow-xs);
    transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 1px; }

/* Participants stepper */
.stepper {
    display: inline-flex;
    align-items: stretch;
    width: 150px;
    height: 36px;
    border: 1px solid var(--input);
    border-radius: 8px;
    background: var(--card);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.stepper button {
    width: 38px;
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 16px;
    color: var(--secondary-foreground);
    cursor: pointer;
}
.stepper button:hover { background: var(--background); }
.stepper input {
    flex: 1;
    min-width: 0;
    border: 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: center;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--foreground);
}
.stepper input:focus { outline: none; background: var(--background); }

/* Autocomplete popover */
.autocomplete { position: relative; }
.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 4px;
    max-height: 210px;
    overflow-y: auto;
    margin: 0;
    list-style: none;
}
.autocomplete-list li {
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
}
.autocomplete-list li .n { font-size: 13.5px; font-weight: 500; }
.autocomplete-list li .m { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }
.autocomplete-list li:hover { background: #f7f7f8; }
.autocomplete-list li.is-active { background: var(--secondary); }
.autocomplete-list li.is-active .n { color: var(--primary); font-weight: 600; }

/* ------------------------------------------------------------------- tables */

.table-wrap {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    overflow-x: auto;
    box-shadow: var(--shadow-xs);
}
table.table { width: 100%; border-collapse: collapse; }
table.table th {
    background: #f7f7f8;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted-foreground);
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.table td {
    font-size: 13px;
    padding: 13px 14px;
    border-bottom: 1px solid #f1f2f4;
    vertical-align: middle;
}
table.table tbody tr:last-child td { border-bottom: 0; }
table.table .num { text-align: right; }
table.table .actions { text-align: right; white-space: nowrap; }
table.table .actions form { display: inline; }
table.table .total { font-weight: 700; }

/* Key/value rows (detail cards) */
.kv { display: flex; flex-direction: column; gap: 11px; }
.kv .row { display: flex; justify-content: space-between; gap: 16px; }
.kv .k { font-size: 13px; color: var(--muted-foreground); flex: none; }
.kv .v { font-size: 13px; font-weight: 500; text-align: right; }

/* ------------------------------------------------------------ price summary */

.price-summary { position: sticky; top: 24px; }
.price-line {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 7px 0;
}
.price-line .lbl { font-size: 13.5px; font-weight: 500; }
.price-line .sub { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }
.price-line .amt { font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.price-total { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 12px; }
.price-total .lbl {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-foreground);
}
.price-total .val { font-size: 24px; font-weight: 700; color: var(--primary); margin-top: 2px; }
.price-note { font-size: 11.5px; color: var(--muted-foreground); margin-top: 10px; }

.price-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 10px; text-align: center; }
.price-empty .ph { width: 38px; height: 38px; border-radius: 9999px; background: var(--secondary); }
.price-empty p { margin: 0; font-size: 13px; color: var(--muted-foreground); }

/* --------------------------------------------------------------------- tabs */

.tabs {
    display: inline-flex;
    background: var(--secondary);
    padding: 3px;
    border-radius: 10px;
    gap: 2px;
}
.tabs a {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted-foreground);
    text-decoration: none;
}
.tabs a:hover { color: var(--foreground); text-decoration: none; }
.tabs a.is-active {
    background: var(--card);
    color: var(--foreground);
    font-weight: 600;
    box-shadow: var(--shadow-xs);
}

/* ------------------------------------------------------------------- matrix */

.matrix-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    overflow: auto;
    box-shadow: var(--shadow-xs);
}
table.matrix { border-collapse: collapse; min-width: 980px; width: 100%; }
table.matrix th {
    background: #f7f7f8;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted-foreground);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: right;
}
table.matrix th.from {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #fff;
    text-align: left;
    min-width: 170px;
    border-right: 1px solid var(--border);
    color: var(--foreground);
    font-weight: 500;
    font-size: 12.5px;
}
table.matrix thead th.from { background: #f7f7f8; color: var(--muted-foreground); font-weight: 600; }
table.matrix td { padding: 5px; border-bottom: 1px solid #f1f2f4; }
table.matrix tbody tr:last-child td, table.matrix tbody tr:last-child th { border-bottom: 0; }
table.matrix td input {
    width: 100%;
    min-width: 74px;
    height: 30px;
    border: 1px solid var(--input);
    border-radius: 6px;
    text-align: right;
    padding: 0 8px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    background: var(--card);
    color: var(--foreground);
}
table.matrix td input::placeholder { color: #c4c8cd; }
table.matrix td input:focus { outline: 2px solid var(--ring); outline-offset: -1px; }
table.matrix td.diag input { background: var(--secondary); color: var(--muted-foreground); }

/* ------------------------------------------------------------- empty states */

.empty-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 24px;
    text-align: center;
}
.empty-card .tile { width: 44px; height: 44px; border-radius: 10px; background: #f1f2f4; }
.empty-card h2 { font-size: 15px; font-weight: 600; margin: 0; }
.empty-card p { margin: 0; font-size: 13px; color: var(--muted-foreground); max-width: 360px; }

/* -------------------------------------------------------------------- login */

.login-split {
    display: grid;
    grid-template-columns: 55% 45%;
    min-height: 100vh;
}
.login-left {
    background: var(--primary);
    color: #fff;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
.login-brand { text-align: center; max-width: 80%; }
.login-logo { width: 100%; max-width: 460px; height: auto; display: block; margin: 0 auto; }
.login-subtitle {
    margin-top: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}
.login-left .cube-pattern {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 300px;
    height: auto;
    pointer-events: none;
}

.login-right {
    background: #fff;
    display: flex;
    flex-direction: column;
}
.login-right .form-holder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}
.login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login-form h1 { font-size: 24px; font-weight: 600; margin: 0; }
.login-form .sub { font-size: 14px; color: var(--muted-foreground); margin: -10px 0 0; }

/* ---------------------------------------------------------------- utilities */

.row { display: flex; align-items: center; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1.15fr; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.ml-auto { margin-left: auto; }
.mw-900 { max-width: 900px; }
.mw-640 { max-width: 640px; }

/* ------------------------------------------------------------ v2: proposals */

/* Course line cards on the new-quotation form */
.item-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: var(--card);
}
.item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.item-head .item-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--primary);
}

/* Status badges (funnel) */
.badge-status-open        { background: var(--secondary); color: var(--secondary-foreground); }
.badge-status-sent        { background: #e0f2fe; color: #075985; }
.badge-status-negotiating { background: var(--warning-soft); color: var(--warning-text); }
.badge-status-accepted    { background: var(--success); color: var(--success-foreground); }
.badge-status-rejected    { background: var(--destructive-soft); color: var(--destructive); }
.badge-status-expired     { background: #fff7ed; color: #9a3412; }
.badge-status-cancelled   { background: var(--secondary); color: var(--muted-foreground); text-decoration: line-through; }
.badge-status-revised     { background: #ede9fe; color: #5b21b6; }

/* Status filter chips on the quotations list */
.chip-link { text-decoration: none; cursor: pointer; }
.chip-link:hover { background: var(--border); }
.chip-link.is-active { background: var(--primary); color: #fff; }
.chip-link .cnt { margin-left: 6px; opacity: 0.7; font-weight: 400; }

/* Dashboard stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
}
.stat-card .k {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
}
.stat-card .v { font-size: 26px; font-weight: 700; color: var(--primary); margin-top: 6px; }
.stat-card .s { font-size: 12px; color: var(--muted-foreground); margin-top: 3px; }

/* Muted variant used in per-line price summaries */
.price-line .lbl.muted { font-weight: 400; color: var(--muted-foreground); }

/* The hidden attribute must win over .field/.row display rules */
[hidden] { display: none !important; }
