:root {
  --green-900: #064e3b;
  --green-800: #065f46;
  --green-700: #047857;
  --green-600: #059669;
  --green-500: #10b981;
  --green-400: #34d399;
  --green-100: #d1fae5;
  --green-50:  #ecfdf5;
  --ink:    #1a2e26;
  --muted:  #5a7a6b;
  --line:   #d1fae5;
  --white:  #ffffff;
  --danger: #dc2626;
  --warning:#d97706;
  --info:   #0284c7;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(6,78,59,0.08);
  --shadow-md: 0 4px 16px rgba(6,78,59,0.12);
  --sidebar-w: 240px;
  --sidebar-w-col: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, sans-serif;
  background: var(--green-50);
  color: var(--ink);
}

/* ===== LAYOUT ===== */
.app { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--green-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width 0.22s ease, transform 0.25s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.sidebar-logo {
  width: 38px; height: 38px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
  flex-shrink: 0;
}

.sidebar-title-wrap { white-space: nowrap; }
.sidebar-title { font-size: 16px; font-weight: 800; letter-spacing: .03em; }
.sidebar-sub   { font-size: 10.5px; color: rgba(255,255,255,0.55); }

.sidebar-section {
  padding: 14px 16px 5px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
}

.sidebar-nav {
  list-style: none;
  padding: 4px 10px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: var(--green-600); color: #fff; }
.sidebar-nav a i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.10);
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  line-height: 1.5;
  white-space: nowrap;
}

/* Collapsed */
.sidebar.collapsed { width: var(--sidebar-w-col); }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 18px 0; }
.sidebar.collapsed .sidebar-title-wrap,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-nav a span,
.sidebar.collapsed .sidebar-foot { display: none; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sidebar-nav a i { font-size: 17px; }

/* ===== MAIN ===== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.22s ease;
}

.main.collapsed { margin-left: var(--sidebar-w-col); }

/* ===== TOPBAR ===== */
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.btn-toggle {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  transition: background .12s;
}
.btn-toggle:hover { background: var(--green-50); }

.topbar-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.topbar-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }

.topbar-user  { display: flex; align-items: center; gap: 10px; }
.user-info    { text-align: right; line-height: 1.25; }
.user-name    { font-size: 13px; font-weight: 600; color: var(--ink); }
.user-role    { font-size: 11.5px; color: var(--muted); }
.user-avatar  {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

/* ===== CONTENT ===== */
.content { padding: 22px 24px 50px; flex: 1; }

/* ===== GRID ===== */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 3fr 2fr; }
.grid-2e { grid-template-columns: 1fr 1fr; }

/* ===== CARD ===== */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 0;
}
.card-head h3 { font-size: 14.5px; font-weight: 700; margin: 0; color: var(--ink); }

/* ===== STAT CARDS ===== */
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--ink); margin-top: 5px; }
.stat-delta { font-size: 11.5px; margin-top: 4px; color: var(--muted); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}

.ic-green  { background: var(--green-100); color: var(--green-700); }
.ic-red    { background: #fee2e2; color: #dc2626; }
.ic-amber  { background: #fef3c7; color: #b45309; }
.ic-blue   { background: #dbeafe; color: #1d4ed8; }

/* ===== RESULT BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px;
  border-radius: 100px;
  font-size: 12px; font-weight: 600;
}
.badge-normal    { background: var(--green-100); color: var(--green-700); }
.badge-perforasi { background: #fee2e2; color: #dc2626; }
.badge-gray      { background: #f1f5f9; color: var(--muted); }
.badge-amber     { background: #fef3c7; color: #b45309; }
.badge-blue      { background: #dbeafe; color: #1d4ed8; }

/* ===== TABLE ===== */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; padding: 11px 14px;
  background: var(--green-50); color: var(--muted);
  font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--line);
}
table.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}
table.data-table tbody tr:hover { background: var(--green-50); }
table.data-table tbody tr:last-child td { border-bottom: none; }

.thumb {
  width: 54px; height: 54px;
  border-radius: 8px; object-fit: cover;
  border: 1px solid var(--line); cursor: pointer;
}
.thumb-pair { display: flex; gap: 4px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: 8px; font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: filter .12s, background .12s;
  text-decoration: none;
}
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { background: var(--green-50); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 11px 0; }
.btn-danger { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink); margin-bottom: 5px;
}
.form-input, .form-select, textarea.form-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13.5px; font-family: inherit;
  color: var(--ink); background: #fff;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--green-500);
  box-shadow: 0 0 0 3px var(--green-100);
}
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; background: #fff; width: 260px;
}
.search-box input { border: none; outline: none; font-size: 13.5px; width: 100%; }
.search-box i { color: var(--muted); }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--green-900) 0%, var(--green-700) 60%, var(--green-500) 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  width: 100%; max-width: 860px;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
  box-shadow: 0 30px 60px rgba(6,50,35,0.30);
}

