:root {
  --red: #E52421; --crimson: #A3182F; --orange: #F5921E; --yellow: #FFD21F; --ink: #0B0C10;
  --grad: linear-gradient(90deg, var(--crimson), var(--red) 35%, var(--orange) 72%, var(--yellow));
  --grad-btn: linear-gradient(120deg, #B81C2E 0%, #E52421 60%, #F0551E 100%);
  --bg: #F6F4F1; --surface: #fff; --surface-2: #FAF8F5; --text: #17181F; --muted: #666B78; --line: rgba(23, 24, 31, .1);
  --ok: #138a4a; --warn: #b86e00; --shadow: 0 1px 2px rgba(23, 24, 31, .05), 0 10px 30px -16px rgba(23, 24, 31, .2);
  --font: "Plus Jakarta Sans", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --side-w: 256px; color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0C0D12; --surface: #151720; --surface-2: #1B1E29; --text: #F2F0ED; --muted: #A2A7B4; --line: rgba(255, 255, 255, .1);
  --ok: #3ccf82; --warn: #ffb547; --shadow: 0 1px 2px rgba(0, 0, 0, .5); color-scheme: dark;
}
/* dark mode: the brand red is only ~3.8:1 on the dark surface; use a lighter tint for small red text */
[data-theme="dark"] .msg.err, [data-theme="dark"] .badge.bad, [data-theme="dark"] .btn.danger, [data-theme="dark"] .list a:hover, [data-theme="dark"] .back:hover { color: #ff6b63; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: .95rem; line-height: 1.55; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--muted); }
.i { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .6rem 1.05rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; font-size: .9rem; transition: transform .2s, box-shadow .2s, border-color .2s, background .2s; }
.btn:hover { border-color: var(--orange); }
.btn.primary { background: var(--grad-btn); color: #fff; border-color: transparent; box-shadow: 0 8px 20px -10px rgba(229, 36, 33, .8); }
.btn.primary:hover { transform: translateY(-1px); }
.btn.danger { color: var(--red); } .btn.danger:hover { background: rgba(229, 36, 33, .08); border-color: var(--red); }
.btn.sm { padding: .35rem .7rem; font-size: .82rem; border-radius: 10px; }
.btn.block { width: 100%; padding: .8rem; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.icon-btn:hover { border-color: var(--orange); }
.field { display: grid; gap: .35rem; font-weight: 600; font-size: .84rem; margin-bottom: 1rem; }
.field input, .field select, .field textarea { width: 100%; font: inherit; font-weight: 500; color: var(--text); background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 12px; padding: .65rem .85rem; transition: border-color .2s, box-shadow .2s; }
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 4px rgba(245, 146, 30, .18); }
.field small { font-weight: 400; }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 600; margin-bottom: 1rem; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }
.msg { min-height: 1.3em; margin: 0 0 .8rem; font-weight: 600; font-size: .88rem; } .msg.err { color: var(--red); } .msg.ok { color: var(--ok); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; background: var(--ink); }
.auth-art span { position: absolute; border-radius: 50%; border: 36px solid transparent; border-top-color: var(--red); opacity: .55; }
.auth-art .a1 { width: 90vmax; height: 90vmax; left: -20vmax; top: -48vmax; border-top-color: var(--crimson); border-right-color: var(--red); transform: rotate(-12deg); }
.auth-art .a2 { width: 64vmax; height: 64vmax; right: -20vmax; top: -30vmax; border-width: 14px; border-top-color: var(--orange); border-right-color: var(--yellow); }
.auth-art .a3 { width: 40vmax; height: 40vmax; right: 6vmax; bottom: -30vmax; border-width: 6px; border-top-color: var(--yellow); }
.auth-card { position: relative; width: min(420px, 100%); background: var(--surface); border-radius: 26px; padding: 2.2rem 2rem 1.6rem; box-shadow: 0 40px 100px -30px #000; }
.auth-logo { height: 64px; width: auto; margin-bottom: 1.2rem; }
[data-theme="dark"] .auth-logo { background: #fff; padding: 4px 10px; border-radius: 12px; }
.auth-card h1 { font-size: 1.6rem; } .auth-card p.muted { margin: .3rem 0 1.4rem; }
.back { display: block; text-align: center; margin-top: 1.2rem; color: var(--muted); font-weight: 600; font-size: .88rem; } .back:hover { color: var(--red); }

/* shell */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--ink); color: #fff; display: flex; flex-direction: column; padding: 1.2rem .9rem; overflow-y: auto; z-index: 50; }
.side-brand { display: flex; align-items: center; gap: .8rem; padding: .3rem .5rem 1.4rem; }
.side-brand b { font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; color: var(--yellow); }
.logo-chip { background: #fff; border-radius: 12px; padding: 4px 10px; display: inline-flex; }
.logo-chip img { width: 74px; height: auto; }
#sideNav { display: grid; gap: 2px; align-content: start; flex: 1; }
#sideNav .grp { margin: 1rem .8rem .35rem; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .42); font-weight: 700; }
#sideNav a { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 12px; color: rgba(255, 255, 255, .72); font-weight: 600; position: relative; transition: background .2s, color .2s; }
#sideNav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
#sideNav a.active { background: var(--grad-btn); color: #fff; box-shadow: 0 8px 20px -10px rgba(229, 36, 33, .9); }
#sideNav .count { margin-left: auto; min-width: 22px; text-align: center; padding: 0 .4rem; border-radius: 999px; background: var(--yellow); color: #111; font-size: .72rem; font-weight: 800; }
.side-foot { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; color: rgba(255, 255, 255, .6); font-weight: 600; border-top: 1px solid rgba(255, 255, 255, .1); margin-top: 1rem; } .side-foot:hover { color: var(--yellow); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .9rem; padding: .8rem clamp(1rem, 3vw, 2rem); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 1.25rem; flex: 1; }
.top-r { display: flex; align-items: center; gap: .55rem; }
.menu { display: none; }
.user { display: flex; align-items: center; gap: .6rem; padding: .25rem .8rem .25rem .3rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.user:hover { border-color: var(--orange); }
.av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-btn); color: #fff; font-weight: 800; font-size: .8rem; }
.u-t { display: grid; text-align: left; line-height: 1.15; } .u-t small { color: var(--muted); font-size: .72rem; }
.view { padding: clamp(1rem, 3vw, 2rem); outline: none; flex: 1; }
.scrim { display: none; }

/* cards & tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.card.pad { padding: 1.3rem 1.4rem; }
.card h2 { font-size: 1.02rem; margin-bottom: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin-bottom: 1.2rem; }
.toolbar .sp { flex: 1; }
.toolbar input[type=search] { padding: .6rem .9rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font: inherit; min-width: 220px; color: var(--text); }
.toolbar input[type=search]:focus { outline: none; border-color: var(--orange); }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: .8rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--red); } tr.unread { font-weight: 700; }
td.act { white-space: nowrap; text-align: right; display: table-cell; } td.act .btn { margin-left: .35rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.badge { display: inline-block; padding: .12rem .65rem; border-radius: 999px; font-size: .74rem; font-weight: 700; border: 1px solid var(--line); background: var(--surface-2); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.badge.bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); background: color-mix(in srgb, var(--red) 8%, transparent); }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); }
.sub { color: var(--muted); font-size: .82rem; font-weight: 500; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { padding: 1.1rem 1.3rem; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--grad); }
.kpi small { color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; }
.kpi b { display: block; font-size: 2.2rem; line-height: 1.1; letter-spacing: -.03em; margin: .25rem 0; }
.kpi span { color: var(--muted); font-size: .82rem; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.2rem; margin-bottom: 1.2rem; }
.bars { display: flex; align-items: flex-end; gap: .7rem; height: 170px; padding-top: .5rem; }
.bar { flex: 1; display: grid; align-content: end; justify-items: center; gap: .4rem; height: 100%; font-size: .72rem; color: var(--muted); font-weight: 600; }
.bar i { display: block; width: 100%; max-width: 46px; border-radius: 10px 10px 4px 4px; background: var(--grad); min-height: 4px; }
.bar em { font-style: normal; color: var(--text); font-weight: 800; }
.list li { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--line); } .list li:last-child { border: 0; }
.list a:hover { color: var(--red); }

/* i18n field */
.i18n { border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface-2); margin-bottom: 1rem; overflow: hidden; }
.i18n-tabs { display: flex; gap: 2px; padding: 4px; border-bottom: 1px solid var(--line); background: var(--surface); }
.i18n-tabs button { flex: 1; border: 0; background: transparent; padding: .38rem; border-radius: 9px; font-weight: 800; font-size: .72rem; letter-spacing: .06em; color: var(--muted); position: relative; }
.i18n-tabs button.on { background: var(--grad-btn); color: #fff; }
.i18n-tabs button.filled:not(.on)::after { content: ""; position: absolute; right: 6px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.i18n textarea, .i18n input { width: 100%; border: 0; background: transparent; padding: .7rem .9rem; font: inherit; font-weight: 500; color: var(--text); display: block; }
.i18n textarea { resize: vertical; min-height: 90px; } .i18n textarea:focus, .i18n input:focus { outline: none; }
.lbl { display: block; font-weight: 600; font-size: .84rem; margin-bottom: .35rem; }
.imgpick { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.imgpick .thumb { width: 68px; height: 68px; }

/* dialog */
.dlg { border: 0; padding: 0; background: transparent; width: min(680px, calc(100% - 24px)); max-height: calc(100vh - 32px); color: var(--text); }
.dlg::backdrop { background: rgba(8, 8, 12, .6); backdrop-filter: blur(4px); }
.dlg-in { background: var(--surface); border-radius: 22px; padding: 1.5rem 1.6rem 1.3rem; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 40px 100px -30px #000; border: 1px solid var(--line); }
.dlg[open] { animation: pop .25s cubic-bezier(.2, .8, .2, 1); } @keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.dlg-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.1rem; } .dlg-h h2 { font-size: 1.2rem; }
.dlg-f { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .6rem; position: sticky; bottom: -1.3rem; background: var(--surface); padding: .8rem 0 .2rem; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: .45rem 1rem; margin-bottom: 1rem; } .kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; word-break: break-word; }
.bodytxt { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; }

/* roles matrix */
.roles { display: grid; grid-template-columns: 280px 1fr; gap: 1.2rem; align-items: start; }
.role-list { display: grid; gap: .4rem; padding: .6rem; }
.role-item { text-align: left; border: 1.5px solid transparent; background: transparent; border-radius: 12px; padding: .7rem .8rem; }
.role-item:hover { background: var(--surface-2); } .role-item.on { border-color: var(--orange); background: var(--surface-2); }
.role-item b { display: flex; justify-content: space-between; gap: .5rem; } .role-item small { color: var(--muted); }
.perm-grp { margin-bottom: 1.2rem; } .perm-grp h3 { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .5rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .3rem .8rem; }
.perm { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem .6rem; border-radius: 10px; font-weight: 500; }
.perm:hover { background: var(--surface-2); } .perm input { margin-top: .25rem; width: 17px; height: 17px; accent-color: var(--red); flex: none; }
.perm code { display: block; font-size: .72rem; color: var(--muted); }
.perm.off { opacity: .5; }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: .6rem; z-index: 9999; }
.toast { background: var(--ink); color: #fff; padding: .75rem 1.1rem; border-radius: 14px; font-weight: 600; box-shadow: 0 16px 40px -12px #000; border-left: 4px solid var(--ok); animation: pop .25s; max-width: 340px; }
.toast.err { border-left-color: var(--red); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-102%); visibility: hidden; transition: transform .3s, visibility 0s .3s; }
  .app.nav-open .side { transform: none; visibility: visible; transition: transform .3s; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 45; }
  .menu { display: grid; } .u-t { display: none; } .user { padding: .25rem; }
  .grid2, .roles { grid-template-columns: 1fr; }
}
@media (max-width: 560px) { .top { flex-wrap: wrap; gap: .4rem .6rem; } .top h1 { order: 3; flex: 1 1 100%; min-width: 0; font-size: 1.1rem; } .top-r { margin-left: auto; } }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; gap: 0; } .kv dt { margin-top: .5rem; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* language switcher (TET · PT · EN · ID) */
.lang-sw { display: inline-flex; padding: 3px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.lang-sw button { border: 0; background: transparent; padding: .34rem .55rem; border-radius: 9px; font-weight: 800; font-size: .72rem; letter-spacing: .04em; color: var(--muted); }
.lang-sw button:hover { color: var(--text); }
.lang-sw button[aria-pressed="true"] { background: var(--grad-btn); color: #fff; }
.auth-lang { position: absolute; top: 14px; right: 14px; }
@media (max-width: 560px) { .top-r .lang-sw button { padding: .3rem .4rem; } }
