/* ============ Token & tema warna ============ */
:root, .tema-navy {
  --aksen: #1B2489;  --on-aksen: #ffffff; --aksen-gelap: #11175F; --link: #1B2489;
  --muda: #E6E9F9;   --latar: #F2F4FB;
  --hero-bg: #11175F; --hero-fg: #ffffff; --hero-sub: #B9C0EE; --sorot: #FFE600;
}
.tema-kuning {
  --aksen: #F2D100;  --on-aksen: #11175F; --aksen-gelap: #D1B300; --link: #11175F;
  --muda: #FFF4B8;   --latar: #FFFBE6;
  --hero-bg: #FFE81F; --hero-fg: #11175F; --hero-sub: #3B4090; --sorot: #11175F;
}
.tema-hijau {
  --aksen: #146B3A;  --on-aksen: #ffffff; --aksen-gelap: #0C4A27; --link: #146B3A;
  --muda: #DFF1E6;   --latar: #F0F7F2;
  --hero-bg: #0C4A27; --hero-fg: #ffffff; --hero-sub: #BCE0C8; --sorot: #FFE600;
}
.tema-teal {
  --aksen: #0E5A63;  --on-aksen: #ffffff; --aksen-gelap: #0B3F47; --link: #0E5A63;
  --muda: #DDEEF0;   --latar: #EEF4F5;
  --hero-bg: #0B3F47; --hero-fg: #ffffff; --hero-sub: #BFDADD; --sorot: #F2B705;
}
.tema-marun {
  --aksen: #A12B2B;  --on-aksen: #ffffff; --aksen-gelap: #6E1B1B; --link: #A12B2B;
  --muda: #F7E3E3;   --latar: #FBF4F4;
  --hero-bg: #6E1B1B; --hero-fg: #ffffff; --hero-sub: #EBC3C3; --sorot: #F2B705;
}
.tema-ungu {
  --aksen: #5B3A9E;  --on-aksen: #ffffff; --aksen-gelap: #3E2870; --link: #5B3A9E;
  --muda: #ECE5F8;   --latar: #F6F3FB;
  --hero-bg: #3E2870; --hero-fg: #ffffff; --hero-sub: #D2C5EC; --sorot: #F2B705;
}

:root {
  --putih: #ffffff;
  --tinta: #131A2B;
  --tinta-2: #566074;
  --garis: #E2E6EF;
  --merah: #B8372A;
  --hijau: #2F7D32;
  --kuning: #F2B705;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 3px 10px rgba(16, 24, 40, .05);
  --shadow-2: 0 2px 4px rgba(16, 24, 40, .06), 0 10px 26px rgba(16, 24, 40, .12);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
}

