/* ============================================================================
   Digital Invoice Portal — design system
   Navy sidebar, blue primary, green success, orange pending.
   ========================================================================== */

:root {
    /* Brand */
    --navy-900: #071B33;
    --navy-800: #0B2A4F;
    --navy-700: #123765;
    --navy-600: #1A4680;
    --blue-600: #1B6FE8;
    --blue-700: #1559C0;
    --blue-100: #E4EEFC;
    --green-600: #17A462;
    --green-700: #12854F;
    --green-100: #E3F7EC;
    --amber-600: #E08A0B;
    --amber-100: #FDF0DA;
    --red-600: #D63B3B;
    --red-100: #FBE5E5;

    /* Neutrals */
    --bg: #F4F7FB;
    --surface: #FFFFFF;
    --ink: #0F2038;
    --ink-soft: #55677F;
    --ink-faint: #8A9AB0;
    --line: #E5EDF7;
    --line-soft: #F0F5FB;

    /* Shape */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 32, 56, .06), 0 1px 3px rgba(15, 32, 56, .04);
    --shadow: 0 2px 8px rgba(15, 32, 56, .06), 0 8px 24px rgba(15, 32, 56, .05);

    --sidebar-w: 248px;
    --topbar-h: 66px;

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); text-decoration: underline; }

/* ============================ Shell ====================================== */

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

/* ---- Sidebar ---- */

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--navy-800);
    color: #C8D6E8;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1040;
    transition: transform .22s ease;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar__brand-text { line-height: 1.1; }

.sidebar__brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 15.5px;
    letter-spacing: -.01em;
    display: block;
}

.sidebar__brand-tag {
    color: #7F97B5;
    font-size: 10px;
    letter-spacing: .04em;
    display: block;
    margin-top: 2px;
}

.sidebar__section {
    padding: 18px 20px 6px;
    font-size: 10px;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: #5F7899;
    font-weight: 600;
}

.sidebar__nav {
    list-style: none;
    margin: 0;
    padding: 8px 12px;
    flex: 1;
    overflow-y: auto;
}

.sidebar__nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9.5px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: #BCCCE0;
    font-size: 14px;
    font-weight: 500;
    transition: background .14s, color .14s;
}

.sidebar__nav a:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
    text-decoration: none;
}

.sidebar__nav a.is-active {
    background: var(--blue-600);
    color: #fff;
    box-shadow: 0 2px 10px rgba(27, 111, 232, .35);
}

.sidebar__nav svg { flex: 0 0 18px; width: 18px; height: 18px; }

.sidebar__foot {
    padding: 14px 20px 18px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: 11.5px;
    color: #6F88A8;
}

/* ---- Main column ---- */

.main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar__title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.015em;
    margin: 0;
    color: var(--ink);
}

.topbar__spacer { flex: 1; }

.topbar__search {
    position: relative;
    width: 260px;
    max-width: 34vw;
}

.topbar__search input {
    width: 100%;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 14px 0 38px;
    font-size: 13.5px;
    background: var(--bg);
    color: var(--ink);
}

.topbar__search input:focus {
    outline: none;
    border-color: var(--blue-600);
    background: #fff;
    box-shadow: 0 0 0 3px var(--blue-100);
}

.topbar__search svg {
    position: absolute;
    left: 13px; top: 50%;
    transform: translateY(-50%);
    width: 15px; height: 15px;
    color: var(--ink-faint);
}

.icon-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
}

.icon-btn:hover { background: var(--bg); color: var(--ink); }

.icon-btn__dot {
    position: absolute;
    top: 8px; right: 9px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--red-600);
    border: 1.5px solid #fff;
}

.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--blue-600);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 650;
    font-size: 13px;
}

.env-pill {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 5px 11px;
    border-radius: 999px;
}

.env-pill--sandbox { background: var(--blue-100); color: var(--blue-700); }
.env-pill--production { background: var(--red-100); color: var(--red-600); }

.content {
    padding: 26px;
    flex: 1;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 27, 51, .5);
    z-index: 1035;
}

/* ============================ Page header ================================ */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.page-head h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0 0 3px;
}

