/* =========================================================
   Satyam Campus — calm, minimal interface
   Change the colours in :root to re-theme the whole app.
   ========================================================= */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --line: #e8e8e3;
  --line-strong: #d9d9d3;

  --accent: #0f766e;          /* teal — main action colour */
  --accent-soft: #e6f2f0;
  --accent-ink: #0b5a54;

  --free: #f1f1ee;            /* empty room */
  --partial: #fdf3e1;         /* partly filled */
  --partial-ink: #9a6412;
  --full: #e3f1ee;            /* full */
  --full-ink: #0b5a54;
  --maint: #fbe9e9;           /* maintenance */
  --maint-ink: #a23b3b;
  --info: #eaf0fb;
  --info-ink: #2f55a4;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 16px rgba(20, 20, 20, .04);
  --shadow-lg: 0 12px 40px rgba(20, 20, 20, .14);
  --sidebar: 232px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  padding: 22px 14px; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand-name { font-weight: 600; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--muted); cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.sidebar .me { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; padding: 28px 36px 60px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

.tabbar { display: none; }

/* ---------- Cards & stats ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat .label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bar { height: 8px; background: var(--free); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px;
              transition: width .5s ease; }

.hostel-card h3 { font-size: 16px; }
.hostel-card .big { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.floor-line { display: grid; grid-template-columns: 90px 1fr 60px; gap: 10px; align-items: center;
              font-size: 13px; color: var(--muted); margin-top: 8px; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px;
             border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); cursor: pointer; font-weight: 500; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--maint-ink); border-color: #efcfcf; }
.btn.danger:hover { background: var(--maint); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--free); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); outline: none; width: 100%;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 11px; color: var(--faint); }
.search .input { padding-left: 38px; }

.segmented { display: inline-flex; background: var(--free); border-radius: 11px; padding: 3px; gap: 2px;
             flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer;
                    font-size: 13px; color: var(--muted); font-weight: 500; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); padding: 5px 12px;
        border-radius: 99px; font-size: 13px; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px;
        font-size: 12px; font-weight: 500; background: var(--free); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--full); color: var(--full-ink); }
.pill.warn { background: var(--partial); color: var(--partial-ink); }
.pill.bad { background: var(--maint); color: var(--maint-ink); }
.pill.info { background: var(--info); color: var(--info-ink); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- Room grid ---------- */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; border: 1px solid var(--line); }
.floor-block { margin-top: 22px; }
.floor-block h3 { font-size: 13px; color: var(--muted); font-weight: 500; text-transform: uppercase;
                  letter-spacing: .06em; margin-bottom: 10px; }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.room {
  border-radius: 12px; padding: 12px; cursor: pointer; border: 1px solid transparent;
  background: var(--free); transition: transform .12s ease, box-shadow .12s ease; position: relative;
  min-height: 84px; display: flex; flex-direction: column; justify-content: space-between;
}
.room:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.room .no { font-weight: 600; font-size: 16px; }
.room .beds { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.room .beds i { width: 10px; height: 10px; border-radius: 3px; background: #fff; border: 1px solid var(--line-strong); }
.room .beds i.on { background: currentColor; border-color: currentColor; }
.room .meta { font-size: 12px; margin-top: 6px; opacity: .85; }
.room.partial { background: var(--partial); color: var(--partial-ink); }
.room.full { background: var(--full); color: var(--full-ink); }
.room.maint, .room.closed { background: var(--maint); color: var(--maint-ink); }
.room.empty { color: var(--muted); }
.room .flag { position: absolute; top: 10px; right: 10px; }
.room .flag svg { width: 15px; height: 15px; }

/* ---------- Avatars ---------- */
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
          display: grid; place-items: center; font-weight: 600; font-size: 13px; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 20px; }
.avatar.empty { background: var(--free); color: var(--faint); border: 1px dashed var(--line-strong); }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 10px 12px;
            border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* ---------- Drawer / sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 20, 20, .28); z-index: 40;
         animation: fade .18s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); background: var(--surface);
  z-index: 41; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slide .22s ease;
}
.drawer-head { padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 18px 22px 40px; overflow-y: auto; flex: 1; }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 51;
  width: min(520px, calc(100% - 32px)); max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px;
  animation: pop .18s ease;
}
.modal-scrim { z-index: 50; }
.modal h2 { margin-bottom: 4px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin: 0 -22px; padding: 0 22px; }
.tabs button { border: 0; background: none; padding: 12px 0; cursor: pointer; color: var(--muted);
               font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-color: var(--text); }

