/* =========================================================
   PTIS Kluang — sistem design asas
   Warna bendera Johor: biru + merah + putih
   ========================================================= */
:root {
    --jb: #1F4FB8;        /* biru logo PTIS */
    --jb-dark: #061A5A;
    --jb-ink: #0A1A45;
    --jb-soft: #E8EEFC;
    --jr: #E2343B;        /* merah logo PTIS */
    --jr-soft: #FCE8EC;
    --ink: #0F1B33;
    --muted: #5A6478;
    --line: #E1E6EF;
    --bg: #F5F7FB;
    --card: #FFFFFF;
    --font-head: 'Manrope', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font-body);
    color: var(--ink);
    background:
        linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 64px,
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}
body.auth { background: var(--bg); }

.page {
    width: 100%; max-width: 1240px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 22px 28px 26px;
    display: flex; flex-direction: column; gap: 22px;
}

/* ---------------- Header ---------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.logo-crest svg { display: block; width: 48px; height: 32px; border-radius: 6px; box-shadow: 0 4px 14px -4px rgba(11, 42, 140, .45); }
.logo-img img { display: block; width: 44px; height: 44px; border-radius: 50%; background: #fff; box-shadow: 0 4px 14px -4px rgba(31, 79, 184, .45); }
.logo strong { display: block; font-family: var(--font-head); font-size: 17px; font-weight: 800; letter-spacing: -.01em; color: var(--jb-ink); }
.logo small { display: block; font-size: 12.5px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #16A34A; box-shadow: 0 0 0 4px rgba(22, 163, 74, .15); }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px;
    background: var(--card); border: 1px solid var(--line);
    font-size: 12.5px; font-weight: 600; color: var(--jb-ink);
}
.chip svg { width: 14px; height: 14px; }

/* ---------------- Grid bento ---------------- */
.bento {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(340px, 1.25fr);
    grid-template-rows: minmax(300px, auto) auto auto;
    gap: 16px;
}
.tile {
    position: relative;
    border-radius: 24px;
    background: var(--card);
    border: 1px solid var(--line);
    padding: 26px;
}
.tile-hero    { grid-column: 1 / 4; grid-row: 1; }
.tile-login   { grid-column: 4; grid-row: 1 / 4; }
.tile-stat    { grid-row: 2; }
.tile-modules { grid-column: 1 / 4; grid-row: 3; }

