:root {
  --bg:#f7f4ec; --ink:#282828; --muted:#7a7266; --gold:#baa17f; --line:#e7e1d6;
  --surface:#ffffff; --danger:#c0392b; --good:#3fae6a;
}
* { box-sizing:border-box; }
body { margin:0; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
       background:var(--bg); color:var(--ink); }
a { color:inherit; }

/* Top bar */
.topbar { position:sticky; top:0; z-index:30; background:var(--ink); color:var(--bg); padding:10px 18px 0; }
.tb-row { display:flex; align-items:center; justify-content:space-between; gap:12px; max-width:1020px; margin:0 auto; }
.tb-brand { display:flex; align-items:center; gap:10px; text-decoration:none; font-weight:700; font-size:17px; color:inherit; }
.tb-brand img { height:34px; max-width:140px; width:auto; object-fit:contain; display:block; }
.tb-out { color:inherit; opacity:.7; font-size:14px; text-decoration:none; white-space:nowrap; }
.tb-out:hover { opacity:1; }
.tb-actions { display:flex; align-items:center; gap:14px; }
.tb-burger { display:none; background:transparent; border:0; color:var(--bg); font-size:22px; line-height:1;
             cursor:pointer; padding:4px 6px; border-radius:8px; }
.tb-burger:hover { background:rgba(255,255,255,.1); }
.tb-nav { display:flex; gap:4px; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none;
          max-width:1020px; margin:8px auto 0; padding-bottom:10px; }
.tb-nav::-webkit-scrollbar { display:none; }
.tb-nav a { white-space:nowrap; padding:8px 14px; border-radius:999px; text-decoration:none; font-size:14px;
            font-weight:600; color:inherit; opacity:.75; display:flex; align-items:center; gap:6px; }
.tb-nav a:hover { opacity:1; background:rgba(255,255,255,.08); }
.tb-nav a.on { background:var(--gold); color:var(--ink); opacity:1; font-weight:700; }
.tb-nav a .badge { background:var(--gold); color:var(--ink); font-size:11px; font-weight:800; border-radius:999px; padding:1px 7px; }
.tb-nav a.on .badge { background:var(--ink); color:var(--gold); }

/* Content */
.content { max-width:1000px; margin:0 auto; padding:28px 24px 60px; }

h1 { font-size:26px; margin:0 0 4px; }
h2 { font-size:18px; margin:28px 0 12px; }
.sub { color:var(--muted); margin:0 0 24px; }
.flash { background:#eef8f1; border:1px solid #cfead8; color:#256b43; padding:12px 16px;
         border-radius:12px; margin-bottom:20px; }

/* Cards / tables */
.card { background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:20px; margin-bottom:18px; }
.grid-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:14px; margin-bottom:8px; }
.stat { background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:18px; }
.stat .n { font-size:30px; font-weight:800; }
.stat .l { color:var(--muted); font-size:13px; margin-top:2px; }

table { width:100%; border-collapse:collapse; background:var(--surface); border:1px solid var(--line);
        border-radius:16px; overflow:hidden; }
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; margin-bottom:18px; }
.table-wrap > table { margin-bottom:0; }
th,td { text-align:left; padding:13px 16px; border-bottom:1px solid var(--line); font-size:15px; }
th { background:#faf8f3; color:var(--muted); font-weight:600; font-size:13px; text-transform:uppercase; letter-spacing:.4px; }
tr:last-child td { border-bottom:0; }
td.right,th.right { text-align:right; }
.cat-head td { background:#f3efe6; font-weight:700; }
.muted { color:var(--muted); }
.pill { display:inline-block; padding:3px 10px; border-radius:999px; font-size:12px; font-weight:600; }
.pill.on { background:#e6f4ec; color:#256b43; }
.pill.off { background:#f0eee9; color:#8a8175; }

/* Buttons + forms */
.btn { display:inline-block; border:0; cursor:pointer; font-size:14px; font-weight:600;
       padding:10px 16px; border-radius:10px; background:var(--ink); color:var(--bg); text-decoration:none; }
.btn.gold { background:var(--gold); color:var(--ink); }
.btn.ghost { background:transparent; border:1px solid var(--line); color:var(--ink); }
.btn.danger { background:transparent; border:1px solid #e6c4bf; color:var(--danger); }
.btn.sm { padding:6px 12px; font-size:13px; }
.actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.toolbar { display:flex; justify-content:space-between; align-items:center; margin-bottom:18px; }

label { display:block; font-weight:600; font-size:14px; margin:14px 0 6px; }
input[type=text],input[type=email],input[type=number],input[type=password],input[type=time],textarea,select {
  width:100%; padding:11px 13px; border:1px solid var(--line); border-radius:10px; font-size:15px;
  background:#fff; color:var(--ink); font-family:inherit; }
textarea { min-height:80px; resize:vertical; }
.row { display:flex; gap:16px; flex-wrap:wrap; }
.row > .col { flex:1; min-width:160px; }
.help { color:var(--muted); font-size:13px; margin-top:6px; }
.inline { display:inline; }

/* Login */
.login-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
.login-card { background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:34px;
              width:100%; max-width:380px; }
.login-card h1 { font-size:22px; }
.err { background:#fbeceb; border:1px solid #f0cfca; color:var(--danger); padding:10px 14px; border-radius:10px; margin:12px 0; }
.login-card .btn { width:100%; text-align:center; margin-top:18px; padding:14px; }

/* ---------------------------------------------------------------------------
   Mobile. Placed LAST so these override the base component rules by source
   order (same specificity). Nav collapses to a tap menu; forms stack; wide
   tables scroll inside their .table-wrap; toolbars/actions stack.
--------------------------------------------------------------------------- */
@media (max-width:760px) {
  .topbar { padding:12px 16px; }
  .tb-burger { display:block; }
  .tb-chip { display:none !important; }            /* beats the chip's inline display */
  .tb-nav { display:none; flex-direction:column; gap:2px; overflow:visible;
            max-height:72vh; overflow-y:auto; margin:8px auto 4px; padding-bottom:8px; }
  .topbar.open .tb-nav { display:flex; }
  .tb-nav a { padding:14px 14px; border-radius:12px; font-size:16px; opacity:.92; }
  .table-wrap > table { min-width:700px; }         /* forces the scroll on wide tables */
  th, td { white-space:nowrap; }
}
@media (max-width:640px) {
  .content { padding:20px 14px 40px; }
  .tb-brand span { font-size:15px; }
  .tb-brand img { height:30px; }
  h1 { font-size:22px; }
  .row { gap:12px; }
  .row > .col { min-width:100%; }                  /* stack form fields full-width */
  .card { padding:16px; }
  .toolbar { flex-direction:column; align-items:flex-start; gap:10px; }
}
