@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    /* Brand */
    --brand:        #0d9488;
    --brand-dark:   #0f766e;
    --brand-light:  #ccfbf1;
    --brand-subtle: #f0fdfa;

    /* Sidebar */
    --sidebar-bg:           #0c1f2e;
    --sidebar-border:       rgba(255,255,255,0.06);
    --sidebar-text:         #7a9ab0;
    --sidebar-text-active:  #e2f0ef;
    --sidebar-hover-bg:     rgba(13,148,136,0.12);
    --sidebar-active-bg:    rgba(13,148,136,0.22);
    --sidebar-active-border:#0d9488;
    --sidebar-width:        256px;

    /* Neutrals */
    --ink:       #0f172a;
    --muted:     #64748b;
    --subtle:    #94a3b8;
    --line:      #e2e8f0;
    --surface:   #ffffff;
    --page:      #f1f5f9;

    /* Semantic palette */
    --c-green:      #059669; --c-green-bg:   #ecfdf5; --c-green-border: rgba(5,150,105,.2);
    --c-blue:       #2563eb; --c-blue-bg:    #eff6ff; --c-blue-border:  rgba(37,99,235,.2);
    --c-amber:      #d97706; --c-amber-bg:   #fffbeb; --c-amber-border: rgba(217,119,6,.2);
    --c-red:        #dc2626; --c-red-bg:     #fef2f2; --c-red-border:   rgba(220,38,38,.2);
    --c-purple:     #7c3aed; --c-purple-bg:  #f5f3ff; --c-purple-border:rgba(124,58,237,.2);
    --c-teal:       #0d9488; --c-teal-bg:    #f0fdfa; --c-teal-border:  rgba(13,148,136,.2);
    --c-slate:      #475569; --c-slate-bg:   #f8fafc; --c-slate-border: rgba(71,85,105,.2);
    --c-orange:     #ea580c; --c-orange-bg:  #fff7ed; --c-orange-border:rgba(234,88,12,.2);
    --c-indigo:     #4f46e5; --c-indigo-bg:  #eef2ff; --c-indigo-border:rgba(79,70,229,.2);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15,23,42,.05);
    --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06);
    --shadow:    0 4px 8px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
    --shadow-md: 0 8px 20px rgba(15,23,42,.08), 0 2px 6px rgba(15,23,42,.04);
    --shadow-lg: 0 20px 48px rgba(15,23,42,.14);

    /* Motion */
    --t: 160ms cubic-bezier(.4,0,.2,1);

    /* Radii */
    --r-sm: 6px;
    --r:    10px;
    --r-lg: 14px;
    --r-xl: 20px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 600; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.08) transparent;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 18px 18px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 6px;
    flex-shrink: 0;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: #fff;
    border-radius: var(--r-sm);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(13,148,136,.45);
    letter-spacing: .02em;
}

.brand strong {
    display: block;
    color: #e0eeee;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.brand small {
    display: block;
    color: var(--sidebar-text);
    font-size: 11px;
    margin-top: 1px;
}

/* Navigation */
nav {
    padding: 6px 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.nav-section-label {
    padding: 12px 10px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(122,154,176,.45);
    user-select: none;
}

nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--t), color var(--t), border-color var(--t);
    border-left: 2px solid transparent;
    line-height: 1;
}

nav a .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: .7;
    transition: opacity var(--t);
}

nav a:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
    border-left-color: rgba(13,148,136,.4);
}

nav a:hover .nav-icon { opacity: 1; }

nav a.active {
    background: var(--sidebar-active-bg);
    color: #b2f5ea;
    border-left-color: var(--sidebar-active-border);
    font-weight: 600;
}

nav a.active .nav-icon { opacity: 1; color: #5eead4; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-xs);
}

.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -.01em;
}

.topbar p {
    color: var(--muted);
    margin: 2px 0 0;
    font-size: 12.5px;
}

.userbox {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}

/* ============================================================
   USER MENU DROPDOWN
   ============================================================ */
.user-menu { position: relative; }

.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    padding: 5px 8px;
    cursor: pointer;
    font: inherit;
    transition: background var(--t), border-color var(--t);
}

.user-trigger:hover,
.user-menu.open .user-trigger {
    background: #f1f5f9;
    border-color: var(--line);
}

