/* Portal Kelas: gaya bersama untuk index.html dan admin.html.
   Tata letak: satu kolom lebar 1120px, bagian bertumpuk, kartu rapat. Tiap siswa ditandai lingkaran bernomor. */
:root {
  --bg: #EEF2F4;
  --surface: #FFFFFF;
  --ink: #13293D;
  --muted: #566878;
  --line: #D5DDE3;
  --line-strong: #B7C3CC;
  --accent: #0A6C74;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDEFF0;
  --today: #9A4A07;
  --today-soft: #FDF0DC;
  --pagi-bg: #FFF1CC;
  --pagi-fg: #7A4B00;
  --sore-bg: #E4E8FB;
  --sore-fg: #2F3E9E;
  --ok-bg: #DDEFF0;   --ok-fg: #0A5A61;
  --no-bg: #FBE3E0;   --no-fg: #9B2318;
  --iz-bg: #FDF0DC;   --iz-fg: #8A4B05;
  --na-bg: #E7ECEF;   --na-fg: #4A5B68;
  --ph-bg: #FFF4CC;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1A22; --surface: #15252F; --ink: #E6EEF3; --muted: #9DB1BE; --line: #263A47; --line-strong: #3A5262;
    --accent: #4FC3CC; --accent-ink: #06262A; --accent-soft: #12363C;
    --today: #F2A65A; --today-soft: #3A2A14;
    --pagi-bg: #3A2D0E; --pagi-fg: #F3CE7A; --sore-bg: #1F2650; --sore-fg: #B5C0FF;
    --ok-bg: #12363C; --ok-fg: #8FDDE3; --no-bg: #4A1E1A; --no-fg: #FFB3A8;
    --iz-bg: #3A2A14; --iz-fg: #F2C27F; --na-bg: #22333F; --na-fg: #B4C4CF; --ph-bg: #3F3512;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1A22; --surface: #15252F; --ink: #E6EEF3; --muted: #9DB1BE; --line: #263A47; --line-strong: #3A5262;
  --accent: #4FC3CC; --accent-ink: #06262A; --accent-soft: #12363C;
  --today: #F2A65A; --today-soft: #3A2A14;
  --pagi-bg: #3A2D0E; --pagi-fg: #F3CE7A; --sore-bg: #1F2650; --sore-fg: #B5C0FF;
  --ok-bg: #12363C; --ok-fg: #8FDDE3; --no-bg: #4A1E1A; --no-fg: #FFB3A8;
  --iz-bg: #3A2A14; --iz-fg: #F2C27F; --na-bg: #22333F; --na-fg: #B4C4CF; --ph-bg: #3F3512;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding-inline: 16px;
  padding-block: 24px 64px;
}
.wrap { max-width: 1120px; margin-inline: auto; display: flex; flex-direction: column; gap: 32px; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 800; line-height: 1.1; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 17px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Kepala halaman dan navigasi */
.top { display: flex; flex-direction: column; gap: 8px; }
.top .row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }
.top .sub { color: var(--muted); }
.classlabel { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.nav a { text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 40px; display: inline-flex; align-items: center; font-weight: 600; font-size: 14px; }
.nav a:hover { border-color: var(--accent); color: var(--accent); }
section[id] { scroll-margin-top: 16px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.banner { border-radius: 10px; padding: 10px 14px; font-size: 14px; background: var(--iz-bg); color: var(--iz-fg); }
.banner.err { background: var(--no-bg); color: var(--no-fg); }
.empty { color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 16px; }
.ph { background: var(--ph-bg); border-radius: 4px; padding: 0 3px; }

/* Tombol dan kolom isian */
input, select, button, textarea { font: inherit; color: inherit; }
input[type="date"], input[type="text"], input[type="password"], select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 44px; width: 100%;
}
button.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 9px 16px; min-height: 44px; font-weight: 700; cursor: pointer; }
button.btn:hover { filter: brightness(1.08); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 12px; min-height: 40px; font-weight: 600; cursor: pointer; }
button.ghost:hover { border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }

