:root{
  --paper:#F7F1E6;
  --paper-2:#EFE6D4;
  --ink:#2A231C;
  --ink-soft:#6B6055;
  --brand:#D2601A;
  --brand-dark:#A84811;
  --teal:#2F6F68;
  --teal-bg:#E4EFEC;
  --red:#B7402E;
  --red-bg:#F6E3DF;
  --gold:#CE9A2E;
  --gold-bg:#F7EBCE;
  --line:#DBCEB5;
  --card:#FFFDF8;
  --radius:14px;
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--paper);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size:22px 22px;
  color:var(--ink);
  font-family:'Inter',sans-serif;
  min-height:100vh;
}
h1,h2,h3,.display{ font-family:'Fredoka',sans-serif; font-weight:600; letter-spacing:-0.01em; }
button{ font-family:'Inter',sans-serif; cursor:pointer; }
::selection{ background:var(--gold-bg); }

/* ---------- Install banner ---------- */
#install-banner{
  display:none; position:fixed; left:0; right:0; bottom:0; z-index:60;
  background:var(--ink); color:#fff; padding:12px 16px calc(12px + env(safe-area-inset-bottom)) 16px;
  align-items:center; justify-content:space-between; gap:12px;
}
#install-banner.show{ display:flex; }
#install-banner span{ font-size:13.5px; }
#install-banner .actions{ display:flex; gap:8px; flex-shrink:0; }