/* ---------------- Kesan cahaya ikut mouse (semua .glow) ---------------- */
.glow { --mx: 50%; --my: 50%; }
.glow::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    background: radial-gradient(260px circle at var(--mx) var(--my), rgba(13, 58, 166, .10), transparent 65%);
    opacity: 0; transition: opacity .25s;
}
.glow:hover::after { opacity: 1; }
.tile-stat, .mods li { transition: transform .2s, box-shadow .2s, border-color .2s; }
.tile-stat:hover { transform: translateY(-3px); border-color: #C9D5F2; box-shadow: 0 18px 40px -24px rgba(13, 58, 166, .45); }

/* ---------------- Hero: rangkaian teknologi ---------------- */
.tile-hero {
    overflow: hidden;
    display: flex; flex-direction: column; justify-content: flex-end;
    min-height: 330px;
    padding: 34px 36px;
    border: 0;
    color: #fff;
    background:
        radial-gradient(600px 360px at 80% 30%, rgba(59, 130, 246, .35), transparent 70%),
        linear-gradient(135deg, #1652D6 0%, var(--jb) 45%, var(--jb-dark) 100%);
    transform-style: preserve-3d;
    transition: transform .25s ease-out;
    will-change: transform;
}
.tile-hero.glow::after { background: radial-gradient(320px circle at var(--mx) var(--my), rgba(255, 255, 255, .12), transparent 65%); }
.net { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-shade {
    position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(90deg, rgba(6, 26, 90, .85) 0%, rgba(6, 26, 90, .45) 45%, transparent 75%);
}
.hero-content { position: relative; z-index: 1; pointer-events: none; }
.kicker {
    display: inline-flex; align-items: center; gap: 8px;
    margin: 0 0 14px; padding: 6px 12px;
    border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16);
    font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #DCE6FF;
}
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--jr); box-shadow: 0 0 0 0 rgba(210, 16, 52, .7); animation: ping 1.8s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 9px rgba(210, 16, 52, 0); } 100% { box-shadow: 0 0 0 0 rgba(210, 16, 52, 0); } }
.tile-hero h1 {
    margin: 0;
    font-family: var(--font-head); font-weight: 800;
    font-size: clamp(30px, 3.4vw, 48px); line-height: 1.06; letter-spacing: -.03em;
}
.tile-hero h1 span {
    background: linear-gradient(90deg, #FFFFFF, #A9C4FF);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-text { max-width: 520px; margin: 16px 0 0; font-size: 15px; line-height: 1.6; color: rgba(255, 255, 255, .8); }
.hero-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 18px; font-size: 12px; color: rgba(255, 255, 255, .7); }
.hero-legend span { display: inline-flex; align-items: center; gap: 7px; }
.hero-legend i { display: inline-block; border-radius: 50%; }
.lg-node { width: 7px; height: 7px; background: #CFE0FF; }
.lg-hub { width: 11px; height: 11px; background: #fff; box-shadow: 0 0 0 3px var(--jr); }
.lg-pkt { width: 6px; height: 6px; background: #FF5C7A; box-shadow: 0 0 8px #FF5C7A; }

/* ---------------- Statistik ---------------- */
.tile-stat { display: flex; flex-direction: column; padding: 20px 22px; overflow: hidden; }
.stat-head { display: flex; align-items: center; justify-content: space-between; }
.stat-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--jb-soft); color: var(--jb); }
.stat-ico.red { background: var(--jr-soft); color: var(--jr); }
.stat-tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #94A0B8; }
.tile-stat b { display: block; margin-top: 14px; font-family: var(--font-head); font-size: 38px; font-weight: 800; letter-spacing: -.03em; color: var(--jb); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { display: block; margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.stat-note { margin: auto 0 0; padding-top: 14px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.stat-note strong { color: var(--ink); }

.seg { display: flex; gap: 3px; height: 8px; margin-top: 16px; border-radius: 99px; overflow: hidden; }
.seg i { display: block; transform-origin: left; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; }
.seg-legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.seg-legend li { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.seg-legend i { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.seg-legend em { margin-left: auto; font-style: normal; font-weight: 600; color: var(--ink); }

.ring {
    --p: 0;
    position: relative; flex: none;
    width: 70px; height: 70px; border-radius: 50%;
    background: conic-gradient(var(--jr) calc(var(--p) * 1%), var(--jr-soft) 0);
    display: grid; place-items: center;
    animation: spin-in 1s cubic-bezier(.2,.8,.2,1) both;
}
.ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: #fff; }
.ring span { position: relative; font-family: var(--font-head); font-weight: 800; font-size: 16px; color: var(--jr); }
@keyframes spin-in { from { transform: rotate(-90deg) scale(.8); opacity: 0; } }

.bars { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 7px; }
.bars li { display: grid; grid-template-columns: 74px 1fr 26px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 6px; border-radius: 99px; background: var(--jb-soft); overflow: hidden; }
.bar-track i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, var(--jb), #3B82F6); transform-origin: left; animation: grow 1s cubic-bezier(.2,.8,.2,1) both; }
.bars em { font-style: normal; font-weight: 600; text-align: right; color: var(--ink); }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------------- Modul ---------------- */
.tile-modules { padding: 20px 22px; }
.mod-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.mod-count { font-size: 12px; color: #94A0B8; }
.eyebrow { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--jr); }
.eyebrow.dark { color: var(--muted); }
.mods { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mods li {
    position: relative; overflow: hidden;
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px; border-radius: 14px;
    background: var(--bg); border: 1px solid var(--line);
    font-size: 13px; font-weight: 600; color: var(--jb-ink);
}
.mods li:hover { transform: translateY(-2px); background: #fff; border-color: #C9D5F2; }
.mod-ico { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #fff; color: var(--jb); border: 1px solid var(--line); transition: background .2s, color .2s; }
.mods li:hover .mod-ico { background: var(--jb); color: #fff; border-color: var(--jb); }
.mods li:nth-child(even):hover .mod-ico { background: var(--jr); border-color: var(--jr); }
.mod-ico svg { width: 16px; height: 16px; }

/* ---------------- Jam & kali pertama (kad log masuk) ---------------- */
.clock { display: flex; align-items: baseline; gap: 4px; margin-bottom: 18px; font-family: var(--font-head); font-variant-numeric: tabular-nums; color: var(--jb-ink); }
.clock-time { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.clock-sec { font-size: 16px; font-weight: 700; color: var(--jr); }
.first-time { margin-top: 20px; padding: 14px 16px; border-radius: 14px; background: var(--bg); border: 1px dashed #CBD5E6; }
.ft-title { margin: 0 0 10px; font-size: 12.5px; font-weight: 700; color: var(--jb-ink); }
.first-time ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.first-time li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.first-time li b { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--jb); color: #fff; font-size: 11px; }
.first-time li:nth-child(2) b { background: var(--jr); }
.first-time em { font-style: normal; font-weight: 600; color: var(--ink); }

/* Log masuk */
.tile-login {
    display: flex; flex-direction: column;
    padding: 34px 30px 26px;
    border-top: 4px solid var(--jr);
    box-shadow: 0 30px 60px -30px rgba(11, 42, 140, .30);
}
.tile-login h2 {
    margin: 14px 0 10px;
    font-family: var(--font-head); font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1;
    color: var(--jb-ink);
}
.tile-login h2 span { color: var(--jr); }
.lead { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.6; }

.actions { display: grid; gap: 10px; padding-top: 24px; }
.btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; min-height: 52px; padding: 0 18px;
    border-radius: 14px; border: 1px solid transparent;
    font: 600 15px var(--font-body); cursor: pointer;
    transition: transform .15s, box-shadow .15s, background .15s;
}
.btn-primary { background: var(--jb); color: #fff; box-shadow: 0 12px 24px -12px rgba(11, 42, 140, .7); }
.btn-primary:hover:not(:disabled) { background: #0E34AA; transform: translateY(-1px); }
.btn-ico { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #fff; }
.btn-ico svg { width: 18px; height: 18px; }
.btn-ghost { background: var(--card); color: var(--jb-ink); border-color: var(--line); }
.btn-ghost svg { color: var(--jr); }
.btn-ghost:hover:not(:disabled) { border-color: var(--jb); }
.btn { text-decoration: none; }
.alert { margin-top: 18px; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.alert-error { background: var(--jr-soft); color: #9F0C27; border: 1px solid #F6C3CD; }
.alert-info { background: var(--jb-soft); color: var(--jb); border: 1px solid #C9D5F2; }
.btn:disabled { cursor: not-allowed; opacity: .55; }

.assure { list-style: none; margin: 22px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.assure li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.assure svg { width: 16px; height: 16px; color: var(--jb); }

.pagefoot { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; color: #8A93A6; }

/* ---------------- Tablet / telefon ---------------- */
@media (max-width: 1024px) {
    .mods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bento { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto; }
    .tile-hero    { grid-column: 1 / -1; grid-row: auto; min-height: 260px; }
    .tile-login   { grid-column: 1 / -1; grid-row: auto; }
    .tile-stat    { grid-row: auto; }
    .tile-modules { grid-column: 1 / -1; grid-row: auto; }
}
@media (max-width: 640px) {
    .page { padding: 16px 14px 20px; gap: 14px; }
    .status, .pagefoot span:last-child { display: none; }
    .bento { gap: 12px; }
    .tile-login { order: -1; padding: 26px 22px 22px; }   /* log masuk dulu di telefon */
    .tile-login h2 { font-size: 28px; }
    .actions { padding-top: 22px; }
    .tile-hero { min-height: 220px; padding: 26px 22px; }
    .hero-canton { width: 120px; height: 72px; }
    .hero-canton::before { left: 14px; top: 14px; width: 30px; height: 30px; box-shadow: -5px 3px 0 0 #fff; }
    .hero-canton::after { left: 56px; top: 14px; width: 15px; height: 15px; }
    .tile-stat { grid-column: 1 / -1; padding: 18px; border-radius: 18px; }
    .tile-stat b { font-size: 26px; margin-top: 10px; }
    .stat-ico { width: 32px; height: 32px; }
    .tile-modules { display: none; }
    .clock-time { font-size: 36px; }
    .seg-legend { grid-template-columns: 1fr; }
}

/* Hormati tetapan 'kurangkan animasi' pengguna */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------- Popup (dialog) ---------------- */
.dlg {
    width: min(480px, calc(100vw - 24px));
    padding: 24px; border: 0; border-radius: 22px;
    border-top: 4px solid var(--jr);
    box-shadow: 0 40px 80px -30px rgba(6, 26, 90, .5);
    color: var(--ink); font-family: var(--font-body);
}
.dlg::backdrop { background: rgba(6, 26, 90, .45); backdrop-filter: blur(4px); }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dlg h3 { margin: 6px 0 0; font-family: var(--font-head); font-size: 22px; font-weight: 800; color: var(--jb-ink); }
.dlg-x { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--muted); }
.pk-list { list-style: none; margin: 18px 0 14px; padding: 0; display: grid; gap: 8px; }
.pk-list li { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.pk-ico { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--jr-soft); color: var(--jr); }
.pk-info { flex: 1; min-width: 0; }
.pk-info b { display: block; font-size: 14px; }
.pk-info small { display: block; font-size: 12px; color: var(--muted); }
.pk-buang { border: 0; background: none; color: var(--jr); font: 600 13px var(--font-body); cursor: pointer; }
.pk-kosong { justify-content: center; color: var(--muted); font-size: 13.5px; border-style: dashed !important; }
.pk-label { display: block; margin-top: 4px; font-size: 12.5px; font-weight: 600; color: var(--jb-ink); }
.pk-input { width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font: 15px var(--font-body); }
.pk-input:focus { outline: 2px solid var(--jb); outline-offset: 1px; }
.cf-turnstile { min-height: 65px; }