/* Penanda siswa: lingkaran bernomor */
.who { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; }
.who .t { padding-top: 1px; font-weight: 600; overflow-wrap: anywhere; }
.mk { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mk.pagi { background: var(--pagi-fg); color: var(--pagi-bg); }
.mk.sore { background: var(--sore-fg); color: var(--sore-bg); }
.tag { align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; }
.tag.pagi { background: var(--pagi-bg); color: var(--pagi-fg); }
.tag.sore { background: var(--sore-bg); color: var(--sore-fg); }
.tag.umum { background: var(--accent-soft); color: var(--accent); }

/* Hari ini */
.today { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 20px 32px; align-items: start; }
.today .kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.today .big { font-family: var(--font-display); font-weight: 800; font-size: clamp(34px, 6vw, 52px); line-height: 1; color: var(--accent); margin-top: 6px; }
.today .big.off { font-size: 28px; color: var(--muted); }
.today .meta { margin-top: 10px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.shifts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.shift { border-radius: 10px; padding: 12px 14px; min-width: 0; }
.shift.pagi { background: var(--pagi-bg); color: var(--pagi-fg); }
.shift.sore { background: var(--sore-bg); color: var(--sore-fg); }
.shift .lbl { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.shift .list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }

/* Tugas piket */
.sec-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; }
.sec-head .field { flex-direction: row; align-items: center; gap: 8px; }
.sec-head select { width: auto; }
.tasks { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-top: 14px; }
.task { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.task header { display: flex; flex-direction: column; gap: 6px; }
.task .when { font-size: 13px; color: var(--muted); }
.task h4 { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; font-family: var(--font-body); }
.task ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 8px; font-size: 14px; }
.task li::before { content: ""; width: 12px; height: 12px; margin-top: 4px; border: 2px solid var(--accent); border-radius: 3px; }

/* Kalender */
.weeks { display: flex; flex-direction: column; gap: 22px; margin-top: 14px; }
.week-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.days { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.day .date { font-size: 13px; font-weight: 600; color: var(--muted); }
.day .head { display: flex; flex-direction: column; gap: 2px; }
.day .grp { font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.1; }
.day .cnt { font-size: 12px; color: var(--muted); }
.day.istoday { border: 2px solid var(--today); background: var(--today-soft); }
.day.istoday .date { color: var(--today); }
.day.off { background: transparent; border-style: dashed; }
.day.off .grp { color: var(--muted); font-size: 16px; font-weight: 600; }
.slot { display: flex; flex-direction: column; gap: 6px; }
.slot .who { font-size: 14px; }
.slot .who .t { font-weight: 500; }
.round { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.status { min-height: 22px; font-size: 14px; color: var(--accent); margin-top: 8px; }
.fallback { width: 100%; min-height: 150px; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }

/* Struktur organisasi */
.org { display: flex; flex-direction: column; align-items: center; margin-top: 16px; }
.tier { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding-top: 24px; width: 100%; }
.tier:first-child { padding-top: 0; }
.tier:not(:first-child)::before { content: ""; position: absolute; top: 0; left: 50%; width: 2px; height: 24px; background: var(--line-strong); }
.node { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 14px; min-width: 190px; max-width: 280px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.node .role { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.node .name { font-weight: 700; overflow-wrap: anywhere; }
.node .sub { font-size: 12px; color: var(--muted); }
.node.top { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.node.top .role, .node.top .sub { color: inherit; opacity: 0.8; }
.node.guru { border-style: dashed; border-color: var(--accent); }
.node.empty-name .name { color: var(--muted); font-weight: 500; }
.node.top.empty-name .name { color: inherit; opacity: 0.8; }
.cluster { background: var(--accent-soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; min-width: 0; }
.cluster > .ctitle { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.cluster .node { min-width: 170px; }
.cluster .items { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.seksi { align-items: stretch; }
.seksi .node { text-align: left; min-width: 0; max-width: none; width: 100%; }
.seksi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; width: 100%; }
.seksi-card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.seksi-card h3 { font-size: 16px; }
.seksi-card .line { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px; font-size: 14px; }
.seksi-card .line b { color: var(--muted); font-weight: 600; }
.seksi-card .line span { overflow-wrap: anywhere; }
.legend { margin-top: 14px; font-size: 13px; color: var(--muted); }

/* Kesepakatan */
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-top: 14px; }
.rule { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.rule ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.rule li { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 10px; font-size: 14.5px; }
.rule li::before { content: ""; width: 6px; height: 6px; margin-top: 8px; border-radius: 50%; background: var(--accent); }
.rule .intro { color: var(--muted); font-size: 14.5px; }

/* Rekap sholat berjamaah */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile .v { font-family: var(--font-display); font-size: 36px; font-weight: 800; line-height: 1.1; }
.tile .s { font-size: 13px; color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-top: 14px; }
.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; position: relative; }
.chart figcaption { font-weight: 600; margin-bottom: 12px; }
.chart figcaption small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.plot { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 6px; }
.yaxis { display: flex; flex-direction: column; justify-content: space-between; height: 160px; font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; line-height: 1; }
.area { position: relative; min-width: 0; }
.grid { position: absolute; inset: 0 0 auto 0; height: 160px; pointer-events: none; }
.grid i { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.cols { position: relative; display: flex; gap: 2px; height: 160px; align-items: stretch; }
.col { flex: 1 1 0; min-width: 0; position: relative; display: flex; align-items: flex-end; justify-content: center; padding: 0; border: 0; background: transparent; cursor: default; border-radius: 4px; }
.col .bar { width: min(100%, 24px); background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; transition: opacity 0.1s; }
.col:hover .bar, .col:focus-visible .bar { opacity: 0.75; }
.col:hover, .col:focus-visible { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.col .val { position: absolute; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.xlabels { display: flex; gap: 2px; margin-top: 6px; }
.xlabels span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 11px; color: var(--muted); line-height: 1.2; }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.35; min-width: 130px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); display: none; }
.tip b { display: block; font-size: 18px; font-family: var(--font-display); }
.tip.on { display: block; }
details.tbl { margin-top: 14px; }
details.tbl summary { cursor: pointer; font-weight: 600; color: var(--accent); min-height: 32px; }
.tbl-scroll { overflow-x: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.foot { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; }

/* Halaman admin */
.admin-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.bulk { display: flex; flex-wrap: wrap; gap: 8px; }
.counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 14px; }
.count { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.count h3 { font-size: 15px; }
.count .line { display: flex; flex-wrap: wrap; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.srow { display: grid; grid-template-columns: 34px minmax(0, 1fr) 118px 118px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.srow.head { position: sticky; top: 0; z-index: 3; background: var(--surface); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.srow .nm { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.srow .nm small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.srow .no { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 14px; }
.st { width: 100%; min-height: 44px; border: 0; border-radius: 8px; font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px 6px; }
.st.kosong { background: transparent; color: var(--muted); border: 1px dashed var(--line-strong); font-weight: 500; }
.st.Tap { background: var(--ok-bg); color: var(--ok-fg); }
.st.Tidak-tap { background: var(--no-bg); color: var(--no-fg); }
.st.Izin { background: var(--iz-bg); color: var(--iz-fg); }
.st.Tidak-wajib { background: var(--na-bg); color: var(--na-fg); }
.savebar { position: sticky; bottom: 0; margin-top: 16px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.08); }
.savebar .msg { font-size: 14px; }
.savebar .msg.ok { color: var(--ok-fg); }
.savebar .msg.warn { color: var(--iz-fg); }
.savebar .msg.err { color: var(--no-fg); }
.login { max-width: 420px; margin-inline: auto; display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 860px) {
  .today { grid-template-columns: minmax(0, 1fr); }
  .days { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .shifts { grid-template-columns: minmax(0, 1fr); }
  .rules { grid-template-columns: minmax(0, 1fr); }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .srow { grid-template-columns: 26px minmax(0, 1fr) 92px 92px; gap: 6px; padding-inline: 6px; }
  .st { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
.ghost-link { color: var(--accent); font-weight: 600; text-decoration: none; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 12px; }
