/* Mobile-first. No framework: one small sheet, system fonts, dark-aware. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #dfe3ea;
  --text: #12141a;
  --muted: #656d7e;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --datang: #0f8a5f;
  --pulang: #b4530a;
  --danger: #c0392b;
  --ok-bg: #e7f6ee;
  --ok-ink: #0b6b45;
  --err-bg: #fdecea;
  --err-ink: #a02c20;
  --warn-bg: #fdf3e0;
  --warn-ink: #8a5b06;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 30, .06), 0 6px 20px rgba(16, 20, 30, .06);
  --tabbar-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --surface: #181b23;
    --surface-2: #21252f;
    --border: #2c313d;
    --text: #eceef4;
    --muted: #9aa3b6;
    --accent: #7c74ff;
    --accent-ink: #0f1116;
    --datang: #34c98b;
    --pulang: #f0a05a;
    --danger: #ff6f61;
    --ok-bg: #102b21;
    --ok-ink: #6ee0ac;
    --err-bg: #33191a;
    --err-ink: #ff9d92;
    --warn-bg: #322611;
    --warn-ink: #f2c66a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  overscroll-behavior-y: contain;
}

a { color: var(--accent); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.topbar .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

main { padding: 16px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card h2 { font-size: 14px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.right { text-align: right; }
.center { text-align: center; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- the two big buttons ------------------------------------------------- */

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.action-btn {
  appearance: none;
  border: none;
  border-radius: 18px;
  color: #fff;
  padding: 26px 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .02em;
  min-height: 116px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.action-btn small { font-size: 12px; font-weight: 500; opacity: .85; letter-spacing: 0; }
.action-btn:active { transform: scale(.97); }
.action-btn[disabled] { filter: grayscale(.5) brightness(.85); cursor: default; }
.action-btn.datang { background: var(--datang); }
.action-btn.pulang { background: var(--pulang); }

/* --- result / status ----------------------------------------------------- */

.result { border-radius: var(--radius); padding: 14px; border: 1px solid transparent; }
.result.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: currentColor; }
.result.err { background: var(--err-bg); color: var(--err-ink); border-color: currentColor; }
.result.busy { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.result h3 { margin: 0 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
.result p { margin: 0; white-space: pre-wrap; word-break: break-word; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .03em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.badge.err { background: var(--err-bg); color: var(--err-ink); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.badge.run { background: var(--surface-2); color: var(--accent); border-color: transparent; }

/* --- forms --------------------------------------------------------------- */

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 650;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.99); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.slim { width: auto; padding: 8px 14px; font-size: 14px; }

.field + .field { margin-top: 14px; }

.notice { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; }
.notice.err { background: var(--err-bg); color: var(--err-ink); }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }

/* --- lists --------------------------------------------------------------- */

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: none; padding-top: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --- calendar ------------------------------------------------------------ */

.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 6px; }
.cal-head span { text-align: center; font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1.06;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.cal-cell.out { opacity: .32; }
.cal-cell.past { color: var(--muted); background: var(--surface-2); }
.cal-cell.today { border-color: var(--accent); border-width: 2px; }
.cal-cell:active { transform: scale(.96); }

.dots { display: flex; gap: 3px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.datang { background: var(--datang); }
.dot.pulang { background: var(--pulang); }
.dot.failed { background: var(--danger); }
.dot.done { box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 30%, transparent); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 12px; }
.legend .row { gap: 6px; }

/* --- bottom sheet -------------------------------------------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 40;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 41;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateY(102%);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1);
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .28);
}
.sheet.open { transform: translateY(0); }
.sheet .grabber { width: 40px; height: 4px; border-radius: 99px; background: var(--border); margin: 6px auto 14px; }
.sheet h2 { margin: 0 0 2px; font-size: 18px; }

.slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.slot:first-of-type { border-top: none; }
.slot .name { font-weight: 650; }
.slot .meta { font-size: 12px; color: var(--muted); }

/* --- switch -------------------------------------------------------------- */

.switch { position: relative; width: 52px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  transition: background .18s ease;
  pointer-events: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 25px; height: 25px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .18s ease;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(21px); }
.switch input:disabled + .track { opacity: .45; }

/* --- tab bar ------------------------------------------------------------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar a {
  flex: 1;
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a.active { color: var(--accent); }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- auth screens -------------------------------------------------------- */

.auth { max-width: 380px; margin: 0 auto; padding-top: 8vh; }
.auth .logo {
  width: 62px; height: 62px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 27px; font-weight: 700;
  margin: 0 auto 18px;
}
.auth h1 { font-size: 23px; text-align: center; margin: 0 0 6px; }
.auth .lede { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 22px; }

pre.dump {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.steps { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.steps li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.steps li:last-child { border-bottom: none; }
.steps .mark { width: 16px; flex: none; font-weight: 700; }
.steps .mark.ok { color: var(--datang); }
.steps .mark.fail { color: var(--danger); }
.steps .ms { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filters .full { grid-column: 1 / -1; }