/* ============ Dasar ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--latar); color: var(--tinta);
  font: 16px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
a { color: var(--link); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.top :focus-visible, .adm-bar :focus-visible { outline-color: var(--hero-fg); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--tinta-2); font-size: .92rem; font-weight: 400; }

/* ============ Kotak icon ============ */
.tile {
  --w: #14919B; --w2: #0B5B63; --wt: #fff;
  width: 52px; height: 52px; flex: none;
  border-radius: 15px;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(145deg, var(--w), var(--w2)); color: var(--wt);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-emoji { font-size: 26px; line-height: 1; }
.tile-letter { font: 700 24px/1 var(--font); }
.tile-sm { width: 42px; height: 42px; border-radius: 12px; }
.tile-sm .tile-emoji { font-size: 21px; }
.tile-sm .tile-letter { font-size: 19px; }
.w-teal   { --w: #14919B; --w2: #0B5B63; }
.w-kuning { --w: #FFD21F; --w2: #F2A900; --wt: #11175F; }
.w-merah  { --w: #E0533F; --w2: #B3321F; }
.w-biru   { --w: #3F6FE0; --w2: #2543A8; }
.w-hijau  { --w: #3FA55A; --w2: #1F7A3A; }
.w-ungu   { --w: #8A5BD0; --w2: #5B3A9E; }
.w-oranye { --w: #F08A3C; --w2: #C9561F; }
.w-abu    { --w: #6C7A86; --w2: #46525B; }

/* ============ Halaman publik ============ */
.top {
  background: var(--hero-bg); color: var(--hero-fg);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
}
.top-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.top-logo { height: 44px; width: auto; display: block; }
.top-text { min-width: 0; }
.top-name { margin: 0; font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.top-sub  { margin: 0; font-size: .82rem; color: var(--hero-sub); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 16px 12px; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 18px; }
.toolbar h1 { font-size: 1.6rem; }
.toolbar-sub { margin: 2px 0 0; color: var(--tinta-2); font-size: .92rem; }

.search { position: relative; flex: 0 1 340px; min-width: 220px; }
.search-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--tinta-2); pointer-events: none; }
.search input {
  width: 100%; height: 48px; padding: 0 16px 0 44px;
  font: inherit; font-size: 16px; color: var(--tinta);
  background: var(--putih); border: 1px solid var(--garis); border-radius: 14px;
  box-shadow: var(--shadow-1); appearance: none; -webkit-appearance: none;
}
.search input:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px var(--muda), var(--shadow-1); }

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.card {
  display: flex; align-items: center; gap: 14px;
  height: 100%; min-height: 88px; padding: 14px 14px 14px 14px;
  background: var(--putih); color: inherit; text-decoration: none;
  border: 1px solid transparent; border-radius: 20px;
  box-shadow: var(--shadow-1);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--aksen); }
.card:active { transform: translateY(0); }
.card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.card-title { font-weight: 700; font-size: 1.04rem; line-height: 1.25; overflow-wrap: anywhere; }
.card-desc {
  color: var(--tinta-2); font-size: .88rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-go {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; background: var(--muda); color: var(--link);
  transition: background .16s ease, color .16s ease;
}
.card:hover .card-go { background: var(--aksen); color: var(--on-aksen); }

.card.is-off { box-shadow: none; background: rgba(255, 255, 255, .55); border: 1px dashed #C5CCDA; }
.card.is-off:hover { transform: none; border-color: #C5CCDA; }
.card.is-off .tile { filter: grayscale(1); opacity: .5; }
.card.is-off .card-title, .card.is-off .card-desc { color: var(--tinta-2); }
.badge-off { flex: none; font-size: .75rem; font-weight: 600; color: var(--tinta-2); background: #E9EDF3; padding: 4px 10px; border-radius: 999px; }

.empty { padding: 40px 0; color: var(--tinta-2); text-align: center; }
.foot {
  max-width: 1080px; margin: 0 auto; padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex; justify-content: space-between; gap: 12px; color: var(--tinta-2); font-size: .88rem;
}
.foot a { color: var(--tinta-2); }

.err { text-align: center; padding-top: 72px; }
.err-code { font: 800 4rem/1 var(--font); color: var(--link); margin: 0 0 8px; }
.err h1 { margin-bottom: 8px; }

/* ============ Tombol & formulir ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px;
  font: 600 .95rem/1.2 var(--font);
  background: var(--aksen); color: var(--on-aksen);
  border: 2px solid var(--aksen); border-radius: 12px;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--aksen-gelap); border-color: var(--aksen-gelap); color: var(--on-aksen); }
.tema-kuning .btn:hover { color: #fff; }
.btn-quiet { background: var(--putih); color: var(--link); border-color: var(--garis); }
.btn-quiet:hover { background: var(--muda); color: var(--link); border-color: var(--link); }
.tema-kuning .btn-quiet:hover { color: var(--link); }
.btn-danger { background: var(--putih); color: var(--merah); border-color: #EBC5C0; }
.btn-danger:hover { background: var(--merah); color: #fff; border-color: var(--merah); }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn-bar { background: transparent; color: var(--hero-fg); border-color: var(--hero-sub); min-height: 34px; }
.btn-bar:hover { background: rgba(255, 255, 255, .15); color: var(--hero-fg); border-color: var(--hero-fg); }
.tema-kuning .btn-bar:hover { background: rgba(17, 23, 95, .1); color: var(--hero-fg); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.form { display: grid; gap: 6px; max-width: 420px; }
.form-wide { max-width: 640px; }
.form label { font-weight: 600; margin-top: 10px; }
.form input:not([type=checkbox]):not([type=radio]):not([type=file]), .form textarea {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 16px;
  background: #fff; border: 1px solid #C2CAD9; border-radius: 12px; color: var(--tinta);
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px var(--muda); }
.form input.short { max-width: 200px; }
.form input[type=file] { font: inherit; max-width: 100%; }
.form fieldset { border: 1px solid var(--garis); border-radius: 14px; padding: 8px 14px 14px; margin: 14px 0 0; background: #fff; min-width: 0; }
.form legend { font-weight: 700; padding: 0 6px; }
.form .check { display: flex; gap: 10px; align-items: center; font-weight: 500; min-height: 40px; }
.form .check input { width: 20px; height: 20px; flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 0; padding: 4px 12px 4px 6px; border: 1px solid var(--garis); border-radius: 12px; background: #fff; cursor: pointer; }
.swatch:has(input:checked) { border-color: var(--link); box-shadow: 0 0 0 2px var(--link); }
.icon-now { display: flex; align-items: center; gap: 14px; margin: 8px 0; }
.icon-preview { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; }

.notice { padding: 12px 16px; border-radius: 12px; border-left: 5px solid; background: #fff; margin: 0 0 16px; box-shadow: var(--shadow-1); }
.notice ul, .notice p { margin: 0; }
.notice ul { padding-left: 20px; }
.notice-ok   { border-color: var(--hijau); }
.notice-err  { border-color: var(--merah); }
.notice-warn { border-color: var(--kuning); }

.login { max-width: 420px; margin: 0 auto; padding: 56px 20px; }
.login h1 { font-size: 1.9rem; }
.login .form { margin: 20px 0; max-width: none; }

/* ============ Admin ============ */
.adm-bar { background: var(--hero-bg); color: var(--hero-fg); padding: env(safe-area-inset-top, 0px) 16px 0; }
.adm-bar-top { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 4px; }
.adm-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--hero-fg); text-decoration: none; }
.adm-brand img { height: 34px; width: auto; }
.adm-out { display: flex; align-items: center; gap: 10px; margin: 0; }
.adm-user { color: var(--hero-sub); font-size: .88rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-nav { max-width: 1080px; margin: 0 auto; display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
.adm-nav::-webkit-scrollbar { display: none; }
.adm-nav a { flex: none; padding: 10px 12px; color: var(--hero-sub); text-decoration: none; font-weight: 600; font-size: .92rem; border-bottom: 3px solid transparent; }
.adm-nav a:hover { color: var(--hero-fg); border-bottom-color: var(--hero-fg); }

.adm-main { max-width: 1080px; margin: 0 auto; padding: 22px 16px calc(60px + env(safe-area-inset-bottom, 0px)); }
.adm-main > h1 { font-size: 1.6rem; margin-bottom: 4px; }
.adm-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; align-items: end; margin-bottom: 14px; }
.adm-head h1 { font-size: 1.6rem; }
.adm-head p { margin: 2px 0 0; }
.adm-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.legend { margin: 0 0 12px; color: var(--tinta-2); font-size: .92rem; }
.legend summary { cursor: pointer; color: var(--link); font-weight: 600; }
.legend p { margin: 8px 0 0; }
.sortbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 8px; color: var(--tinta-2); font-size: .92rem; }
.sortbar a { text-decoration: none; padding: 6px 0; }
.sortbar a[aria-current] { color: var(--tinta); font-weight: 700; border-bottom: 3px solid var(--aksen); }
.hint { margin: 0 0 4px; color: var(--tinta-2); font-size: .9rem; }
.grip-inline { font-weight: 700; letter-spacing: -2px; }
.status { min-height: 1.4em; margin: 0 0 8px; font-size: .9rem; color: var(--link); font-weight: 600; }

.daftar { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 10px 12px; background: var(--putih);
  border: 1px solid var(--garis); border-radius: 16px; box-shadow: var(--shadow-1);
}
.item.is-off { background: rgba(255, 255, 255, .6); }
.item.is-off .item-info strong { color: var(--tinta-2); }
.item.dragging { box-shadow: var(--shadow-2); border-color: var(--aksen); position: relative; z-index: 2; background: #fff; }
.item-main { display: flex; align-items: center; gap: 10px; flex: 1 1 300px; min-width: 0; }
.item-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.item-info .url { font-size: .85rem; overflow-wrap: anywhere; }
.item-side { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.item-side form { margin: 0; }
.item-act { display: flex; gap: 6px; margin-left: 4px; }

.handle {
  flex: none; display: grid; place-items: center; width: 36px; height: 44px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--tinta-2);
  cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none;
}
.handle:hover { background: var(--muda); color: var(--link); }
.pos { flex: none; min-width: 22px; text-align: center; font-weight: 700; font-size: .85rem; color: var(--tinta-2); font-variant-numeric: tabular-nums; }
body.is-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
body.is-dragging * { cursor: grabbing !important; }

.port { display: inline-flex; flex-direction: column; align-items: flex-start; min-width: 64px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.port.dup { color: var(--merah); }
.srv { font: 600 .72rem var(--font); color: var(--tinta-2); }
.pill { min-height: 34px; font: 600 .82rem var(--font); padding: 4px 14px; border-radius: 999px; border: 1px solid; cursor: pointer; background: #fff; }
.pill-on   { color: #1E6B22; border-color: #A9CFAB; background: #EDF7EE; }
.pill-off  { color: var(--tinta-2); border-color: var(--garis); }
.pill-warn { color: #7A5A00; border-color: #E6CF85; background: #FFF6D6; }

/* Pengaturan warna */
.set-form { display: grid; gap: 16px; max-width: 720px; margin-top: 16px; }
.temas { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.temas legend { font-weight: 700; padding: 0; margin-bottom: 10px; }
.tema-opt { position: relative; display: block; cursor: pointer; }
.tema-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tema-card { display: grid; gap: 2px; padding: 10px; background: #fff; border: 2px solid var(--garis); border-radius: 16px; box-shadow: var(--shadow-1); }
.tema-opt input:checked + .tema-card { border-color: var(--link); box-shadow: 0 0 0 2px var(--link); }
.tema-opt input:focus-visible + .tema-card { outline: 3px solid var(--link); outline-offset: 2px; }
.tema-name { font-weight: 700; margin-top: 8px; }
.tema-note { font-size: .8rem; color: var(--tinta-2); }
.tema-prev { display: block; height: 72px; border-radius: 10px; overflow: hidden; background: var(--latar); border: 1px solid var(--garis); }
.tp-bar { display: block; height: 20px; background: var(--hero-bg); }
.tp-body { display: flex; align-items: center; gap: 8px; padding: 10px; }
.tp-btn { width: 44px; height: 16px; border-radius: 8px; background: var(--aksen); }
.tp-chip { width: 16px; height: 16px; border-radius: 50%; background: var(--muda); border: 2px solid var(--aksen); }

/* ============ Ponsel ============ */
@media (max-width: 640px) {
  .top-logo { height: 40px; }
  .wrap { padding: 16px 14px 8px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 14px; }
  .toolbar h1 { font-size: 1.35rem; }
  .search { flex: 1 1 auto; min-width: 0; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .card { min-height: 80px; padding: 12px; gap: 12px; border-radius: 18px; }
  .adm-main { padding: 16px 12px 60px; }
  .adm-head { align-items: stretch; }
  .adm-actions .btn { flex: 1 1 auto; }
  .item-main { flex: 1 1 100%; }
  .item-side { flex: 1 1 100%; padding-top: 10px; border-top: 1px solid var(--garis); }
  .item-act { margin-left: auto; }
  .adm-user { display: none; }
  .form input.short { max-width: none; }
  .form-actions .btn { flex: 1 1 auto; }
}
@media (hover: none) {
  .card:hover { transform: none; box-shadow: var(--shadow-1); border-color: transparent; }
  .card:hover .card-go { background: var(--muda); color: var(--link); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