.bed { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line);
       border-radius: 12px; margin-bottom: 10px; }
.bed .no { width: 28px; font-size: 12px; color: var(--faint); font-weight: 600; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state svg { width: 36px; height: 36px; color: var(--faint); margin-bottom: 8px; }

/* ---------- Toast & banners ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
              display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
         box-shadow: var(--shadow-lg); animation: pop .18s ease; max-width: 90vw; }
.toast.err { background: var(--maint-ink); }
.banner { background: var(--info); color: var(--info-ink); padding: 8px 14px; border-radius: 10px;
          font-size: 13px; margin-bottom: 18px; display: flex; gap: 8px; align-items: center; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); padding: 32px; }
.login .brand { padding: 0 0 24px; }
.demo-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--accent-ink); }
.live .dot { animation: pulse 1.6s infinite; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } }
.toast { animation-name: fade; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Phone layout ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 18px 16px 96px; }
  .grid.stats { grid-template-columns: 1fr 1fr; }
  .grid.two { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .stat .value { font-size: 24px; }
  .rooms { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column;
                   align-items: center; gap: 3px; font-size: 11px; color: var(--muted); padding: 6px 0; cursor: pointer; }
  .tabbar button.active { color: var(--accent-ink); }
  .drawer { top: auto; height: 92vh; width: 100%; border-radius: 20px 20px 0 0; animation: rise .24s ease; }
  .hide-sm { display: none; }
  .toast-wrap { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .search { width: 100% !important; }
  .kv { grid-template-columns: 110px 1fr; }
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }

/* ---------- Floor header (Hostels page) ---------- */
.floor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.floor-head h3 { margin: 0; }
.brand-mark.logo { background: var(--surface); border: 1px solid var(--line); overflow: hidden; padding: 3px; }
.brand-mark.logo img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Sign-in screen ---------- */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 44%) 1fr; background: var(--bg); }
.login-art {
  position: relative; overflow: hidden; color: #eaf4f2; padding: 40px 44px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background: #0d4f49;
  background-image: radial-gradient(120% 80% at 0% 0%, rgba(255,255,255,.08), transparent 60%);
}
.login-art-top { display: flex; align-items: center; gap: 12px; }
.brand-mark.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 20px; background: #f6f6f3; color: #0d4f49; }
.la-name { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.la-sub { font-size: 13px; opacity: .7; }
.login-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; max-width: 420px; }
.lt { display: block; aspect-ratio: 1; border-radius: 9px; transition: background-color .9s ease, transform .9s ease; }
.lt.full { background: rgba(220, 240, 235, .92); }
.lt.partial { background: rgba(244, 214, 160, .85); }
.lt.free { background: rgba(255, 255, 255, .10); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.lt.maint { background: rgba(240, 170, 165, .80); }
.login-art-copy h2 { font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; color: #fff; text-wrap: balance; }
.login-art-copy p { margin: 10px 0 18px; opacity: .8; font-size: 15px; max-width: 34ch; }
.la-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; opacity: .85; }
.la-legend span { display: inline-flex; align-items: center; gap: 6px; }
.la-legend .lt { width: 11px; height: 11px; border-radius: 3px; aspect-ratio: auto; }

.login-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; }
.login-form { width: min(400px, 100%); }
.login-form h1 { font-size: 28px; letter-spacing: -0.02em; }
.login-form .input { height: 46px; border-radius: 12px; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 14px; top: 14px; color: var(--faint); pointer-events: none; }
.input-icon .input { padding-left: 42px; padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border: 0; background: none;
             border-radius: 9px; color: var(--faint); cursor: pointer; display: grid; place-items: center; }
