:root {
  --header: #0d3d3a;
  --header-text: #e8f2f1;
  --sidebar: #0a3330;
  --sidebar-w: 240px;
  --bg: #eef2f6;
  --card: #ffffff;
  --text: #16323a;
  --muted: #6b7c86;
  --teal: #2aa3a0;
  --line: #e4e9ee;
  --mint: #d4f0e8;
  --cream: #f7eec7;
  --lavender: #ddd6f5;
  --blush: #f8d5d5;
  --shadow: 0 8px 24px rgba(16, 40, 48, 0.06);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #0d3d3a 0%, #1a5c57 40%, #eef2f6 40%);
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(13, 61, 58, 0.18);
}

.login-card.wide {
  width: min(480px, 100%);
}

.auth-notice {
  background: #eaf7f0;
  border: 1px solid #c5e6d4;
  color: #0d5c40;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 18px;
  text-align: left;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f0f4f5;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tab {
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #5a7078;
  cursor: pointer;
}

.auth-tab.active {
  background: #fff;
  color: var(--header);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.auth-panel { display: none; }
.auth-panel.active { display: block; }

.login-card .btn-secondary {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #c5d5d3;
  border-radius: 10px;
  background: #fff;
  color: var(--header);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.login-success {
  min-height: 18px;
  color: #0f7a4a;
  font-size: 12px;
  margin-top: 8px;
}

.link-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--teal);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:hover { color: var(--header); }

.otp-code-display {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--header);
  text-align: center;
  margin: 8px 0 4px;
  font-family: ui-monospace, Consolas, monospace;
}

.login-card .logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--header);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 28px;
  margin-bottom: 16px;
}

.login-card h1 { margin: 0 0 6px; font-size: 20px; color: var(--header); }
.login-card p { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin: 10px 0 6px;
  color: #445;
}
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d8e0e6;
  border-radius: 10px;
  font: inherit;
  background: #fafbfc;
}
.login-card input:focus {
  outline: 2px solid #2aa3a044;
  border-color: var(--teal);
}
.login-card button {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--header);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { filter: brightness(1.08); }
.login-error { min-height: 18px; color: #c0392b; font-size: 12px; margin-top: 8px; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ===== APP SHELL + SIDEBAR ===== */
.app { display: none; min-height: 100vh; }
.app.show { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: #dce8e6;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}
.sidebar-brand .mark {
  font-size: 32px;
  line-height: 1;
  margin-bottom: 8px;
}
.sidebar-brand h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.35;
  color: #fff;
}
.sidebar-brand span {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: #8fbbb6;
}

.sidebar nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #b7d4d0;
  font: inherit;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
}
.nav-link .ico {
  width: 20px;
  text-align: center;
  opacity: 0.9;
  font-size: 14px;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-link.active {
  background: rgba(42, 163, 160, 0.28);
  color: #fff;
  font-weight: 600;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.logout-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 9px;
  padding: 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.14); }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .crumb {
  font-size: 16px;
  font-weight: 600;
  color: var(--header);
}
.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.topbar .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--mint);
  display: grid;
  place-items: center;
  font-size: 16px;
}
.topbar .user-chip small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  color: var(--header);
  margin-right: 10px;
}

.page {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px 36px;
  flex: 1;
}

/* Welcome strip */
.welcome {
  background: var(--card);
  border-radius: 14px;
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.welcome h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  color: #4a6a72;
}
.welcome .date {
  color: #5a9aa0;
  font-size: 15px;
  font-weight: 500;
}

/* Stat cards */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat {
  border-radius: var(--radius);
  padding: 22px 24px;
  min-height: 110px;
  box-shadow: var(--shadow);
}
.stat .label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #3d5a62;
  margin-bottom: 14px;
  text-transform: uppercase;
}
.stat .value {
  font-size: 32px;
  font-weight: 700;
  color: #122b32;
  line-height: 1.1;
}
.stat.mint { background: var(--mint); }
.stat.cream { background: var(--cream); }
.stat.lavender { background: var(--lavender); }
.stat.blush { background: var(--blush); }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.row.three { grid-template-columns: 1fr 1fr 1fr; }

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  min-height: 200px;
}
.panel h3 {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 600;
  color: #1a3a42;
}

.chart-box { height: 180px; position: relative; }
.chart-box svg { width: 100%; height: 100%; display: block; }

