* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Arial, sans-serif;
  background: #f6f9ff;
  color: #0b2447;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #0E65B7;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

h1 {
  font-size: 18px;
  margin: 0;
}

main {
  max-width: 840px;
  margin: 16px auto;
  padding: 0 12px;
}

.card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .06);
  padding: 16px 16px 20px;
}

.hidden {
  display: none;
}

label {
  display: block;
  margin: 10px 0 6px;
  font-weight: 600;
  font-size: 14px;
}

input {
  width: 100%;
  padding: 12px;
  border: 1px solid #d6e0ff;
  border-radius: 10px;
  outline: none;
}

input:focus {
  border-color: #0E65B7;
  box-shadow: 0 0 0 3px rgba(14, 101, 183, .15);
}

.primary {
  background: #0E65B7;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
}

.primary:disabled {
  opacity: .6;
}

.action {
  display: block;
  width: 100%;
  margin: 14px 0 8px;
  font-size: 18px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.between {
  justify-content: space-between;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0;
}

.stat {
  background: #f0f6ff;
  border: 1px solid #e1ecff;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat .label {
  font-size: 12px;
  color: #446;
}

.stat .val {
  font-size: 22px;
  font-weight: 800;
  color: #0E65B7;
}

.timeblock {
  text-align: right;
}

.time {
  font-size: 22px;
  font-weight: 800;
}

.date {
  font-size: 12px;
  color: #335;
}

.hello {
  font-size: 14px;
  color: #335;
}

.name {
  font-size: 18px;
  font-weight: 700;
}

footer {
  max-width: 840px;
  margin: 16px auto;
  padding: 0 12px 20px;
  color: #667;
}

.link {
  background: transparent;
  border: none;
  color: #0E65B7;
  padding: 10px 0;
  font-weight: 600;
  cursor: pointer;
}

.link.danger {
  color: #b71c1c;
}

.muted {
  color: #657;
  opacity: .9;
}

.tiny {
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  z-index: 3;
}

.badge {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.badge.offline {
  background: #b71c1c;
}

/* --- iOS safe-area (notch) --- */
:root{
  --safe-top:  env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Fallback iOS lawas (pakai constant()) */
@supports (padding: constant(safe-area-inset-top)) {
  :root{
    --safe-top:  constant(safe-area-inset-top);
    --safe-left: constant(safe-area-inset-left);
    --safe-right: constant(safe-area-inset-right);
  }
}

/* Header menyesuaikan status bar */
header{
  padding-top: calc(12px + var(--safe-top));
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  min-height: calc(48px + var(--safe-top));
}

/* Opsional: konten juga aman dari sisi kiri/kanan notch */
main{
  padding-left: calc(12px + var(--safe-left));
  padding-right: calc(12px + var(--safe-right));
}

/* ========== MODAL (native + fallback iOS PWA) ========== */
/* Native <dialog> (untuk non-iOS) */
.modal { 
  width: min(720px, 92vw);
  border: none; 
  border-radius: 12px; 
  padding: 0;
}
.modal::backdrop { background: rgba(0,0,0,.35); }

/* Fallback (pakai .open di iOS PWA & browser lama) */
.modal { display: none; }             /* disembunyikan default */
.modal.open {
  display: block;
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  width: min(720px, 92vw);
  max-height: 70vh;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  z-index: 10001;
}
.modal .modal-body {
  padding: 12px 14px;
  max-height: 60vh; 
  overflow: auto;
  -webkit-overflow-scrolling: touch; /* iOS momentum */
}

/* Header & Footer (dipakai baik native maupun fallback) */
.modal-header, .modal-footer {
  padding: 10px 14px; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  border-bottom: 1px solid #eee;
}
.modal-footer { border-top: 1px solid #eee; border-bottom: none; }
.modal .close { 
  background: transparent; 
  border: none; 
  font-size: 18px; 
  cursor: pointer; 
}

/* Backdrop fallback (untuk iOS PWA) */
.modal-backdrop {
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,.35); 
  z-index: 10000; 
  pointer-events: auto;
}

/* Tahan scroll body saat modal terbuka (fallback) */
.no-scroll { overflow: hidden; }

/* Tabel di dalam modal */
.table-wrap { width: 100%; overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { 
  border-bottom: 1px solid #eee; 
  padding: 8px; 
  text-align: left; 
  font-size: 14px; 
}
.table tbody tr:hover { background: #fafafa; }

/* Link & tombol sekunder (single source of truth) */
.link { 
  background: none; 
  border: none; 
  color: #0E65B7; 
  cursor: pointer; 
  padding: 0; 
  font-weight: 600;
}
.link.danger { color: #b71c1c; }
.secondary { 
  background: #f3f5f8; 
  border: 1px solid #e6eaef; 
  padding: 8px 12px; 
  border-radius: 8px; 
  cursor: pointer; 
}
.subactions{
  display: flex;
  justify-content: center;     /* center horizontal */
  margin-top: 6px;
}

.subaction{
  appearance: none;
  border: 1px solid #e1ecff;
  background: #f7fbff;
  color: #0E65B7;
  padding: 10px 14px;
  border-radius: 999px;        /* pill */
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .05s ease, background .2s ease, box-shadow .2s ease;
  box-shadow: 0 2px 10px rgba(14,101,183,.08);
}
.subaction:hover{ background:#eef6ff; }
.subaction:active{ transform: translateY(1px); }
.subaction:disabled{ opacity:.6; cursor: default; }