.user-caret {
    color: var(--muted);
    flex-shrink: 0;
    transition: transform var(--t);
}

.user-menu.open .user-caret { transform: rotate(180deg); }

/* Dropdown panel */
.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity var(--t), visibility var(--t), transform var(--t);
    pointer-events: none;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Header block (name + email) */
.user-dropdown-header {
    padding: 8px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-dropdown-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.user-dropdown-role {
    font-size: 11.5px;
    color: var(--muted);
}

/* Divider */
.user-dropdown-divider {
    border: none;
    border-top: 1px solid var(--line);
    margin: 4px 0;
}

/* Menu items — shared by <a> and <button> */
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background var(--t), color var(--t);
}

.user-dropdown-item:hover { background: #f1f5f9; color: var(--ink); }

.user-dropdown-item.danger { color: var(--c-red); }
.user-dropdown-item.danger:hover { background: var(--c-red-bg); }

/* Content padding wrapper */
.content-area {
    padding: 24px 28px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

/* ============================================================
   BUTTONS
   ============================================================ */
button, .button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--r-sm);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    transition: background var(--t), border-color var(--t), box-shadow var(--t), transform var(--t), color var(--t);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

button:hover, .button:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    box-shadow: var(--shadow-xs);
}

button:active, .button:active { transform: translateY(1px); }

.primary, button.primary, .button.primary {
    color: #fff;
    background: var(--brand);
    border-color: var(--brand);
    box-shadow: 0 1px 3px rgba(13,148,136,.3);
}

.primary:hover, button.primary:hover, .button.primary:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    box-shadow: 0 2px 8px rgba(13,148,136,.4);
    color: #fff;
}

.icon-button {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
}

.icon-button svg { flex-shrink: 0; }

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

/* ============================================================
   KPI GRID
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.kpi-grid article {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--t), transform var(--t);
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeUp .35s ease both;
}

.kpi-grid article:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Stagger animation on KPI cards */
.kpi-grid article:nth-child(1) { animation-delay: .04s; }
.kpi-grid article:nth-child(2) { animation-delay: .08s; }
.kpi-grid article:nth-child(3) { animation-delay: .12s; }
.kpi-grid article:nth-child(4) { animation-delay: .16s; }
.kpi-grid article:nth-child(5) { animation-delay: .20s; }
.kpi-grid article:nth-child(6) { animation-delay: .24s; }

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Icon colour variants */
.kpi-icon.teal   { background: var(--c-teal-bg);   color: var(--c-teal); }
.kpi-icon.blue   { background: var(--c-blue-bg);   color: var(--c-blue); }
.kpi-icon.green  { background: var(--c-green-bg);  color: var(--c-green); }
.kpi-icon.amber  { background: var(--c-amber-bg);  color: var(--c-amber); }
.kpi-icon.red    { background: var(--c-red-bg);    color: var(--c-red); }
.kpi-icon.purple { background: var(--c-purple-bg); color: var(--c-purple); }
.kpi-icon.indigo { background: var(--c-indigo-bg); color: var(--c-indigo); }

.kpi-content span {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.kpi-content strong {
    display: block;
    font-size: 26px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1;
    letter-spacing: -.02em;
}

/* Fallback for plain article > span/strong (no .kpi-content wrapper) */
.kpi-grid > article > span {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.kpi-grid > article > strong {
    display: block;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.02em;
}

/* ============================================================
   PANEL
   ============================================================ */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #e2e8f0;
    scrollbar-gutter: stable;
    animation: fadeUp .3s ease both;
}

.panel:has(> table) {
    overflow: auto;
    max-height: calc(100vh - 190px);
}

form > .panel:has(> table) {
    max-height: calc(100vh - 300px);
}

.table-scroll,
.table-scroll-top {
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #e2e8f0;
}

.table-scroll {
    overflow: auto;
    max-width: 100%;
    max-height: calc(100vh - 190px);
    -webkit-overflow-scrolling: touch;
}

form > .panel .table-scroll {
    max-height: calc(100vh - 330px);
}

.table-scroll-top {
    height: 16px;
    overflow-x: scroll;
    overflow-y: hidden;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.table-scroll-top[hidden] {
    display: none;
}

.table-scroll-top-inner {
    height: 1px;
}

.panel::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar,
.table-scroll-top::-webkit-scrollbar,
.content-area::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

.panel::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track,
.table-scroll-top::-webkit-scrollbar-track,
.content-area::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 999px;
}

.panel::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb,
.table-scroll-top::-webkit-scrollbar-thumb,
.content-area::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border: 3px solid #e2e8f0;
    border-radius: 999px;
}