/* ---------- Login ---------- */
#login-screen{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
.login-card{
  background:var(--card); border:1.5px solid var(--line); border-radius:20px;
  padding:36px 30px; max-width:380px; width:100%; box-shadow:0 2px 0 var(--line); position:relative;
}
.login-card::before{
  content:""; position:absolute; top:-10px; left:30px; width:70px; height:14px;
  background:var(--gold); opacity:.35; border-radius:8px; transform:rotate(-3deg);
}
.brand-mark{ display:flex; align-items:center; gap:10px; margin-bottom:6px; }
.brand-mark img{ width:34px; height:34px; }
.brand-title{ font-size:24px; margin:0; }
.brand-sub{ color:var(--ink-soft); font-size:14px; margin:2px 0 26px 0; }
.field-label{ font-size:13px; color:var(--ink-soft); margin-bottom:6px; display:block; }
.role-pick{ display:flex; gap:10px; margin-bottom:18px; }
.role-btn{
  flex:1; padding:14px 8px; border-radius:12px; border:1.5px solid var(--line);
  background:var(--paper); font-size:14px; font-weight:600; color:var(--ink-soft); transition:.15s;
}
.role-btn.active{ border-color:var(--brand); color:var(--brand-dark); background:#FBEEE0; }

input[type=text], input[type=tel], input[type=number], input[type=date], input[type=password], select, textarea{
  width:100%; padding:11px 12px; border-radius:10px; border:1.5px solid var(--line);
  background:#fff; font-size:14px; font-family:'Inter',sans-serif; color:var(--ink); margin-bottom:16px;
}
input:focus, select:focus, textarea:focus{ outline:2px solid var(--brand); outline-offset:1px; border-color:var(--brand); }

.btn{ display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:12px 18px; border-radius:10px; border:none; font-weight:600; font-size:14px; }
.btn-primary{ background:var(--brand); color:#fff; }
.btn-primary:hover{ background:var(--brand-dark); }
.btn-block{ width:100%; }
.btn-ghost{ background:transparent; border:1.5px solid var(--line); color:var(--ink); }
.btn-ghost.on-dark{ border-color:#665c4d; color:#fff; }
.btn-teal{ background:var(--teal); color:#fff; }
.btn-red{ background:var(--red); color:#fff; }
.btn-sm{ padding:8px 12px; font-size:13px; border-radius:8px; }
.hint{ font-size:12px; color:var(--ink-soft); margin-top:-8px; margin-bottom:16px; }

/* ---------- App shell ---------- */
#app-shell{ display:none; min-height:100vh; }
.sidebar{
  width:220px; background:var(--card); border-right:1.5px solid var(--line);
  padding:22px 16px; position:fixed; top:0; bottom:0; left:0; display:flex; flex-direction:column;
}
.sidebar .brand-mark{ padding:0 4px 20px 4px; }
.nav-item{
  display:flex; align-items:center; gap:11px; padding:11px 12px; border-radius:10px;
  color:var(--ink-soft); font-weight:600; font-size:14px; margin-bottom:4px; background:none; border:none; width:100%; text-align:left;
}
.nav-item svg{ width:18px; height:18px; flex-shrink:0; }
.nav-item.active{ background:#FBEEE0; color:var(--brand-dark); }
.nav-item:hover:not(.active){ background:var(--paper-2); }
.sidebar-footer{ margin-top:auto; padding-top:14px; border-top:1.5px solid var(--line); }
.role-badge{ font-size:12px; color:var(--ink-soft); margin-bottom:10px; }
.role-badge b{ color:var(--ink); }

.main{ margin-left:220px; padding:28px 34px 80px 34px; max-width:1180px; }
.topbar{ display:flex; justify-content:space-between; align-items:flex-end; margin-bottom:24px; flex-wrap:wrap; gap:10px; }
.page-title{ font-size:26px; margin:0 0 4px 0; }
.page-sub{ color:var(--ink-soft); font-size:14px; margin:0; }

.grid{ display:grid; gap:16px; }
.grid-4{ grid-template-columns:repeat(4,1fr); }
.grid-2{ grid-template-columns:2fr 1fr; }
@media(max-width:1000px){ .grid-4{ grid-template-columns:repeat(2,1fr); } .grid-2{ grid-template-columns:1fr; } }

.card{ background:var(--card); border:1.5px solid var(--line); border-radius:var(--radius); padding:20px; }
.stat-card .stat-label{ font-size:13px; color:var(--ink-soft); font-weight:600; margin-bottom:8px; }
.stat-card .stat-value{ font-family:'Fredoka',sans-serif; font-size:28px; font-weight:600; }
.stat-card .stat-delta{ font-size:12.5px; margin-top:6px; font-weight:600; }
.up{ color:var(--teal); } .down{ color:var(--red); }

table{ width:100%; border-collapse:collapse; font-size:14px; }
th{ text-align:left; color:var(--ink-soft); font-weight:600; font-size:12.5px; padding:8px 10px; border-bottom:1.5px solid var(--line); }
td{ padding:10px 10px; border-bottom:1px solid var(--line); vertical-align:middle; }
tr:last-child td{ border-bottom:none; }
.tag{ display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:20px; font-size:12px; font-weight:600; }
.tag-paid{ background:var(--teal-bg); color:var(--teal); }
.tag-unpaid{ background:var(--red-bg); color:var(--red); }
.tag-gold{ background:var(--gold-bg); color:var(--gold); }
.row-actions{ display:flex; gap:6px; flex-wrap:wrap; }
.empty-state{ text-align:center; padding:50px 20px; color:var(--ink-soft); }
.empty-state svg{ width:52px; height:52px; margin-bottom:12px; opacity:.5; }

.section-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; flex-wrap:wrap; gap:10px; }
.section-head h2{ font-size:18px; margin:0; }

.pkg-card{ border:1.5px solid var(--line); border-radius:12px; padding:16px; background:var(--paper); position:relative; }
.pkg-card.inactive{ opacity:.5; }
.pkg-name{ font-family:'Fredoka',sans-serif; font-weight:600; font-size:16px; margin-bottom:2px; }
.pkg-meta{ color:var(--ink-soft); font-size:13px; margin-bottom:10px; }
.pkg-price{ font-size:20px; font-weight:700; color:var(--brand-dark); font-family:'Fredoka',sans-serif; }

.overlay{ position:fixed; inset:0; background:rgba(42,35,28,.45); display:none; align-items:center; justify-content:center; z-index:50; padding:20px; }
.overlay.show{ display:flex; }
.modal{ background:var(--card); border-radius:16px; width:100%; max-width:440px; max-height:88vh; overflow-y:auto; padding:24px; border:1.5px solid var(--line); }
.modal h3{ margin:0 0 16px 0; font-size:19px; }
.modal-close{ float:right; background:none; border:none; font-size:20px; color:var(--ink-soft); }

.bottom-nav{ display:none; }
@media(max-width:820px){
  .sidebar{ display:none; }
  .main{ margin-left:0; padding:18px 16px calc(96px + env(safe-area-inset-bottom)) 16px; }
  .bottom-nav{
    display:flex; position:fixed; bottom:0; left:0; right:0; background:var(--card);
    border-top:1.5px solid var(--line); z-index:40; justify-content:space-around;
    padding:8px 4px calc(8px + env(safe-area-inset-bottom)) 4px;
  }
  .bottom-nav button{
    flex:1 1 0; min-width:0; background:none; border:none; display:flex; flex-direction:column;
    align-items:center; gap:3px; color:var(--ink-soft); font-size:11px; font-weight:600; padding:4px 4px;
  }
  .bottom-nav button svg{ width:20px; height:20px; flex-shrink:0; }
  .bottom-nav button span{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
  .bottom-nav button.active{ color:var(--brand-dark); }
  .grid-4{ grid-template-columns:repeat(2,1fr); }
  table{ font-size:12.5px; }
  th,td{ padding:8px 6px; }
  .login-card{ padding:28px 20px; }
}

@media(max-width:820px){
  #install-banner.show{ bottom: calc(64px + env(safe-area-inset-bottom)); }
}

.table-scroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; margin:0 -4px; padding:0 4px; }
@media(max-width:820px){
  .table-scroll table{ min-width:560px; }
}
.divider-note{ background:var(--gold-bg); color:#7a5c17; border-radius:10px; padding:10px 14px; font-size:12.5px; margin-bottom:18px; }
.attend-dot{ display:inline-flex; padding:5px 10px; background:var(--teal-bg); color:var(--teal); border-radius:8px; font-size:12.5px; margin:3px 4px 3px 0; }
.loading{ text-align:center; padding:60px; color:var(--ink-soft); }

.strength-bar{ height:6px; border-radius:6px; background:var(--paper-2); overflow:hidden; margin:-10px 0 14px 0; }
.strength-bar-fill{ height:100%; border-radius:6px; transition:width .15s ease; }
.strength-label{ font-size:12px; margin:-12px 0 16px 0; }
.tag-inactive{ background:var(--paper-2); color:var(--ink-soft); }
.tag-locked{ background:var(--red-bg); color:var(--red); }
.setup-card{ max-width:520px; }
.setup-section-title{ font-size:14px; font-weight:600; color:var(--brand-dark); margin:20px 0 10px 0; }
.setup-section-title:first-of-type{ margin-top:0; }
