/* ── CSS variables ───────────────────────────────────────── */
:root {
    --brand:       #8B6914;
    --brand-50:    #FDF6E3;
    --brand-100:   #F5E6C0;
    --brand-800:   #5C4205;
    --brand-text:  #fff;

    --bg:          #F5F5F5;
    --bg2:         #EFEFEF;
    --bg3:         #E8E8E8;
    --surface:     #FFFFFF;
    --border:      #E2E2E2;
    --border2:     #D5D5D5;

    --text:        #111111;
    --text1:       #111111;   /* alias for --text — both names appear across templates */
    --text2:       #555555;
    --text3:       #888888;

    --success-bg:  #ECFDF5; --success:  #065F46;
    --warn-bg:     #FFFBEB;  --warn:     #92400E;
    --danger-bg:   #FEF2F2;  --danger:   #991B1B;
    --info-bg:     #EFF6FF;  --info:     #1E40AF;

    --radius:      8px;
    --radius-lg:   12px;

    --sw: 168px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 13px; color: var(--text); background: var(--bg); }
a { color: var(--brand); }

/* ── App shell ───────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar { width: var(--sw); background: var(--brand-800); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.sb-head { padding: 16px 12px; border-bottom: .5px solid rgba(255,255,255,.1); }
.sb-logo { display: flex; align-items: center; gap: 8px; }
.sb-icon { width: 32px; height: 32px; background: rgba(255,255,255,.18); border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0; }
.sb-name { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.92); }
.sb-sub  { font-size: 10px; color: rgba(255,255,255,.4); }
.sb-nav  { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-i   { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; font-size: 12px; color: rgba(255,255,255,.52); text-decoration: none; transition: background .12s, color .12s; }
.nav-i:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.88); }
.nav-i.act   { background: rgba(255,255,255,.15); color: #fff; }
.nav-spacer  { flex: 1; }
.sb-foot { padding: 10px 12px; border-top: .5px solid rgba(255,255,255,.1); }
.sb-tenant   { background: rgba(255,255,255,.08); border-radius: 7px; padding: 8px 10px; }
.sb-tn { font-size: 11px; font-weight: 500; color: rgba(255,255,255,.8); }
.sb-tp { font-size: 10px; color: rgba(255,255,255,.4); margin-top: 2px; }
.logout-btn  { background: none; border: none; font-size: 10px; color: rgba(255,255,255,.4); cursor: pointer; padding: 0; font-family: inherit; }
.logout-btn:hover { color: rgba(255,255,255,.7); }

/* ── Main content ────────────────────────────────────────── */
.main-content { flex: 1; padding: 20px 24px; overflow: auto; min-width: 0; }

/* ── Flash messages ──────────────────────────────────────── */
.flash { padding: 10px 14px; border-radius: var(--radius); font-size: 12px; margin-bottom: 14px; }
.flash-ok  { background: var(--success-bg); color: var(--success); }
.flash-err { background: var(--danger-bg);  color: var(--danger); }