.panel::-webkit-scrollbar-thumb:hover,
.table-scroll::-webkit-scrollbar-thumb:hover,
.table-scroll-top::-webkit-scrollbar-thumb:hover,
.content-area::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fafcfc 0%, var(--surface) 100%);
}

.panel-head h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -.01em;
}

.actions, .tile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tile-actions {
    padding: 16px 20px;
    gap: 10px;
}

.tile-actions .button {
    padding: 10px 18px;
    font-size: 13.5px;
    border-radius: var(--r-sm);
}

/* ============================================================
   TABBED ENTRY PANELS
   ============================================================ */
.tabbar {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: #f8fafc;
}

.tab-button {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.tab-button.active {
    color: #fff;
    background: var(--brand);
    border-color: var(--brand);
    box-shadow: var(--shadow-xs);
}

.booking-tab-panel { display: none; }
.booking-tab-panel.active { display: block; animation: fadeIn .18s ease; }

.booking-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(130px, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: #f8fafc;
}

.booking-summary div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
}

.booking-summary span {
    display: block;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.booking-summary strong {
    display: block;
    margin-top: 4px;
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   TABLES
   ============================================================ */
table { width: 100%; border-collapse: collapse; }

.panel > table,
.table-scroll > table {
    min-width: max-content;
}

thead tr { background: #f8fafc; }

th {
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 13.5px;
    color: var(--ink);
}

td input[type="number"] {
    min-width: 96px;
}

td.num input[type="number"] {
    max-width: 132px;
    text-align: right;
}

tbody tr { transition: background var(--t); }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* Numeric cells */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    background: var(--c-teal-bg);
    color: var(--c-teal);
    border: 1px solid var(--c-teal-border);
    white-space: nowrap;
}

/* ── Booking statuses ── */
.status--enquiry      { background:var(--c-blue-bg);   color:var(--c-blue);   border-color:var(--c-blue-border); }
.status--confirmed    { background:var(--c-green-bg);  color:var(--c-green);  border-color:var(--c-green-border); }
.status--checked_in   { background:var(--c-teal-bg);   color:var(--c-teal);   border-color:var(--c-teal-border); }
.status--checked_out  { background:var(--c-slate-bg);  color:var(--c-slate);  border-color:var(--c-slate-border); }
.status--cancelled    { background:var(--c-red-bg);    color:var(--c-red);    border-color:var(--c-red-border); }
.status--owner_stay   { background:var(--c-purple-bg); color:var(--c-purple); border-color:var(--c-purple-border); }
.status--no_income    { background:var(--c-orange-bg); color:var(--c-orange); border-color:var(--c-orange-border); }

/* ── Journal / Bill / Capex / Asset statuses ── */
.status--draft        { background:var(--c-slate-bg);  color:var(--c-slate);  border-color:var(--c-slate-border); }
.status--submitted    { background:var(--c-blue-bg);   color:var(--c-blue);   border-color:var(--c-blue-border); }
.status--approved     { background:var(--c-green-bg);  color:var(--c-green);  border-color:var(--c-green-border); }
.status--posted       { background:var(--c-teal-bg);   color:var(--c-teal);   border-color:var(--c-teal-border); }
.status--paid         { background:var(--c-green-bg);  color:#065f46;         border-color:rgba(5,150,105,.3); font-weight:700; }
.status--issued       { background:var(--c-blue-bg);   color:var(--c-blue);   border-color:var(--c-blue-border); }
.status--open         { background:var(--c-blue-bg);   color:var(--c-blue);   border-color:var(--c-blue-border); }
.status--partial      { background:var(--c-amber-bg);  color:var(--c-amber);  border-color:var(--c-amber-border); }
.status--settled      { background:var(--c-green-bg);  color:var(--c-green);  border-color:var(--c-green-border); }
.status--pending      { background:var(--c-amber-bg);  color:var(--c-amber);  border-color:var(--c-amber-border); }
.status--released     { background:var(--c-teal-bg);   color:var(--c-teal);   border-color:var(--c-teal-border); }
.status--void         { background:var(--c-red-bg);    color:var(--c-red);    border-color:var(--c-red-border); }
.status--rejected     { background:var(--c-red-bg);    color:var(--c-red);    border-color:var(--c-red-border); }
.status--reversed     { background:var(--c-amber-bg);  color:var(--c-amber);  border-color:var(--c-amber-border); }
.status--converted    { background:var(--c-purple-bg); color:var(--c-purple); border-color:var(--c-purple-border); }
.status--active       { background:var(--c-green-bg);  color:var(--c-green);  border-color:var(--c-green-border); }
.status--disposed     { background:var(--c-amber-bg);  color:var(--c-amber);  border-color:var(--c-amber-border); }
.status--written_off  { background:var(--c-red-bg);    color:var(--c-red);    border-color:var(--c-red-border); }

/* ============================================================
   FORM PANEL
   ============================================================ */
.form-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    max-width: 760px;
    padding: 26px;
    animation: fadeUp .3s ease;
}

.form-panel.wide { max-width: 1200px; }

.form-section-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
    margin: 24px 0 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    letter-spacing: .01em;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

/* ============================================================
   FORM FIELDS
   ============================================================ */
form p {
    display: grid;
    gap: 5px;
    margin: 0 0 14px;
}

form p label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: .01em;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 9px 12px;
    font: inherit;
    font-size: 13.5px;
    background: #fff;
    color: var(--ink);
    transition: border-color var(--t), box-shadow var(--t);
    outline: none;
    appearance: auto;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(13,148,136,.14);
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: #94a3b8;
}

input[type="radio"],
input[type="checkbox"] { width: auto; }

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

textarea { min-height: 110px; resize: vertical; }

.check-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.check-option.compact {
    min-height: 0;
    white-space: nowrap;
}

.check-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
}

