:root {
  --bg: #0e1524;
  --panel: #161f31;
  --panel-2: #1c273c;
  --line: #2a3852;
  --text: #e7eefb;
  --muted: #91a3bd;
  --accent: #f7941d;
  --accent-soft: rgba(247, 148, 29, 0.14);
  --green: #37d39b;
  --red: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(247, 148, 29, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

body { min-height: 100vh; }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 120px;
}

/* ---------------------------------------------------------------- header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 20, 34, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(160deg, #ffb347, #f7941d);
  color: #1a1205;
  font-weight: 800;
  letter-spacing: 0.5px;
}

h1 { margin: 0; font-size: 19px; letter-spacing: 0.2px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.pill {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill-ok { color: var(--green); border-color: rgba(55, 211, 155, 0.35); background: rgba(55, 211, 155, 0.08); }
.pill-warn { color: #ffc46b; border-color: rgba(247, 148, 29, 0.4); background: var(--accent-soft); }
.pill-wait { color: var(--muted); }

/* ---------------------------------------------------------------- setup */

.setup {
  margin-top: 20px;
  padding: 18px 20px;
  border: 1px solid rgba(247, 148, 29, 0.35);
  background: var(--accent-soft);
  border-radius: var(--radius);
}
.setup strong { color: #ffcf8a; }
.setup ol { margin: 10px 0 8px; padding-left: 20px; color: #f0d9b8; }
.setup li { margin: 4px 0; }
.setup .muted { margin: 0; }
.setup code, .mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.setup code { color: #ffe1b3; }

/* --------------------------------------------------------------- upload */

.uploader { margin-top: 24px; }

.drop {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 38px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(28, 39, 60, 0.6), rgba(22, 31, 49, 0.6));
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.drop:hover, .drop:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop.dragging { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}
.drop-title { font-size: 16px; font-weight: 600; }
.drop-sub { color: var(--muted); font-size: 13px; }

.hint { margin: 10px 2px 0; color: var(--muted); font-size: 13px; }
.hint b { color: #d6e2f5; font-weight: 600; }

/* -------------------------------------------------------------- loading */

.loading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.loading p { margin: 2px 0 0; font-size: 13px; }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(247, 148, 29, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- hasil */

.results { display: grid; gap: 18px; margin-top: 22px; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.thumb {
  width: 54px;
  height: 96px;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1220;
  flex: none;
}

.card-title { flex: 1; min-width: 0; }
.card-title h2 { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title .meta { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.card-title .meta b { color: #ffcf8a; font-weight: 600; }

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

select, input[type="date"], .cell {
  background: #0f1828;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13.5px;
}
select:focus, input:focus, .cell:focus { outline: 2px solid rgba(247, 148, 29, 0.5); outline-offset: 1px; border-color: var(--accent); }
select.needs { border-color: var(--red); box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.2); }

.icon-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--red); border-color: rgba(255, 107, 107, 0.5); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; text-align: left; vertical-align: middle; }
thead th {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
tbody tr + tr td { border-top: 1px solid rgba(42, 56, 82, 0.55); }
tbody tr:hover { background: rgba(247, 148, 29, 0.045); }
td.rank { width: 86px; }
td.score { width: 190px; }
td.act { width: 44px; text-align: right; }

.cell { width: 100%; padding: 6px 8px; }
.cell.rank-input { text-align: center; }
.cell.score-input { text-align: right; font-variant-numeric: tabular-nums; }
.cell.bad { border-color: rgba(255, 107, 107, 0.7); }

.self-tag {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(55, 211, 155, 0.14);
  color: var(--green);
  font-size: 10.5px;
  vertical-align: 1px;
  white-space: nowrap;
}

.row-del {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}
.row-del:hover { color: var(--red); background: rgba(255, 107, 107, 0.1); }

.card-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: rgba(15, 24, 40, 0.45);
}

.error-box {
  margin: 14px 16px 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
  border-radius: 10px;
  color: #ffbdbd;
  font-size: 13.5px;
}

.empty-box {
  margin: 14px 16px 16px;
  padding: 12px 14px;
  border: 1px dashed rgba(247, 148, 29, 0.4);
  background: var(--accent-soft);
  border-radius: 10px;
  color: #f3d3a7;
  font-size: 13.5px;
}

/* --------------------------------------------------------------- simpan */

.savebar {
  position: sticky;
  bottom: 16px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(22, 31, 49, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.savebar-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.savebar label { font-size: 13px; color: var(--muted); }

.btn-primary {
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  background: linear-gradient(160deg, #ffb347, #f7941d);
  color: #1c1405;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(247, 148, 29, 0.25);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.55; cursor: progress; box-shadow: none; }

.saved {
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px solid rgba(55, 211, 155, 0.35);
  background: rgba(55, 211, 155, 0.08);
  border-radius: var(--radius);
}
.saved h3 { margin: 0 0 8px; font-size: 15px; color: #9df3d2; }
.saved ul { margin: 0 0 10px; padding-left: 20px; color: #c8f5e5; }
.saved a { color: #ffd28f; }

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .card-head { flex-wrap: wrap; }
  .thumb { width: 44px; height: 78px; }
  td.rank { width: 64px; }
  td.score { width: 130px; }
}