/* ── Page header ─────────────────────────────────────────── */
.ph  { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.pt  { font-size: 17px; font-weight: 500; color: var(--text); }
.ps  { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: var(--radius); font-size: 12px; font-weight: 500; cursor: pointer; border: .5px solid var(--border2); background: var(--surface); color: var(--text); transition: background .12s; font-family: inherit; text-decoration: none; }
.btn:hover  { background: var(--bg2); }
.btn-p      { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.btn-p:hover { background: var(--brand-800); border-color: var(--brand-800); }

/* ── Cards ───────────────────────────────────────────────── */
.card { background: var(--surface); border: .5px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; }
.ch   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding-bottom: 10px; border-bottom: .5px solid var(--border); }
.ct   { font-size: 12px; font-weight: 500; }

/* ── Stats grid ──────────────────────────────────────────── */
.sg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.sc { background: var(--surface); border: .5px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.sl { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.sv { font-size: 24px; font-weight: 500; }
.ss { font-size: 10px; color: var(--text3); margin-top: 3px; }
.sa { color: var(--brand); }

/* ── Two col ─────────────────────────────────────────────── */
.tc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Table ───────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { text-align: left; padding: 6px 8px; font-size: 10px; font-weight: 500; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; border-bottom: .5px solid var(--border); }
.tbl td { padding: 10px 8px; border-bottom: .5px solid var(--border); color: var(--text); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg2); }
.empty-cell { text-align: center; color: var(--text3); padding: 20px !important; }

/* ── Badges ──────────────────────────────────────────────── */
.badge  { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 100px; font-size: 10px; font-weight: 500; }
.b-open { background: var(--success-bg); color: var(--success); }
.b-close { background: var(--bg3); color: var(--text3); }
.b-pend  { background: var(--warn-bg); color: var(--warn); }
.b-hi    { background: var(--danger-bg); color: var(--danger); }
.b-lo    { background: var(--info-bg); color: var(--info); }

/* ── Forms ───────────────────────────────────────────────── */
.fg  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fgr { display: flex; flex-direction: column; gap: 4px; }
.fgr.fw { grid-column: 1 / -1; }
.fl  { font-size: 11px; font-weight: 500; color: var(--text2); }
.fc  { padding: 8px 10px; border: .5px solid var(--border2); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 12px; font-family: inherit; width: 100%; transition: border-color .12s; }
.fc:focus   { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-50); }
.fc[readonly] { background: var(--bg2); cursor: not-allowed; }
.stl { font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; padding-bottom: 8px; border-bottom: .5px solid var(--border); margin-bottom: 14px; }
.field-error { font-size: 11px; color: var(--danger); margin-top: 2px; }

/* ── Themes ──────────────────────────────────────────────── */
[data-theme="slate"]    { --brand: #475569; --brand-50: #F1F5F9; --brand-100: #E2E8F0; --brand-800: #1E293B; --brand-text: #fff; }
[data-theme="forest"]   { --brand: #166534; --brand-50: #F0FDF4; --brand-100: #DCFCE7; --brand-800: #14532D; --brand-text: #fff; }
[data-theme="crimson"]  { --brand: #991B1B; --brand-50: #FEF2F2; --brand-100: #FEE2E2; --brand-800: #7F1D1D; --brand-text: #fff; }
[data-theme="midnight"] { --brand: #1D4ED8; --brand-50: #EFF6FF; --brand-100: #DBEAFE; --brand-800: #1E3A5F; --brand-text: #fff; }

/* ── Dark mode ───────────────────────────────────────────── */
[data-mode="dark"] {
    --bg:          #0f1419;
    --bg2:         #181d24;
    --bg3:         #232a32;
    --surface:     #181d24;
    --border:      #2a3138;
    --border2:     #3a424b;

    --text:        #e6e8eb;
    --text1:       #e6e8eb;
    --text2:       #b1b6bb;
    --text3:       #80868d;

    --success-bg:  #0f2a1a;  --success:  #4ade80;
    --warn-bg:     #2a1f08;  --warn:     #fbbf24;
    --danger-bg:   #2a0e0e;  --danger:   #f87171;
    --info-bg:     #0e1a36;  --info:     #60a5fa;
}

/* In dark mode the brand-50 highlight needs to be a dim tinted background, not a pale one.
   Override per theme so the brand accent still feels distinct. */
[data-mode="dark"][data-theme="gold"],
[data-mode="dark"]:not([data-theme]) {
    --brand-50: #2a210d; --brand-100: #3a2e15;
}
[data-mode="dark"][data-theme="slate"]    { --brand-50: #1d242c; --brand-100: #29333d; }
[data-mode="dark"][data-theme="forest"]   { --brand-50: #0e2419; --brand-100: #143524; }
[data-mode="dark"][data-theme="crimson"]  { --brand-50: #2a1212; --brand-100: #3d1c1c; }
[data-mode="dark"][data-theme="midnight"] { --brand-50: #131e36; --brand-100: #1a2a4a; }

/* Form inputs stay readable on dark surfaces */
[data-mode="dark"] .fc                  { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-mode="dark"] .fc[readonly],
[data-mode="dark"] .fc[disabled]        { background: var(--bg2); color: var(--text3); }
[data-mode="dark"] .card                { background: var(--surface); border-color: var(--border); }
[data-mode="dark"] .tbl thead th        { background: var(--bg2); color: var(--text2); border-color: var(--border); }
[data-mode="dark"] .tbl td              { border-color: var(--border); }
[data-mode="dark"] .btn                 { background: var(--surface); color: var(--text); border-color: var(--border2); }
[data-mode="dark"] .btn:hover           { background: var(--bg2); }
[data-mode="dark"] .badge               { background: var(--bg3); color: var(--text2); }
[data-mode="dark"] .b-open              { background: var(--success-bg); color: var(--success); }
[data-mode="dark"] .b-pend              { background: var(--warn-bg);    color: var(--warn);    }
[data-mode="dark"] .b-close             { background: var(--danger-bg);  color: var(--danger);  }
[data-mode="dark"] .flash-ok            { background: var(--success-bg); color: var(--success); border-color: rgba(74,222,128,.25); }
[data-mode="dark"] .flash-err           { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(248,113,113,.25); }
[data-mode="dark"] .empty-cell          { color: var(--text3); }
[data-mode="dark"] select.fc            { background-color: var(--surface); }
[data-mode="dark"] input[type="date"].fc { color-scheme: dark; }

/* ── Auth pages ──────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-card { background: var(--surface); border: .5px solid var(--border); border-radius: var(--radius-lg); padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 4px 24px rgba(0,0,0,.07); }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth-sub   { font-size: 12px; color: var(--text3); }
.auth-form  { display: flex; flex-direction: column; gap: 14px; }
.auth-foot  { text-align: center; font-size: 12px; color: var(--text3); margin-top: 16px; }

/* ── Password show/hide wrapper ─────────────────────────── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 36px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
             background: none; border: none; cursor: pointer; padding: 2px;
             color: var(--text3); display: flex; align-items: center; line-height: 1; }
.pw-toggle:hover { color: var(--text2); }