.list-item {
  padding: 10px 0;
  color: #5a7078;
  font-size: 14px;
}
.list-item + .list-item { border-top: 1px solid #f0f3f5; }

.activity {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  color: #5a7078;
  font-size: 14px;
}
.activity + .activity { border-top: 1px solid #f0f3f5; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a6f78;
  margin-top: 7px;
  flex: none;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mini {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.mini span { color: var(--muted); font-size: 11px; }
.mini b { display: block; font-size: 18px; margin-top: 4px; }

/* Module pages */
.module-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.module-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--header);
}
.module-head p { margin: 0; color: var(--muted); font-size: 14px; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--header);
  color: #fff;
}
.btn.secondary {
  background: #fff;
  color: var(--header);
  border: 1px solid #c5d5d3;
}
.btn.danger { background: #c0392b; color: #fff; }
.btn.sm { padding: 7px 11px; font-size: 13px; font-weight: 500; }

.table-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

/* Galeri */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.gallery-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gallery-thumb {
  height: 160px;
  background: #e8eef0 center/cover no-repeat;
  border: 0;
  padding: 0;
  width: 100%;
  display: block;
}
.gallery-thumb-btn {
  cursor: zoom-in;
}
.gallery-thumb-btn:hover {
  filter: brightness(0.92);
}
.gallery-body {
  padding: 14px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.gallery-body h4 {
  margin: 4px 0 6px;
  font-size: 15px;
  color: var(--header);
}
.gallery-body p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
}
.gallery-cat {
  font-size: 11px;
  font-weight: 600;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.gallery-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.gallery-folder {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gallery-folder:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(16, 40, 48, 0.12);
}

.upload-zone {
  background: linear-gradient(180deg, #f3faf7 0%, #fff 100%);
  border: 2px dashed #2aa3a0;
  border-radius: var(--radius);
  padding: 28px 20px;
  margin-bottom: 8px;
  cursor: pointer;
}
.upload-zone.dragover {
  background: #e5f7f2;
  border-color: var(--header);
}
.upload-zone-inner {
  text-align: center;
  color: var(--text);
}
.upload-zone-inner p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Lightbox / zoom galeri */
.gallery-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
}
.gallery-lightbox.show {
  display: block;
}
.gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 20, 24, 0.88);
  cursor: pointer;
}
.gallery-lightbox-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px 72px;
  pointer-events: none;
}
.gallery-lightbox-stage img {
  max-width: min(92vw, 1200px);
  max-height: 78vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease;
  pointer-events: auto;
  transform-origin: center center;
  background: #111;
}
.gallery-lightbox-close {
  position: absolute;
  top: 14px;
  right: 18px;
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  line-height: 1;
}
.gallery-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}
.gallery-lightbox-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  pointer-events: auto;
  max-width: 92vw;
  font-size: 14px;
}
.gallery-lightbox-actions {
  display: flex;
  gap: 6px;
}
.gallery-lightbox-actions .btn {
  min-width: 40px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
th, td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
th {
  background: #f7fafb;
  color: #4a636a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
tr:last-child td { border-bottom: 0; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok { background: #d8f3e6; color: #0f7a4a; }
.badge.warn { background: #fff0d6; color: #b07600; }
.badge.new { background: #e3eefc; color: #1f6fc2; }
.badge.bad { background: #fde2e2; color: #b53a3a; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Report cards */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.report-card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.report-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.report-card b {
  font-size: 22px;
  color: var(--header);
}

/* Settings form */
.settings-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  max-width: 640px;
}
.settings-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin: 12px 0 6px;
}
.settings-form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #d5dde2;
  border-radius: 9px;
  font: inherit;
}
.settings-form .form-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 32, 0.45);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal-backdrop.show { display: grid; }
.modal {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.modal h3 { margin: 0 0 16px; }
.modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin: 10px 0 6px;
}
.modal input,
.modal select,
.modal textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #d5dde2;
  border-radius: 9px;
  font: inherit;
}
.modal textarea { min-height: 80px; resize: vertical; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--header);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  display: none;
  z-index: 60;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  font-size: 14px;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 20px 24px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 25;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .row { grid-template-columns: 1fr; }
  .row.three { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-block; }
  .page { padding: 18px 14px 28px; }
  .stats { grid-template-columns: 1fr; }
  .row.three { grid-template-columns: 1fr; }
  .welcome { flex-direction: column; align-items: flex-start; gap: 8px; }
  .module-head { flex-direction: column; }
}