.page-head p {
    margin: 0;
    color: var(--ink-soft);
    font-size: 13.5px;
}

/* ============================ Cards ====================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card__head {
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card__title {
    font-size: 15px;
    font-weight: 650;
    margin: 0;
    letter-spacing: -.01em;
}

.card__body { padding: 20px; }

/* ---- KPI stat cards (the poster's four tiles) ---- */

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 17px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: box-shadow .16s, transform .16s;
}

.stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat__label {
    font-size: 12.5px;
    color: var(--ink-soft);
    font-weight: 500;
    margin: 0 0 6px;
}

.stat__value {
    font-size: 27px;
    font-weight: 750;
    line-height: 1.05;
    letter-spacing: -.025em;
    margin: 0;
    color: var(--ink);
}

.stat__sub {
    font-size: 11.5px;
    color: var(--ink-faint);
    margin: 5px 0 0;
}

.stat__icon {
    width: 44px; height: 44px;
    flex: 0 0 44px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.stat__icon svg { width: 21px; height: 21px; }
.stat__icon--blue { background: var(--blue-100); color: var(--blue-600); }
.stat__icon--green { background: var(--green-100); color: var(--green-600); }
.stat__icon--amber { background: var(--amber-100); color: var(--amber-600); }
.stat__icon--navy { background: #E3E9F3; color: var(--navy-700); }
.stat__icon--red { background: var(--red-100); color: var(--red-600); }

/* ============================ Tables ===================================== */

.table-wrap { overflow-x: auto; }

table.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.tbl th {
    text-align: left;
    padding: 11px 18px;
    background: var(--line-soft);
    color: var(--ink-soft);
    font-weight: 650;
    font-size: 11.5px;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

table.tbl td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #FAFCFF; }

.t-right { text-align: right; }
.t-center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--ink-faint);
}

.empty svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: .5; }
.empty p { margin: 0 0 4px; font-size: 14px; color: var(--ink-soft); font-weight: 550; }
.empty span { font-size: 13px; }

/* ============================ Status pills =============================== */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3.5px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .01em;
    white-space: nowrap;
}