.pw-toggle:hover, .pw-toggle.on { color: var(--accent); background: var(--accent-soft); }
.login-error { color: var(--maint-ink); font-size: 13px; min-height: 18px; margin-top: -6px; }
.login-error:empty { display: none; }
.login-foot { margin-top: 36px; text-align: center; }
.demo-roles .btn { justify-content: flex-start; height: 44px; }
.btn:focus-visible, .chip:focus-visible, .pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-art { padding: 22px 20px 24px; gap: 18px; }
  .login-tiles { grid-template-columns: repeat(12, 1fr); gap: 6px; max-width: none; }
  .login-tiles .lt:nth-child(n+25) { display: none; }
  .lt { border-radius: 5px; }
  .login-art-copy h2 { font-size: 22px; }
  .login-art-copy p { margin: 6px 0 12px; font-size: 14px; }
  .login-panel { justify-content: flex-start; padding: 28px 16px 40px; }
  .login-form h1 { font-size: 24px; }
  .login-foot { margin-top: 28px; }
}
@media (prefers-reduced-motion: reduce) { .lt { transition: none; } }

/* ---------- Stage 2: fees, blocks, access ---------- */
.num, .stat .value, .big-num { font-variant-numeric: tabular-nums; }
.big-num { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.month-switch { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.month-label { font-weight: 600; font-size: 17px; min-width: 110px; text-align: center; }
.access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.access { border-radius: 12px; padding: 12px 14px; border: 1px solid transparent; }
.access .a-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.access .a-val { font-weight: 600; font-size: 17px; margin: 2px 0 2px; }
.access.ok { background: var(--full); color: var(--full-ink); }
.access.warn { background: var(--partial); color: var(--partial-ink); }
.access.bad { background: var(--maint); color: var(--maint-ink); }
.block-row { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.block-row:last-child { border-bottom: 0; }
.drawer .block-row { padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.code-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
            font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.bad-banner { background: var(--maint); color: var(--maint-ink); }
.fee-auto { border-color: #f1d0d0; }
@media (max-width: 860px) {
  .block-row { flex-wrap: wrap; }
  .block-row > .row:first-child { flex: 1 1 100% !important; }
  .access-grid { grid-template-columns: 1fr 1fr; }
  .big-num { font-size: 28px; }
}
.plan-line { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 10px;
             background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }

/* ---------- Stage 3: student app ---------- */
.login-tabs { display: flex; width: 100%; }
.login-tabs button { flex: 1; padding: 9px 12px; font-size: 14px; }
.sa { max-width: 520px; margin: 0 auto; min-height: 100vh; padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }
.sa-top { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; }
.sa-name { font-weight: 600; font-size: 16px; }
.sa-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); text-align: center; }
.sa-card h2 { margin: 6px 0 4px; font-size: 20px; }
.sa-card p { margin: 6px 0 0; color: var(--muted); }
.sa-card.ok { background: var(--full); border-color: transparent; color: var(--full-ink); }
.sa-card.ok p { color: var(--full-ink); opacity: .85; }
.sa-card.bad { background: var(--maint); border-color: transparent; color: var(--maint-ink); }
.sa-card.bad p { color: var(--maint-ink); opacity: .9; }
.sa-card-icon svg { width: 34px; height: 34px; }
.qr-card { text-align: left; }
.sa-meal { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.qr-box { margin: 16px auto 0; width: min(300px, 78vw); aspect-ratio: 1; background: #fff; border-radius: 16px; padding: 8px; border: 1px solid var(--line); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-bar { height: 4px; background: var(--free); border-radius: 99px; overflow: hidden; margin: 12px auto 0; width: min(300px, 78vw); }
.qr-bar span { display: block; height: 100%; background: var(--accent); transition: width .5s linear; }
.sa-warn { display: flex; gap: 8px; align-items: center; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--partial); color: var(--partial-ink); font-size: 13px; }
.sa-tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 6px; z-index: 30;
           background: rgba(255,255,255,.95); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); }
.sa-tabs button { flex: 1; max-width: 160px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
                  font-size: 12px; color: var(--muted); padding: 6px 0; cursor: pointer; border-radius: 12px; }
.sa-tabs button.active { color: var(--accent-ink); background: var(--accent-soft); }

/* ---------- Stage 3: mess counter ---------- */
.sc { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.sc-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sc-top > .row:first-child { flex: 1 1 200px; }
.sc-stat { text-align: right; }
.sc-stat b { font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.sc-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, 1fr); gap: 16px; padding: 16px; }
.sc-cam, .sc-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.sc-video { position: relative; background: #101413; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; max-height: 62vh; width: 100%; }
.sc-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.sc-frame { position: absolute; inset: 18% 22%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.sc-hint { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: #e7eeec; text-align: center; padding: 20px; font-size: 14px; }
.sc-hint svg { width: 36px; height: 36px; }
.sc-result { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; cursor: pointer; animation: fade .15s ease; }
.sc-result.ok { background: #0e7a5a; color: #fff; }
.sc-result.bad { background: #b3261e; color: #fff; }
.sc-r-inner { text-align: center; max-width: 560px; }
.sc-r-title { font-size: clamp(34px, 7vw, 64px); font-weight: 800; letter-spacing: -0.03em; display: flex; align-items: center; justify-content: center; gap: 12px; }
.sc-r-title svg { width: 1em; height: 1em; stroke-width: 2.6; }
.sc-r-photo { width: clamp(120px, 26vw, 220px); aspect-ratio: 1; margin: 18px auto 10px; border-radius: 24px; overflow: hidden; background: rgba(255,255,255,.18);
              display: grid; place-items: center; font-size: 56px; font-weight: 700; }
.sc-r-photo img { width: 100%; height: 100%; object-fit: cover; }
.sc-r-name { font-size: clamp(22px, 4.5vw, 36px); font-weight: 700; }
.sc-r-meta { font-size: 16px; opacity: .9; margin-top: 4px; }
.sc-r-slip { display: inline-block; margin-top: 14px; padding: 6px 14px; border-radius: 99px; background: rgba(255,255,255,.2); font-weight: 600; }
.sc-r-msg { margin-top: 12px; font-size: 18px; font-weight: 500; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; accent-color: var(--accent); }
.code-chip { font-family: ui-monospace, Menlo, monospace; letter-spacing: .08em; background: var(--accent-soft); color: var(--accent-ink); padding: 2px 8px; border-radius: 6px; }
.grid.meals3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) {
  .sc-body { grid-template-columns: 1fr; padding: 12px; }
  .sc-top { gap: 10px; }
  .sc-stat { text-align: left; }
  .grid.meals3 { grid-template-columns: 1fr; }
}

/* ---------- Slip printing through the print dialog ---------- */
#print-slip { display: none; }
@media print {
  @page { size: 58mm auto; margin: 2mm; }
  body * { visibility: hidden !important; }
  #print-slip, #print-slip * { visibility: visible !important; }
  #print-slip { display: block; position: absolute; left: 0; top: 0; width: 54mm; font: 11px/1.35 ui-monospace, Menlo, monospace; color: #000; }
  #print-slip hr { border: 0; border-top: 1px dashed #000; margin: 4px 0; }
  #print-slip .ps-c { text-align: center; }
  #print-slip .ps-big { font-size: 18px; font-weight: 700; }
  #print-slip .ps-tear { break-after: page; page-break-after: always; height: 0; }
}

/* ---------- Charts, bill, meal tracker ---------- */
.chart-wrap { overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis, .spark .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .axis.strong { fill: var(--text); font-weight: 600; }
.chart .hit { cursor: default; }
.chart .hit:hover { fill: rgba(20, 20, 20, .04); }
.chart-tip { position: fixed; z-index: 80; pointer-events: none; background: var(--text); color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 280px; }
.meal-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.bill-lines { margin-top: 14px; border-top: 1px solid var(--line); }
.bill-line { display: grid; grid-template-columns: 1.4fr 1.2fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.bill-line .num:last-child { text-align: right; }
.meal-tracker { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; margin-top: 12px; }
.mt-rows { display: flex; flex-direction: column; gap: 12px; }
.mt-row { display: grid; grid-template-columns: 110px 1fr 80px; gap: 12px; align-items: center; }
.mt-label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.mt-num { text-align: right; font-size: 14px; }
.mt-side { text-align: right; padding-left: 20px; border-left: 1px solid var(--line); }
@media (max-width: 860px) {
  .meal-tracker { grid-template-columns: 1fr; }
  .mt-side { text-align: left; padding-left: 0; border-left: 0; border-top: 1px solid var(--line); padding-top: 12px; }
  .mt-row { grid-template-columns: 90px 1fr 64px; }
  .bill-line { grid-template-columns: 1fr auto; }
  .bill-line > div:nth-child(2) { grid-column: 1 / -1; order: 3; color: var(--muted); font-size: 13px; }
}
.grid.split { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .grid.split { grid-template-columns: 1fr; } }
.grid > .card { min-width: 0; }
@media (max-width: 1000px) { .grid.split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Update 09: bell, notifications, notices, complaints, printer, meal edits ---------- */
.nav-item .badge, .bell .badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: #d93a2b; color: #fff;
  font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.nav-item .badge[hidden], .bell .badge[hidden] { display: none; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 10px; }
.bell { position: relative; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.bell:hover { background: var(--surface-2); }
.bell .i { width: 20px; height: 20px; }
.bell .badge { position: absolute; top: -6px; right: -6px; margin: 0; border: 2px solid var(--bg); }
.mtop { display: none; }
@media (max-width: 860px) {
  .mtop { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 25; padding: 10px 16px;
    background: rgba(246, 246, 243, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .mtop .brand-mark { width: 32px; height: 32px; font-size: 15px; }
  .mtop-title { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mtop .bell { width: 38px; height: 38px; }
  .main { padding-top: 14px; }
}
.list-item.note { align-items: flex-start; cursor: pointer; border-radius: 10px; padding: 12px 8px; }
.list-item.note:hover { background: var(--surface-2); }
.list-item.note.unread { background: #f3f8f7; }
.note-ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--free); color: var(--muted); }
.note-ic .i { width: 17px; height: 17px; }
.note-ic.k-ticket { background: var(--partial); color: var(--partial-ink); }
.note-ic.k-leave { background: var(--info); color: var(--info-ink); }
.note-ic.k-block { background: var(--maint); color: var(--maint-ink); }
.note-ic.k-fee { background: var(--full); color: var(--full-ink); }
.note-ic.k-notice { background: var(--accent-soft); color: var(--accent-ink); }
.note-t { font-weight: 500; font-size: 14px; line-height: 1.35; }
.list-item.note.unread .note-t { font-weight: 600; }
.note-b { margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.alert-cta { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: var(--accent-soft); margin-bottom: 12px; }
.alert-cta > .i { color: var(--accent-ink); flex-shrink: 0; }
.notices { gap: 12px; }
.notice.pinned { border-color: #b9dcd7; box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.notice-body { margin-top: 8px; white-space: pre-line; font-size: 14px; line-height: 1.55; }
.pill.tag { font-size: 11px; padding: 1px 7px; vertical-align: 1px; margin-left: 4px; }
.sa-top .bell { margin-left: auto; }
.sa-tabs button { min-width: 0; font-size: 11px; }
.sa-tabs button .i { flex-shrink: 0; }
.cmp { padding: 14px 16px; }
.cmp-note { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--full); color: var(--full-ink); }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); margin: 14px 0 10px; }
.step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; color: var(--faint); }
.step i { width: 12px; height: 12px; border-radius: 50%; background: var(--line-strong); position: relative; z-index: 1; box-shadow: 0 0 0 3px var(--surface); }
.step::before { content: ""; position: absolute; top: 5px; left: -50%; width: 100%; height: 2px; background: var(--line-strong); }
.step:first-child::before { display: none; }
.step.done { color: var(--accent-ink); font-weight: 500; }
.step.done i, .step.done::before { background: var(--accent); }
.me-list { max-height: 52vh; overflow: auto; }
.meal-toggles { display: flex; gap: 6px; }
.mtog { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--faint);
  font: 600 13px var(--font); cursor: pointer; }
.mtog.on { background: var(--full); border-color: #9fcfc6; color: var(--full-ink); }
.mtog:disabled { opacity: .5; }
.pc-h { margin-bottom: 8px; }
.pc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.pc-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.pc-chk { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.pc-chk input { accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }
.slip-preview { background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; padding: 12px 10px 18px; margin: 0 auto;
  font: 11px/1.4 ui-monospace, Menlo, Consolas, monospace; color: #111; box-shadow: var(--shadow); position: sticky; top: 0;
  -webkit-mask: linear-gradient(#000 calc(100% - 8px), transparent); }
.slip-preview { white-space: pre; overflow: hidden; }
.slip-preview.p58 { width: 228px; font-size: 10.5px; }
.slip-preview.p80 { width: 316px; font-size: 10px; }
.slip-preview hr { border: 0; border-top: 1px dashed #777; margin: 5px 0; }
.slip-preview .ps-c { text-align: center; }
.slip-preview .ps-big { font-size: 20px; font-weight: 700; line-height: 1.25; margin: 2px 0; }
.slip-preview hr, #print-slip hr { white-space: normal; }
.helpbox { margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.helpbox ol { margin: 6px 0 0; padding-left: 20px; }
.helpbox li { margin: 3px 0; }
.helpbox summary { cursor: pointer; }
.helpbox code { font-size: 12px; background: var(--free); padding: 1px 5px; border-radius: 4px; }
.sc-reprint { margin-top: 12px; background: rgba(255, 255, 255, .92); color: var(--text); border-color: transparent; }
@media (max-width: 860px) {
  .pc-grid { grid-template-columns: 1fr; }
  .slip-preview { position: static; }
}
@media (max-width: 420px) { .pc-checks { grid-template-columns: 1fr; } }
.modal.wide { width: min(820px, calc(100% - 32px)); }

/* ---------- iPhone / iPad fixes ---------- */
@supports (height: 100dvh) {
  .modal { max-height: calc(100dvh - 48px); }
  .shell, .login, .login-shell { min-height: 100dvh; }
  .sidebar { height: 100dvh; }
}
@media (max-width: 860px) {
  @supports (height: 100dvh) { .drawer { height: 92dvh; } }
  /* iOS zooms into any text box smaller than 16px — keep them at 16px on phones */
  .input, select.input, textarea.input, input, select, textarea { font-size: 16px; }
}
.mtop { padding-top: calc(10px + env(safe-area-inset-top)); }
.sa { padding-top: calc(14px + env(safe-area-inset-top)); }
button, .list-item, [data-act] { -webkit-tap-highlight-color: transparent; }

/* ---------- Update 11: attendance + gate ---------- */
.att-controls { padding: 14px 16px; }
.att-controls .field { margin: 0; }
.att-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.att-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; }
.att-stat b { font-size: 24px; line-height: 1.1; }
.att-stat span { font-size: 12px; color: var(--muted); }
.att-stat.ok b { color: var(--full-ink); } .att-stat.bad b { color: var(--maint-ink); } .att-stat.info b { color: var(--info-ink); }
.att-floor { margin-bottom: 18px; }
.att-floor > h3 { margin: 4px 0 10px; }
.att-rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.att-room { padding: 10px 14px; }
.att-room-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 0 6px; border-bottom: 1px solid var(--line); }
.att-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.att-row:last-child { border-bottom: 0; }
.att-name { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-toggle { display: flex; gap: 5px; flex-shrink: 0; }
.att-b { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--faint); font: 700 13px var(--font); cursor: pointer; }
.att-b.present.on { background: var(--full); border-color: #9fcfc6; color: var(--full-ink); }
.att-b.absent.on { background: var(--maint); border-color: #eab3b3; color: var(--maint-ink); }
.att-b.leave.on { background: var(--info); border-color: #b9c9ef; color: var(--info-ink); }
.att-save { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px;
  padding: 10px 12px 10px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); }
.att-save .small { flex: 1; }
.att-dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 10px; }
.att-dash-item { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.rc-row { padding: 12px 14px; }
.sc-result.warn { background: #9a6412; color: #fff; }
.sc-result.out { background: #2f55a4; color: #fff; }
@media (max-width: 860px) {
  .att-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .att-rooms { grid-template-columns: minmax(0, 1fr); }
  .att-save { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .rc-row .form-grid { grid-template-columns: 1fr 1fr !important; }
}
