/* Sheet Hub — direktori kartu, tanpa dependensi */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --border: #e7e5e4;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --danger: #b91c1c;
  --chip-bg: #f5f5f4;
  --chip-fg: #44403c;
  --warning-bg: #fef3c7;
  --warning-fg: #92400e;
  --radius: 8px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0c0a09;
  --surface: #171412;
  --surface-2: #201c1a;
  --border: #292524;
  --text: #f5f5f4;
  --muted: #a8a29e;
  --accent: #60a5fa;
  --accent-fg: #0c0a09;
  --danger: #f87171;
  --chip-bg: #292524;
  --chip-fg: #d6d3d1;
  --warning-bg: #422006;
  --warning-fg: #fcd34d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted, .row-note { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 45%, var(--text)));
}
.brand-lg { font-size: 20px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, opacity 150ms;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 88%, black); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13.5px; }

.icon-btn {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.app { min-height: 100vh; min-height: 100dvh; }
.topbar {
  display: flex;
  min-height: 60px;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-menu { position: relative; }
.user-menu summary {
  max-width: 180px;
  overflow: hidden;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 28px rgb(0 0 0 / 0.12);
}
.menu-pop button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.menu-pop button:hover { background: var(--surface-2); }

.main-content { width: min(1280px, 100%); margin: 0 auto; padding: 24px; }
.filter-panel {
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.filter-row { display: flex; align-items: center; gap: 10px; }
.search-field { flex: 1 1 280px; min-width: 180px; }
.search-field input, .select-field select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.search-field input:focus-visible, .select-field select:focus-visible,
.field input:focus-visible, .field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.select-field { width: 160px; }
.category-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  min-height: 32px;
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.is-active {
  border-color: color-mix(in oklab, var(--accent) 50%, var(--border));
  background: color-mix(in oklab, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-weight: 600;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.page-card {
  display: flex;
  min-height: 176px;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.025);
}
.page-card-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-category {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.period-badge {
  flex: none;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}
.page-card-title { margin: 14px 0 10px; font-size: 17px; line-height: 1.35; }
.role-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-size: 12.5px;
}
.page-card-actions { display: flex; justify-content: flex-end; margin-top: auto; padding-top: 14px; }
.empty-state, .error-state {
  margin: 36px auto;
  max-width: 480px;
  padding: 24px;
  text-align: center;
}
.empty-state h1 { margin: 0 0 6px; font-size: 19px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }
.error-state { color: var(--danger); }
.load-more-wrap { display: flex; justify-content: center; padding: 24px 0 8px; }

.skeleton-card { gap: 16px; }
.skeleton {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-short { width: 35%; }
.skeleton-title { width: 75%; height: 19px; }
.skeleton-line { width: 55%; }
.skeleton-button { width: 72px; height: 30px; align-self: flex-end; margin-top: auto; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Admin panel */
.admin { width: min(1280px, 100%); margin: 0 auto; padding: 22px 24px 48px; }
.admin-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.admin-head h1 { margin: 0; font-size: 19px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.tabs button {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tabs button[aria-selected="true"] {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; }
th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
tbody tr + tr td { border-top: 1px solid var(--border); }
td.actions { text-align: right; white-space: nowrap; }
.link { color: var(--accent); word-break: break-all; }
.row-note { font-size: 13px; }
.warning-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 12px;
  white-space: nowrap;
}
.admin-empty { padding: 24px; color: var(--muted); text-align: center; }

/* Modal */
dialog.modal {
  width: min(540px, calc(100vw - 32px));
  max-height: min(90vh, 760px);
  overflow-y: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}
dialog.modal::backdrop { background: rgb(0 0 0 / 0.45); }
.modal form { display: grid; gap: 12px; padding: 18px 20px 20px; }
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.field { display: grid; gap: 4px; }
.field > span:first-child { color: var(--muted); font-size: 13px; }
.field input, .field select {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.checks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.checks input[type="checkbox"] { width: 16px; min-height: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Login and feedback */
.login { display: grid; min-height: 100vh; min-height: 100dvh; place-items: center; padding: 24px; }
.login-card {
  display: grid;
  width: min(380px, 100%);
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.06);
}
.login-card .muted { margin: 0 0 4px; font-size: 13.5px; }
.login-card label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.login-card input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.error { margin: 0; color: var(--danger); font-size: 13.5px; }
.toast {
  position: fixed;
  z-index: 40;
  bottom: 24px;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.16);
  font-size: 14px;
}
.toast[data-kind="error"] { border-color: var(--danger); color: var(--danger); }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; }
  .main-content { padding: 16px 14px 32px; }
  .filter-panel { padding: 12px; }
  .filter-row { flex-wrap: wrap; }
  .search-field { flex: 1 1 100%; }
  .select-field { flex: 1 1 120px; }
  .filter-row > .btn { flex: 1 1 auto; }
  .card-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .page-card { min-height: 160px; }
  .admin { padding: 16px 14px 40px; }
}
@media (min-width: 761px) and (max-width: 1040px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition: none !important; }
}