.select-search { margin-bottom: 6px; }

form ul {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

form li label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    background: #fff;
    cursor: pointer;
    font-size: 13.5px;
    transition: border-color var(--t), background var(--t);
}

form li label:hover {
    border-color: var(--brand);
    background: var(--brand-subtle);
}

/* Error text */
.errorlist {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
    color: var(--c-red);
    font-size: 12px;
}

/* ============================================================
   JOURNAL ENTRY TABLE
   ============================================================ */
.entry-grid select,
.entry-grid input { min-width: 120px; }

.entry-grid td {
    padding: 6px 8px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.entry-grid tfoot th {
    text-align: right;
    background: var(--c-teal-bg);
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 700;
}

/* ============================================================
   JOURNAL TALLY
   ============================================================ */
.journal-tally {
    margin-top: 12px;
    padding: 10px 14px;
    border: 1px solid var(--c-red-border);
    border-radius: var(--r-sm);
    background: var(--c-red-bg);
    color: var(--c-red);
    font-size: 13px;
    font-weight: 500;
}

.journal-tally.balanced {
    background: var(--c-green-bg);
    color: var(--c-green);
    border-color: var(--c-green-border);
}

/* ============================================================
   MESSAGES
   ============================================================ */
.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.message {
    padding: 11px 16px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--line);
    background: #fff;
}