.login-brand {
  background: var(--green-800);
  padding: 40px 28px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 12px;
  color: #fff;
}

.login-brand-logo {
  width: 80px; height: 80px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
}

.login-brand-name {
  font-size: 28px; font-weight: 800;
  letter-spacing: .04em;
  color: #fff;
}

.login-brand-tagline {
  font-size: 12px; line-height: 1.5;
  color: rgba(255,255,255,0.75);
}

.login-brand-meta {
  font-size: 11px; color: rgba(255,255,255,0.5);
  margin-top: 4px;
}

.login-brand-chips {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; margin-top: 8px;
}

.login-brand-chips span {
  padding: 4px 10px;
  border-radius: 100px;
  background: rgba(255,255,255,0.12);
  font-size: 11px; color: rgba(255,255,255,0.85);
  display: flex; align-items: center; gap: 5px;
}

.login-form-side {
  padding: 40px 36px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-form-side h3 { font-size: 20px; margin: 0 0 4px; }
.login-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 22px; }

.role-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px; padding: 3px;
  margin-bottom: 18px;
  background: var(--green-50);
}
.role-toggle button {
  flex: 1; padding: 8px 0; border: none;
  background: transparent; border-radius: 7px;
  font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.role-toggle button.active {
  background: #fff; color: var(--green-700);
  box-shadow: var(--shadow-sm);
}

.login-note {
  margin-top: 14px; font-size: 12px; color: var(--muted);
  background: var(--green-50); border-radius: 8px;
  padding: 9px 12px; display: flex; gap: 8px;
}
.login-note i { color: var(--green-600); margin-top: 1px; }

.login-demo {
  margin-top: 14px; font-size: 11.5px; color: var(--muted);
  background: #f8fafc; border-radius: 8px;
  padding: 9px 11px;
}

.error-text { color: var(--danger); font-size: 12.5px; margin-top: 8px; display: none; }

/* ===== MISC ===== */
.page-head {
  display: flex; align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-head h2 { font-size: 20px; margin: 0; color: var(--ink); }
.page-head p { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

.section-label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin: 0 0 12px;
}

.tag-strip { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tag-chip {
  padding: 6px 14px; border-radius: 100px;
  border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer; background: #fff; color: var(--muted);
}
.tag-chip.active { background: var(--green-600); border-color: var(--green-600); color: #fff; }

.hidden { display: none !important; }

/* ===== PROGRESS BAR (untuk % luas perforasi) ===== */
.progress-wrap { background: #f1f5f9; border-radius: 100px; height: 8px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 100px; background: #dc2626; transition: width .4s; }
.progress-bar.normal { background: var(--green-500); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6,78,59,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-box {
  background: #fff; border-radius: 12px;
  width: 100%; max-width: 500px; max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 30px 60px rgba(6,50,35,0.25);
}
.modal-box.wide { max-width: 680px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-head .close-x {
  cursor: pointer; color: var(--muted); font-size: 17px;
  background: none; border: none;
}
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ===== MONITORING CHART ===== */
.visit-timeline { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.visit-pill {
  padding: 5px 13px; border-radius: 100px;
  border: 1.5px solid var(--line);
  font-size: 12px; font-weight: 600;
  cursor: pointer; background: #fff; color: var(--muted);
}
.visit-pill.normal    { border-color: var(--green-500); color: var(--green-700); }
.visit-pill.perforasi { border-color: #dc2626; color: #dc2626; }

/* ===== PRINT ===== */
.print-only { display: none; }

@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  .main { margin-left: 0 !important; }
  body { background: #fff; }
  .print-report-table thead { display: table-header-group; }
  .print-report-table tr { break-inside: avoid; page-break-inside: avoid; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed .sidebar-title-wrap,
  .sidebar.collapsed .sidebar-section,
  .sidebar.collapsed .sidebar-nav a span,
  .sidebar.collapsed .sidebar-foot { display: revert; }
  .sidebar.collapsed .sidebar-brand { justify-content: flex-start; padding: 18px 16px; }
  .sidebar.collapsed .sidebar-nav a { justify-content: flex-start; padding: 10px 12px; }
  .main, .main.collapsed { margin-left: 0 !important; }
  .login-card { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}