.pill--green { background: var(--green-100); color: var(--green-700); }
.pill--amber { background: var(--amber-100); color: var(--amber-600); }
.pill--red { background: var(--red-100); color: var(--red-600); }
.pill--blue { background: var(--blue-100); color: var(--blue-700); }
.pill--grey { background: #EDF1F7; color: var(--ink-soft); }

.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.scenario-tag {
    display: inline-block;
    padding: 2.5px 8px;
    border-radius: 6px;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: 11.5px;
    font-weight: 650;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ============================ Buttons ==================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .14s, box-shadow .14s, border-color .14s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn--primary { background: var(--blue-600); color: #fff; box-shadow: 0 1px 3px rgba(27, 111, 232, .35); }
.btn--primary:hover { background: var(--blue-700); color: #fff; }

.btn--success { background: var(--green-600); color: #fff; }
.btn--success:hover { background: var(--green-700); color: #fff; }

.btn--ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn--ghost:hover { background: var(--bg); color: var(--ink); }

.btn--outline-primary { background: var(--surface); color: var(--blue-600); border-color: var(--blue-600); }
.btn--outline-primary:hover { background: var(--blue-100); color: var(--blue-700); }

.btn--danger-ghost { background: var(--surface); color: var(--red-600); border-color: var(--line); }
.btn--danger-ghost:hover { background: var(--red-100); }

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

/* ============================ Forms ====================================== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
}

.fld { display: flex; flex-direction: column; }
.fld--2 { grid-column: span 2; }
.fld--3 { grid-column: span 3; }
.fld--4 { grid-column: span 4; }
.fld--5 { grid-column: span 5; }
.fld--6 { grid-column: span 6; }
.fld--12 { grid-column: span 12; }

.fld > label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 6px;
}

.fld input[type=text],
.fld input[type=number],
.fld input[type=date],
.fld input[type=password],
.fld input[type=email],
.fld select,
.fld textarea,
input.inp, select.inp {
    height: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 11px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface);
    width: 100%;
}

.fld textarea { height: auto; padding: 9px 11px; }

.fld input:focus, .fld select:focus, .fld textarea:focus,
input.inp:focus, select.inp:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px var(--blue-100);
}

.fld input[readonly] { background: var(--line-soft); color: var(--ink-soft); }

.hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }
.hint code { background: var(--line-soft); padding: 1px 5px; border-radius: 4px; font-size: 11px; color: var(--navy-700); }

.field-error, .text-danger { color: var(--red-600); font-size: 12px; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--blue-600); }
.check label { font-size: 13.5px; font-weight: 500; margin: 0; }
.check .hint { margin-top: 2px; }

.input-join { display: flex; gap: 0; }
.input-join input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-join .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }

/* ============================ Alerts ===================================== */

.alert {
    border-radius: var(--radius);
    padding: 13px 16px;
    margin-bottom: 16px;
    font-size: 13.5px;
    border: 1px solid transparent;
    display: flex;
    gap: 11px;
    align-items: flex-start;
}

.alert svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }
.alert strong { font-weight: 650; }
.alert ul { margin: 7px 0 0; padding-left: 18px; }
.alert li { margin-bottom: 3px; }

.alert--success { background: var(--green-100); border-color: #BDE7CF; color: var(--green-700); }
.alert--info { background: var(--blue-100); border-color: #C3DAFA; color: var(--blue-700); }
.alert--warning { background: var(--amber-100); border-color: #F5D9A8; color: #9A5E06; }
.alert--danger { background: var(--red-100); border-color: #F3C4C4; color: #A82B2B; }
.alert--plain { background: var(--surface); border-color: var(--line); color: var(--ink-soft); }

/* ============================ Invoice document =========================== */

.doc {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.doc__head {
    padding: 22px 26px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.doc__meta { text-align: right; }
.doc__meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.doc__meta-value { font-size: 15px; font-weight: 650; }

.doc__parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 26px;
    padding: 22px 26px;
    border-bottom: 1px solid var(--line);
}

.doc__party-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink-faint);
    margin-bottom: 7px;
}

.doc__party-name { font-weight: 650; font-size: 14.5px; margin-bottom: 3px; }
.doc__party-line { font-size: 13px; color: var(--ink-soft); }

.doc__totals {
    padding: 18px 26px;
    background: var(--line-soft);
    display: flex;
    justify-content: flex-end;
}

.doc__totals-inner { width: 320px; max-width: 100%; }

.doc__total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13.5px;
    color: var(--ink-soft);
}

.doc__total-row--grand {
    border-top: 2px solid var(--navy-800);
    margin-top: 8px;
    padding-top: 11px;
    font-size: 17px;
    font-weight: 750;
    color: var(--ink);
}

.irn-box {
    background: var(--green-100);
    border: 1px solid #BDE7CF;
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.irn-box__label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--green-700); font-weight: 650; }
.irn-box__value { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; font-weight: 650; color: var(--green-700); }

/* ============================ Misc ======================================= */

.dl { margin: 0; }
.dl__row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.dl__row:last-child { border-bottom: none; }
.dl__key { color: var(--ink-soft); }
.dl__val { font-weight: 550; text-align: right; }

.section-note {
    font-size: 12.5px;
    color: var(--ink-faint);
    margin-top: 10px;
}

.spin {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ Responsive ================================= */

@media (max-width: 1200px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar.is-open ~ .sidebar-backdrop { display: block; }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .content { padding: 18px 16px; }
    .doc__parties { grid-template-columns: 1fr; gap: 18px; }
}

@media (max-width: 768px) {
    .stats { grid-template-columns: 1fr; }
    .topbar__search { display: none; }
    .fld--2, .fld--3, .fld--4, .fld--5, .fld--6 { grid-column: span 12; }
    .page-head { flex-direction: column; }
}

.menu-toggle { display: none; }
@media (max-width: 992px) { .menu-toggle { display: inline-flex; } }

/* ============================ Print ====================================== */

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
    body { background: #fff; }
    .doc { border: none; box-shadow: none; }
}
