/* Apna PG: royal theme (deep navy, antique gold, ivory) */
:root {
  --bg: #f8f5ee;
  --card: #ffffff;
  --text: #1a2236;
  --muted: #5f6678;
  --line: #e7e0d0;
  --navy: #14213d;
  --navy-2: #1f3260;
  --gold: #c9a24b;          /* decoration only (rules, stars, icon) */
  --gold-text: #8a6516;     /* gold that passes contrast for text */
  --gold-soft: #f6ecd4;
  --accent: #1f3260;
  --accent-soft: #e8ecf5;
  --accent-text: #ffffff;
  --ok: #1d6b45;
  --ok-soft: #e1f2e8;
  --warn: #8a5a00;
  --warn-soft: #fbefd2;
  --bad: #a3271f;
  --bad-soft: #fbe3e0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .05), 0 4px 16px rgba(20, 33, 61, .05);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1424;
    --card: #161e33;
    --text: #eef0f6;
    --muted: #a3aac0;
    --line: #2a3452;
    --navy: #0a1020;
    --navy-2: #16234a;
    --gold: #d8b45e;
    --gold-text: #e3c072;
    --gold-soft: #2e2714;
    --accent: #9fb5ea;
    --accent-soft: #212d4d;
    --accent-text: #0e1424;
    --ok: #74d3a1;
    --ok-soft: #14321f;
    --warn: #f0c46a;
    --warn-soft: #3a2e10;
    --bad: #ff9d94;
    --bad-soft: #42201d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: .1px; line-height: 1.2; }
h1 { font-size: 1.75rem; margin: 0 0 .2rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .65rem; }
h3 { font-size: 1.05rem; margin: 0 0 .25rem; }
p { margin: .3rem 0 .8rem; }
a { color: var(--accent); }
small, .muted { color: var(--muted); }
.fine { font-size: .85rem; color: var(--muted); margin: 0; }
.boot { padding: 2.5rem; text-align: center; color: var(--muted); }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-text); }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .8rem 1rem; padding-top: calc(.8rem + env(safe-area-inset-top));
  background: var(--navy); color: #fff;
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--serif); font-weight: 700; font-size: 1.2rem; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.who { font-size: .88rem; text-align: right; line-height: 1.25; }
.who span { display: block; color: #e6cf94; font-size: .76rem; }

main { max-width: 880px; margin: 0 auto; padding: 1.25rem 1rem 6.5rem; }

/* ---------- navigation ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 18px rgba(20, 33, 61, .06);
}
.bottomnav a {
  flex: 1; text-align: center; padding: .5rem .2rem .55rem; text-decoration: none;
  color: var(--muted); font-size: .72rem; font-weight: 600; position: relative; min-height: 56px;
}
.bottomnav a svg { display: block; margin: 0 auto .1rem; width: 24px; height: 24px; }
.bottomnav a.on { color: var(--accent); }
.bottomnav a.on::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
  background: var(--gold); border-radius: 0 0 3px 3px;
}

.tabs {
  display: flex; gap: .15rem; overflow-x: auto; background: var(--card);
  border-bottom: 1px solid var(--line); padding: 0 .6rem; position: sticky; top: 0; z-index: 5;
  scrollbar-width: none;
}
.tabs a {
  padding: .85rem .85rem; text-decoration: none; color: var(--muted); white-space: nowrap;
  border-bottom: 3px solid transparent; font-size: .95rem; font-weight: 600;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--gold); }

/* ---------- building blocks ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.card.hero {
  background: linear-gradient(var(--navy-2), var(--navy-2)); color: #fff; border: none;
}
.stack { display: flex; flex-direction: column; gap: .8rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card.err { background: var(--bad-soft); color: var(--bad); border-color: transparent; box-shadow: none; }
.card.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; box-shadow: none; }

label { display: block; font-size: .88rem; font-weight: 600; color: var(--muted); }
label.check { display: flex; gap: .5rem; align-items: flex-start; color: var(--text); font-weight: 400; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .7rem .8rem;
  font: inherit; font-weight: 400; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; min-height: 46px;
  transition: border-color .15s, box-shadow .15s;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; display: inline-block; margin: 0; accent-color: var(--accent); }
input[type=file] { padding: .55rem .6rem; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

.btn {
  font: inherit; font-weight: 700; cursor: pointer; border-radius: 12px; min-height: 46px;
  padding: .6rem 1.1rem; border: 1px solid var(--line); background: var(--card); color: var(--text);
  transition: transform .06s, filter .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy-2); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.gold { background: var(--gold); color: #1a1406; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: .3rem .75rem; font-size: .86rem; font-weight: 600; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--accent); color: var(--accent-text); } }

.badge {
  display: inline-block; padding: .14rem .6rem; border-radius: 99px; font-size: .74rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.badge.s-received { background: var(--warn-soft); color: var(--warn); }
.badge.s-in_progress { background: var(--accent-soft); color: var(--accent); }
.badge.s-resolved { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--bad-soft); color: var(--bad); }

.note {
  background: var(--gold-soft); border-radius: 12px; padding: .6rem .8rem; margin-top: .5rem; font-size: .93rem;
}
.photo { max-width: 100%; max-height: 260px; border-radius: 12px; margin-top: .5rem; display: block; }

/* stars */
.stars { display: flex; gap: .15rem; margin-top: .35rem; }
.stars button {
  font-size: 1.8rem; line-height: 1; background: none; border: none; cursor: pointer;
  color: var(--line); padding: .15rem .2rem; min-width: 44px; min-height: 44px;
}
.stars button.on { color: var(--gold); }

/* polls */
.bar { background: var(--accent-soft); border-radius: 10px; overflow: hidden; margin: .4rem 0; position: relative; }
.bar i { display: block; height: 100%; background: var(--gold); opacity: .45; position: absolute; inset: 0 auto 0 0; transition: width .4s; }
.bar.mine i { background: var(--navy-2); opacity: .22; }
.bar span { position: relative; display: flex; justify-content: space-between; gap: .5rem; padding: .55rem .75rem; font-size: .95rem; }
.opt {
  display: flex; gap: .7rem; align-items: center; padding: .7rem .8rem; margin: .4rem 0; font-size: 1rem; font-weight: 400;
  color: var(--text); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; min-height: 48px;
}
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* tables */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
td.low { color: var(--bad); font-weight: 700; }
td.good { color: var(--ok); font-weight: 700; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }

.stat { font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.statlabel { font-size: .78rem; color: var(--muted); font-weight: 600; }
.catbar { display: flex; align-items: center; gap: .55rem; font-size: .88rem; margin: .3rem 0; }
.catbar .name { width: 6.5rem; color: var(--muted); }
.catbar .track { flex: 1; background: var(--accent-soft); border-radius: 6px; height: .7rem; overflow: hidden; }
.catbar .track i { display: block; height: 100%; background: var(--navy-2); }

/* ---------- login ---------- */
.loginpage { min-height: 100vh; background: var(--navy); display: flex; flex-direction: column; }
.login { width: 100%; max-width: 400px; margin: 0 auto; padding: 10vh 1.25rem 2rem; color: #fff; }
.login .logo { width: 72px; height: 72px; display: block; margin: 0 auto 1rem; border-radius: 18px; box-shadow: 0 0 0 3px var(--gold); }
.login h1 { text-align: center; font-size: 2.1rem; color: #fff; }
.login .tag { text-align: center; color: #e6cf94; margin: 0 0 1.6rem; font-size: .95rem; }
.login .card { color: var(--text); }
.login .help { text-align: center; color: #c9cfdf; font-size: .86rem; margin-top: 1.2rem; }

/* ---------- dialog + toast ---------- */
dialog { border: none; border-radius: var(--radius); padding: 0; max-width: min(660px, 94vw); width: 100%; background: var(--card); color: var(--text); border-top: 4px solid var(--gold); }
dialog::backdrop { background: rgba(10, 16, 32, .6); }
.dlg { padding: 1.2rem 1.25rem; max-height: 85vh; overflow-y: auto; }

#toast {
  position: fixed; left: 50%; bottom: 5.8rem; transform: translate(-50%, 20px); opacity: 0;
  background: var(--navy); color: #fff; padding: .65rem 1.1rem; border-radius: 12px; max-width: 90vw;
  transition: .2s; pointer-events: none; z-index: 100; font-size: .93rem; border-left: 4px solid var(--gold);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #a3271f; border-left-color: #fff; }

@media (min-width: 760px) {
  .bottomnav { position: static; border-top: none; border-bottom: 1px solid var(--line); box-shadow: none; justify-content: center; }
  .bottomnav a { flex: 0 1 140px; min-height: 0; padding: .7rem; font-size: .9rem; display: flex; align-items: center; justify-content: center; gap: .4rem; }
  .bottomnav a svg { display: inline-block; margin: 0; width: 20px; height: 20px; }
  .bottomnav a.on::before { top: auto; bottom: 0; border-radius: 3px 3px 0 0; }
  main { padding-bottom: 2.5rem; }
}