.message.success { background:var(--c-green-bg); border-color:var(--c-green-border); color:#065f46; }
.message.error   { background:var(--c-red-bg);   border-color:var(--c-red-border);   color:#991b1b; }
.message.warning { background:var(--c-amber-bg); border-color:var(--c-amber-border); color:#92400e; }
.message.info    { background:var(--c-blue-bg);  border-color:var(--c-blue-border);  color:#1e40af; }

/* ============================================================
   INVOICE SUMMARY
   ============================================================ */
.summary-list {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px 16px;
    padding: 22px;
    margin: 0;
}

.summary-list dt {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .02em;
    padding-top: 1px;
}

.summary-list dd {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0c1f2e 0%, #0d3545 55%, #0f6060 100%);
    padding: 20px;
}

.login-panel {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 38px 34px;
    width: min(420px, 100%);
    animation: fadeUp .45s ease;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 30px;
}

.login-brand .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: var(--r);
    font-size: 17px;
}

.login-tagline {
    display: block;
    color: var(--muted);
    font-size: 12.5px;
    margin-top: 2px;
}

.login-heading {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 4px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   FORM GRID SYSTEM
   ============================================================ */
.fgrid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px 16px;
    align-items: start;
}

/* Column span helpers (within a 4-col grid) */
.fg-1 { grid-column: span 1; }
.fg-2 { grid-column: span 2; }
.fg-3 { grid-column: span 3; }
.fg-4 { grid-column: span 4; }

/* Individual field wrapper: stacks label → input → errors */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

/* Field label — compact uppercase style */
.field > label {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Full-width section separator inside .fgrid */
.fgrid-section {
    grid-column: 1 / -1;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--subtle);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    margin-top: 8px;
}

.cash-entry-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 22px;
    align-items: start;
}

.denomination-panel {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: #f8fafc;
    overflow: hidden;
}

.denomination-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.denomination-panel-head h3 {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.denomination-panel-head strong,
.cash-modal-summary strong {
    font-variant-numeric: tabular-nums;
}

.denomination-table {
    width: 100%;
    background: var(--surface);
}

.denomination-table th,
.denomination-table td {
    padding: 8px 10px;
}

.denomination-table input {
    min-width: 0;
    width: 74px;
    padding: 6px 8px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.cash-modal[hidden] {
    display: none;
}

.cash-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.cash-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .46);
}

.cash-modal-panel {
    position: relative;
    width: min(420px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    padding: 18px;
}

.cash-modal-panel.allocation-modal-panel {
    width: min(760px, 100%);
}

.cash-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.cash-modal-head h2 {
    font-size: 16px;
}

.cash-modal-panel .denomination-panel {
    margin-top: 14px;
}

.cash-modal-summary {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: center;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: #f8fafc;
}

.cash-modal-summary span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.cash-modal-summary strong {
    text-align: right;
}

.cash-modal-summary strong.balanced {
    color: var(--c-green);
}

.cash-modal-summary strong.unbalanced {
    color: var(--c-red);
}

.allocation-table {
    margin-top: 14px;
}

.allocation-table input[type="number"] {
    width: 92px;
    min-width: 0;
    text-align: right;
}

.allocation-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
}

body.modal-open {
    overflow: hidden;
}

.mini-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.mini-stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}

.mini-stat span {
    display: block;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mini-stat strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Compact textarea for notes/description */
.field-notes textarea,
textarea.compact { min-height: 52px; }

/* ── Property / option pill buttons ──────────────────────── */
/* Used by manually-iterated RadioSelect fields               */
.prop-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.prop-pill {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    padding: 7px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    transition: border-color var(--t), background var(--t),
                color var(--t), box-shadow var(--t);
}

/* Hide the native radio circle */
.prop-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* Hover */
.prop-pill:hover {
    border-color: var(--brand);
    background: var(--brand-subtle);
    color: var(--brand-dark);
}

/* Selected — :has() is baseline-2023 in all modern browsers */
.prop-pill:has(input[type="radio"]:checked) {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(13,148,136,.28);
}

/* Date inputs should not stretch beyond their content */
input[type="date"] { min-width: 0; }

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: static;
        height: auto;
        overflow: visible;
        border-bottom: 1px solid rgba(255,255,255,.08);
    }

    .brand {
        padding: 14px 16px;
        margin-bottom: 0;
    }

    nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 6px 10px 10px;
        gap: 3px;
    }

    .nav-section-label { display: none; }

    nav a {
        padding: 7px 10px;
        font-size: 12px;
        border-left: none;
        border-bottom: 2px solid transparent;
        border-radius: var(--r-sm) var(--r-sm) 0 0;
    }

    nav a:hover, nav a.active {
        border-left-color: transparent;
        border-bottom-color: var(--brand);
    }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); }

    .content-area { padding: 16px; }

    .topbar {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .mini-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .cash-entry-layout { grid-template-columns: 1fr; }
    .denomination-panel { max-width: 420px; }
}

@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }

    table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

    .form-panel { padding: 16px; }

    .fgrid {
        grid-template-columns: repeat(2, 1fr);
    }
    .fg-1 { grid-column: span 1; }
    .fg-2, .fg-3, .fg-4 { grid-column: span 2; }
    .mini-stat-grid { grid-template-columns: 1fr; }
}
