:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --ink: #1b2233;
  --muted: #6b7489;
  --line: #e3e7f0;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef0ff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --top: #111827;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

[hidden] { display: none !important; }

h2 { font-size: 18px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 12px; }

.muted { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 9px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: #c9cfdd; background: #f8f9fc; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn.light { color: #e5e7eb; border-color: #374151; }
.btn.light:hover { background: #1f2937; color: #fff; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.wide { width: 100%; }

.top {
  background: var(--top);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.meter { flex: 1; min-width: 200px; max-width: 420px; margin-left: auto; }
.meter-text { font-size: 12px; color: #cbd5e1; margin-bottom: 5px; }
.meter-bar { height: 7px; background: #374151; border-radius: 99px; overflow: hidden; }
.meter-bar span { display: block; height: 100%; width: 0; background: #22c55e; border-radius: 99px; transition: width .4s; }
.meter-bar span.warn { background: #f59e0b; }
.meter-bar span.full { background: #ef4444; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #cbd5e1; }

.tabs {
  display: flex;
  gap: 4px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  overflow-x: auto;
}
.tab {
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  padding: 14px 14px 12px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.badge {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 99px;
  font-size: 12px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}

main { max-width: 1120px; margin: 0 auto; padding: 22px 18px 60px; }

.notice { border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; font-size: 14px; }
.notice.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.notice.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px dashed #c8cee0;
  border-radius: 16px;
  background: #fff;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--brand-soft);
  position: relative;
  margin-bottom: 4px;
}
.drop-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 13px;
  width: 14px;
  height: 14px;
  border-left: 3px solid var(--brand);
  border-top: 3px solid var(--brand);
  transform: translateX(-50%) rotate(45deg);
}
.drop-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 16px;
  width: 3px;
  height: 18px;
  background: var(--brand);
  transform: translateX(-50%);
}
.drop-title { font-size: 17px; font-weight: 700; }
.drop-sub { color: var(--muted); font-size: 14px; }

.list-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.thumb, .vthumb {
  position: relative;
  background: #1f2937;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.thumb { width: 128px; aspect-ratio: 16 / 9; }
.thumb img, .vthumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ph { position: absolute; inset: 0; display: block; background: linear-gradient(135deg, #1f2937, #374151); }
.ph::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent rgba(255, 255, 255, .55);
  transform: translate(-40%, -50%);
}
.body { flex: 1; min-width: 0; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: 13px; margin-top: 1px; }
.state { font-size: 13px; margin-top: 5px; }
.state.err { color: var(--err); }
.state.warn { color: var(--warn); }
.bar { height: 6px; background: #e8ebf3; border-radius: 99px; overflow: hidden; margin-top: 7px; }
.bar span { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .3s; }
.bar.busy span {
  width: 35% !important;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
.actions { display: flex; gap: 6px; flex-shrink: 0; }

.empty { color: var(--muted); text-align: center; padding: 26px 0; margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.vcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.vthumb { width: 100%; aspect-ratio: 16 / 9; border-radius: 0; }
.dur {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 6px;
}
.vinfo { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.vactions { display: flex; gap: 8px; margin-top: 8px; }
.vactions .btn.primary { flex: 1; }

.settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.sticky { position: sticky; top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 14px; }
.field > span { font-weight: 600; }
.field > span b { font-weight: 500; color: var(--muted); margin-left: 4px; }
.field input[type="text"], .field input[type="password"], .field select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input[type="text"]:focus, .field input[type="password"]:focus, .field select:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}
.field input[type="range"] { width: 100%; accent-color: var(--brand); }
.field input[type="color"] { width: 64px; height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 3px; background: #fff; }
.field-row { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.field-row .switch { margin-bottom: 9px; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }

.logo-row { display: flex; gap: 14px; align-items: center; }
.logo-box {
  width: 120px;
  height: 80px;
  border-radius: 10px;
  border: 1px dashed #c8cee0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f6f7fb;
  background-image: linear-gradient(45deg, #e9ecf3 25%, transparent 25%), linear-gradient(-45deg, #e9ecf3 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e9ecf3 75%), linear-gradient(-45deg, transparent 75%, #e9ecf3 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  flex-shrink: 0;
  overflow: hidden;
}
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-box span { color: var(--muted); font-size: 12px; text-align: center; padding: 6px; }
.logo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; width: 100%; }

.pos { display: grid; grid-template-columns: repeat(3, 34px); gap: 6px; }
.pos button {
  width: 34px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f6f7fb;
  cursor: pointer;
  position: relative;
}
.pos button::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: #c3c9d8;
  transform: translate(-50%, -50%);
}
.pos button.active { background: var(--brand-soft); border-color: var(--brand); }
.pos button.active::after { background: var(--brand); }

.preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #334155, #0f172a 60%, #1e293b);
}
#previewBg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
#previewLogo { position: absolute; height: auto; max-width: none; }
#previewText { position: absolute; font-family: "DejaVu Sans", Verdana, sans-serif; font-weight: 700; white-space: nowrap; line-height: 1; }
#previewText.shadow { text-shadow: 2px 2px 3px rgba(0, 0, 0, .65); }
#previewText.outline { -webkit-text-stroke: .07em rgba(0, 0, 0, .8); paint-order: stroke fill; }
.preview.portrait { width: min(50%, 220px); aspect-ratio: 9 / 16; margin: 0 auto; }
#previewShape { margin-bottom: 10px; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f6f7fb; align-self: flex-start; }
.seg button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--brand); color: #fff; }
.checks { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.card select { margin-top: 2px; }
.card .btn.wide { margin-top: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  max-width: calc(100% - 32px);
  z-index: 20;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 12px 40px rgba(17, 24, 39, .08);
  margin: 0;
}
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 19px; margin-bottom: 8px; }
.login-box .btn { margin-top: 20px; }
.form-error { color: var(--err); font-size: 14px; margin: 12px 0 0; }

.lp-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.lp-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; }
.lp-num { flex: 0 0 26px; height: 26px; margin-top: 6px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.lp-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.lp-fields input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); font: inherit; font-size: 14px; }
.lp-fields input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.lp-acts { display: flex; flex-direction: column; gap: 4px; }
.lp-acts .btn { min-width: 64px; }
.lp-preview { display: flex; flex-direction: column; align-items: center; margin: 12px 0 14px; padding: 28px 18px; border-radius: 14px; background: #000; text-align: center; }
.lp-logo { display: block; width: 84px; height: 84px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px #000, 0 0 0 3px #ec0377; }
.lp-title { margin-top: 16px; padding-left: .16em; color: #fff; font-size: 17px; font-weight: 800; letter-spacing: .16em; }
.lp-line { width: 22px; height: 2px; margin: 10px auto 18px; border-radius: 2px; background: #ec0377; }
.lp-buttons { width: 100%; max-width: 260px; display: flex; flex-direction: column; gap: 8px; }
.lp-btn { display: block; padding: 10px 14px; border: 1px solid rgba(255, 255, 255, .3); border-radius: 999px; color: #fff; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.lp-btn.kosong { color: rgba(255, 255, 255, .4); }
.lp-open { margin-top: 10px; text-align: center; }

@media (max-width: 860px) {
  .settings { grid-template-columns: 1fr; }
  .card.sticky { position: static; }
}

@media (max-width: 640px) {
  .top { padding: 10px 14px; gap: 10px; }
  .meter { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  .who { margin-left: auto; }
  main { padding: 16px 12px 50px; }
  .item { flex-wrap: wrap; }
  .thumb { width: 100px; }
  .body { flex-basis: calc(100% - 120px); }
  .actions { width: 100%; justify-content: flex-end; }
  .logo-row { flex-direction: column; align-items: flex-start; }
}

.bulk {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.bulk .btn { margin-left: auto; }
.vsel {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: flex;
  padding: 5px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  cursor: pointer;
}
.vsel input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.vcard.picked { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

.tg-card { margin-bottom: 18px; }
.tg-card .card-head { flex-wrap: wrap; }
.tg-intro { margin: 0 0 14px; }
.tg-state { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.tg-state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #c3c9d8; }
.tg-state.good { color: var(--ok); }
.tg-state.good::before { background: var(--ok); }
.tg-state.warn { color: var(--warn); }
.tg-state.warn::before { background: var(--warn); }
.tg-state.bad { color: var(--err); }
.tg-state.bad::before { background: var(--err); }
.tg-pairs { display: flex; flex-direction: column; gap: 10px; }
.tg-none { padding: 14px 0; }
.tg-pair { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fafbfd; }
.tg-pair.off { opacity: .65; }
.tg-route { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.tg-end { overflow-wrap: anywhere; }
.tg-end b { font-weight: 700; }
.tg-to { color: var(--brand); font-weight: 700; }
.tg-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.tg-pair-acts { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.tg-pair-acts .btn { margin-left: auto; }
.tg-add { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding: 14px; border: 1px dashed #c8cee0; border-radius: 10px; }
.tg-side { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tg-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.tg-add input[type="text"] { font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
.tg-add input[type="text"]:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.tg-add .tg-to { font-size: 20px; padding-bottom: 8px; }
.tg-links { color: var(--muted); font-size: 12.5px; margin-top: 3px; overflow-wrap: anywhere; }
.tg-addbtn { align-self: flex-end; }
.tg-auto { margin-top: 14px; }
.tg-sub { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 10px; }
.tg-sub h3 { margin: 0; }
.tg-sub .tg-histbtn { margin-left: auto; align-self: center; }
.tg-items { display: flex; flex-direction: column; gap: 8px; }
.tg-item { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tg-item .tg-item-route { overflow-wrap: anywhere; }
.tg-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.tg-item-side .actions { flex-wrap: wrap; justify-content: flex-end; }
.state.ok { color: var(--ok); }
.state.dim { color: var(--muted); }

.tg-when { white-space: nowrap; }

body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 15; background: rgba(17, 24, 39, .55); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--card); border-radius: var(--radius); width: 100%; max-width: 820px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 14px 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-foot .muted { text-align: center; }
.modal-small { max-width: 540px; }
.dest-info { margin: 0 0 12px; }
.dest-field { display: flex; flex-direction: column; gap: 6px; }
.dest-field input { font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
.dest-field input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
#upDestErr { margin-top: 10px; }

@media (max-width: 640px) {
  .tg-add .tg-to { display: none; }
  .tg-item { flex-direction: column; align-items: stretch; }
  .tg-item .body { flex-basis: auto; }
  .tg-item-side { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
  .tg-item-side .actions { width: auto; justify-content: flex-start; }
  .modal { padding: 0; align-items: stretch; }
  .modal-box { max-width: none; max-height: none; height: 100%; border-radius: 0; }
  .modal-foot .btn { padding: 6px 9px; }
}
