:root{
  --ink:#0E0E0E; --ink2:#1C1C1C; --gold:#D2A857; --gold-l:#F6E39B; --gold-d:#9C7529;
  --paper:#F7F4EC; --card:#FFFFFF; --line:#E5DFD0; --muted:#6B675E; --text:#1C1C1C;
  --red:#B3261E; --red-bg:#FBEBEB; --yellow:#8A6A00; --yellow-bg:#FFF4D6; --green:#2E7D32; --green-bg:#E5F4E4;
  --radius:10px; --nav-h:64px; --top-h:56px;
  --safe-b:env(safe-area-inset-bottom,0px); --safe-t:env(safe-area-inset-top,0px);
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;background:var(--paper);color:var(--text);font-size:16px;line-height:1.45;-webkit-font-smoothing:antialiased}
h1,h2,h3{font-family:Georgia,"Times New Roman",serif;margin:0 0 .5em;line-height:1.2}
h1{font-size:1.6rem} h2{font-size:1.25rem} h3{font-size:1.05rem}
a{color:var(--gold-d)}
button,input,select,textarea{font:inherit;color:inherit}
.muted{color:var(--muted)} .small{font-size:.875rem} .hidden{display:none!important}

/* boot + spinner */
.boot{min-height:100vh;display:grid;place-items:center;background:var(--ink)}
.spinner{width:34px;height:34px;border:3px solid rgba(210,168,87,.25);border-top-color:var(--gold);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* auth screens */
.auth{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px 16px calc(24px + var(--safe-b));background:var(--ink)}
.auth-logo{width:150px;height:150px;margin-bottom:18px}
.auth-card{width:100%;max-width:380px;background:var(--card);border-radius:var(--radius);padding:24px;box-shadow:0 10px 40px rgba(0,0,0,.4)}
.auth-card h1{font-size:1.35rem}
.auth-foot{color:#8d8a82;font-size:.8rem;margin-top:18px;text-align:center}
.code-input{font-size:2rem;letter-spacing:.5em;text-align:center;font-weight:700;padding:10px 0 10px .5em}

/* forms */
label{display:block;font-weight:600;font-size:.9rem;margin:0 0 6px}
.field{margin-bottom:14px}
.input,select.input,textarea.input{width:100%;padding:11px 12px;border:1px solid #cfc8b6;border-radius:8px;background:#fff;min-height:44px}
textarea.input{min-height:110px;resize:vertical}
.input:focus{outline:2px solid var(--gold);outline-offset:1px;border-color:var(--gold-d)}
.hint{font-size:.8rem;color:var(--muted);margin-top:4px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.row > .grow{flex:1 1 180px}
.check{display:flex;gap:10px;align-items:center;font-weight:500;margin:6px 0}
.check input{width:20px;height:20px;accent-color:var(--gold-d)}
.error{background:var(--red-bg);color:var(--red);padding:10px 12px;border-radius:8px;font-size:.9rem;margin-bottom:12px}
.ok{background:var(--green-bg);color:var(--green);padding:10px 12px;border-radius:8px;font-size:.9rem;margin-bottom:12px}

/* buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:10px 18px;border-radius:8px;border:1px solid transparent;font-weight:700;cursor:pointer;text-decoration:none;white-space:nowrap}
.btn-primary{background:var(--ink);color:var(--gold)} .btn-primary:hover{background:#262626}
.btn-gold{background:linear-gradient(160deg,var(--gold-l),var(--gold) 45%,var(--gold-d));color:var(--ink)}
.btn-ghost{background:transparent;border-color:#cfc8b6;color:var(--text)} .btn-ghost:hover{background:#efe9db}
.btn-danger{background:transparent;border-color:#e3b4b0;color:var(--red)}
.btn-block{width:100%}
.btn[disabled]{opacity:.55;cursor:default}
.link-btn{background:none;border:0;color:var(--gold-d);font-weight:600;cursor:pointer;padding:6px 0;text-decoration:underline}

/* shell */
.shell{min-height:100vh;display:flex}
.topbar{position:fixed;top:0;left:0;right:0;height:calc(var(--top-h) + var(--safe-t));padding-top:var(--safe-t);background:var(--ink);color:#fff;display:flex;align-items:center;gap:12px;padding-left:14px;padding-right:10px;z-index:20}
.brand{display:flex;align-items:center;gap:10px;color:var(--gold);font-family:Georgia,serif;font-weight:700;letter-spacing:.18em;font-size:.95rem;text-decoration:none}
.brand img{width:34px;height:34px;border-radius:6px}
.topbar .spacer{flex:1}
.user-btn{background:#222;border:1px solid #333;color:#eee;border-radius:999px;padding:6px 12px;font-size:.85rem;cursor:pointer;max-width:46vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.menu{position:fixed;top:calc(var(--top-h) + var(--safe-t) - 4px);right:10px;background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,.2);min-width:220px;z-index:30;padding:6px}
.menu button,.menu a{display:block;width:100%;text-align:left;background:none;border:0;padding:10px 12px;border-radius:8px;cursor:pointer;color:var(--text);text-decoration:none;font-size:.95rem}
.menu button:hover,.menu a:hover{background:#f3efe4}
.menu .who{padding:8px 12px;border-bottom:1px solid var(--line);margin-bottom:4px;font-size:.85rem}

.sidenav{display:none}
.main{flex:1;padding:calc(var(--top-h) + var(--safe-t) + 16px) 14px calc(var(--nav-h) + var(--safe-b) + 24px);max-width:1100px;margin:0 auto;width:100%}

.bottomnav{position:fixed;left:0;right:0;bottom:0;height:calc(var(--nav-h) + var(--safe-b));padding-bottom:var(--safe-b);background:var(--ink);display:flex;z-index:20;border-top:1px solid #222}
.bottomnav a,.bottomnav button{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;color:#b9b4a8;text-decoration:none;font-size:.72rem;background:none;border:0;cursor:pointer}
.bottomnav .active{color:var(--gold)}
.bottomnav svg{width:22px;height:22px}

.sheet-bg{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:40}
.sheet{position:fixed;left:0;right:0;bottom:0;background:#fff;border-radius:16px 16px 0 0;z-index:41;padding:14px 10px calc(14px + var(--safe-b));max-height:80vh;overflow:auto}
.sheet a{display:flex;align-items:center;gap:14px;padding:13px 14px;border-radius:10px;color:var(--text);text-decoration:none;font-weight:600}
.sheet a.active{background:#f3efe4;color:var(--gold-d)}
.sheet svg{width:22px;height:22px}

@media (min-width:900px){
  .bottomnav{display:none}
  .sidenav{display:block;position:fixed;top:var(--top-h);bottom:0;left:0;width:230px;background:#151515;padding:14px 10px;overflow:auto}
  .sidenav a{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:8px;color:#cfcabd;text-decoration:none;font-size:.95rem;margin-bottom:2px}
  .sidenav a:hover{background:#222}
  .sidenav a.active{background:#262116;color:var(--gold)}
  .sidenav svg{width:20px;height:20px}
  .sidenav .sec{color:#6f6b62;font-size:.72rem;letter-spacing:.12em;text-transform:uppercase;margin:16px 12px 6px}
  .main{padding:calc(var(--top-h) + 24px) 28px 40px 258px;max-width:none}
  .main > .page{max-width:1050px}
}

/* content */
.page-head{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:16px}
.page-head h1{margin:0}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:18px;margin-bottom:14px}
.card h2{margin-bottom:10px}
.grid{display:grid;gap:14px;grid-template-columns:1fr}
@media (min-width:700px){.grid-2{grid-template-columns:1fr 1fr}.grid-3{grid-template-columns:repeat(3,1fr)}}
.stat{display:flex;flex-direction:column;gap:4px}
.stat .num{font-size:1.9rem;font-weight:800;font-family:Georgia,serif}
.badge{display:inline-block;padding:2px 9px;border-radius:999px;font-size:.75rem;font-weight:700;background:#efe9db;color:#5c564a}
.badge.gold{background:#f6ecd2;color:#7a5b18} .badge.red{background:var(--red-bg);color:var(--red)} .badge.green{background:var(--green-bg);color:var(--green)}
.empty{text-align:center;padding:28px 14px;color:var(--muted)}
.empty svg{width:42px;height:42px;color:var(--gold-d);margin-bottom:8px}

.tabs{display:flex;gap:6px;overflow-x:auto;padding-bottom:4px;margin-bottom:14px;scrollbar-width:none}
.tabs::-webkit-scrollbar{display:none}
.tabs a{flex:0 0 auto;padding:8px 14px;border-radius:999px;background:#ece6d7;color:#4a463d;text-decoration:none;font-weight:600;font-size:.9rem}
.tabs a.active{background:var(--ink);color:var(--gold)}

.list{border:1px solid var(--line);border-radius:var(--radius);background:#fff;overflow:hidden}
.list-item{display:flex;gap:12px;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid #efeadf;flex-wrap:wrap}
.list-item:last-child{border-bottom:0}
.list-item .meta{min-width:0;flex:1 1 220px}
.list-item .meta strong{display:block;overflow:hidden;text-overflow:ellipsis}

table.tbl{width:100%;border-collapse:collapse;font-size:.92rem}
.tbl th,.tbl td{text-align:left;padding:9px 10px;border-bottom:1px solid #efeadf;vertical-align:top}
.tbl th{font-size:.78rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}
.tbl-wrap{overflow-x:auto}

#toasts{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--nav-h) + var(--safe-b) + 14px);z-index:60;display:flex;flex-direction:column;gap:8px;width:min(92vw,420px)}
.toast{background:var(--ink);color:#fff;padding:12px 14px;border-radius:10px;box-shadow:0 8px 24px rgba(0,0,0,.3);font-size:.92rem;border-left:4px solid var(--gold)}
.toast.err{border-left-color:#e57373}
@media (min-width:900px){#toasts{bottom:24px}}
