/* ============================================================================
   EDC Dashboard - Design System (Phase 2)
   Style: Clean minimalist, banking-trust palette.
   Inspiration: Stripe / Linear / Brex dashboards.
   ============================================================================ */

:root {
  /* Brand */
  --color-navy:        #0F2952;
  --color-navy-dark:   #0A1D3F;
  --color-royal:       #2563EB;
  --color-royal-hover: #1D4ED8;
  --color-sky:         #DBEAFE;
  --color-sky-deep:    #93C5FD;

  /* Surface */
  --bg-canvas:         #F8FAFC;
  --bg-card:           #FFFFFF;
  --bg-subtle:         #F1F5F9;
  --bg-hover:          #EFF6FF;
  --border-soft:       #E2E8F0;
  --border-mid:        #CBD5E1;

  /* Text */
  --text-primary:      #0F172A;
  --text-secondary:    #475569;
  --text-muted:        #94A3B8;
  --text-inverse:      #FFFFFF;

  /* Status (soft-tuned) */
  --status-ot:         #10B981;
  --status-ot-bg:      #D1FAE5;
  --status-ot-border:  #6EE7B7;
  --status-ar:         #F59E0B;
  --status-ar-bg:      #FEF3C7;
  --status-ar-border:  #FCD34D;
  --status-oft:        #EF4444;
  --status-oft-bg:     #FEE2E2;
  --status-oft-border: #FCA5A5;
  --status-inact:      #94A3B8;
  --status-inact-bg:   #F1F5F9;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(15, 41, 82, 0.04);
  --shadow-md:  0 4px 12px rgba(15, 41, 82, 0.06);
  --shadow-lg:  0 12px 32px rgba(15, 41, 82, 0.08);

  /* Radius */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-pill: 999px;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-12: 48px;

  /* Sidebar width */
  --sidebar-w: 240px;
  --topbar-h:  64px;
}

/* ============================================================================
   Reset & base
   ============================================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-royal); text-decoration: none; }
a:hover { color: var(--color-royal-hover); }

/* ============================================================================
   Typography
   ============================================================================ */
h1 { font-size: 24px; font-weight: 700; color: var(--text-primary); }
h2 { font-size: 20px; font-weight: 600; color: var(--text-primary); }
h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.caption { font-size: 13px; color: var(--text-muted); }
.muted   { color: var(--text-muted); }
.num     { font-variant-numeric: tabular-nums; }

/* ============================================================================
   Layout shell (sidebar + topbar + content)
   ============================================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  min-height: 100vh;
}

.sidebar {
  background: var(--color-navy);
  color: var(--text-inverse);
  padding: var(--space-6) var(--space-3);
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.sidebar .brand {
  font-size: 16px; font-weight: 700;
  padding: 0 var(--space-3) var(--space-6);
  display: flex; align-items: center; gap: var(--space-3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: var(--space-4);
}
.sidebar .brand .logo {
  width: 32px; height: 32px;
  background: var(--color-royal);
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800;
}

.sidebar .nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.7);
  font-size: 14px; font-weight: 500;
  margin-bottom: var(--space-1);
  transition: all 200ms ease;
  cursor: pointer;
  position: relative;
}
.sidebar .nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-inverse);
}
.sidebar .nav-item.active {
  background: var(--color-royal);
  color: var(--text-inverse);
}
.sidebar .nav-item.active::before {
  content: ""; position: absolute;
  left: -12px; top: 8px; bottom: 8px; width: 4px;
  background: var(--color-sky); border-radius: 4px;
}
.sidebar .nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar .nav-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: rgba(255,255,255,0.4);
  padding: var(--space-4) var(--space-4) var(--space-2);
}

.sidebar .user-info {
  margin-top: auto;
  padding: var(--space-4);
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-md);
  display: flex; align-items: center; gap: var(--space-3);
}
.sidebar .user-info .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--color-royal);
  display: grid; place-items: center;
  font-weight: 600; font-size: 14px;
}
.sidebar .user-info .name  { font-weight: 600; font-size: 13px; }
.sidebar .user-info .role  { font-size: 11px; color: rgba(255,255,255,0.5); }

.main {
  display: flex; flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
  padding: 0 var(--space-8);
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar .breadcrumb { font-size: 13px; color: var(--text-muted); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8);
  max-width: 1440px;
  width: 100%;
}

/* ============================================================================
   Cards
   ============================================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.card-subtitle {
  font-size: 12px; color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: all 200ms ease;
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-card .label {
  font-size: 12px; color: var(--text-muted);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}
.kpi-card .value {
  font-size: 28px; font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-card .delta {
  font-size: 12px; font-weight: 500;
  margin-top: var(--space-1);
}
.kpi-card .delta.positive { color: var(--status-ot); }
.kpi-card .delta.negative { color: var(--status-oft); }

/* KPI grid layouts */
.kpi-grid { display: grid; gap: var(--space-4); }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary {
  background: var(--color-royal);
  color: var(--text-inverse);
}
.btn-primary:hover { background: var(--color-royal-hover); color: var(--text-inverse); }
.btn-secondary {
  background: var(--bg-card);
  color: var(--color-navy);
  border-color: var(--border-mid);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--color-royal); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-danger {
  background: var(--status-oft);
  color: var(--text-inverse);
}
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: 12px; }
.btn-lg { padding: var(--space-3) var(--space-5); font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================================
   Status badges (pill-shaped)
   ============================================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.badge-ot   { background: var(--status-ot-bg);    color: var(--status-ot); }
.badge-ar   { background: var(--status-ar-bg);    color: #B45309; }
.badge-oft  { background: var(--status-oft-bg);   color: #B91C1C; }
.badge-inact{ background: var(--status-inact-bg); color: var(--status-inact); }
.badge-info { background: var(--color-sky);       color: var(--color-navy); }
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}

/* ============================================================================
   Tables
   ============================================================================ */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  background: var(--bg-subtle);
  font-weight: 600; text-align: left;
  padding: var(--space-3) var(--space-4);
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }
.table .num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.table .center-cell { text-align: center; }

/* Sparkline cell */
.spark-cell svg { display: block; }

/* ============================================================================
   Filter bar
   ============================================================================ */
.filter-bar {
  display: flex; gap: var(--space-3); flex-wrap: wrap;
  background: var(--bg-card);
  padding: var(--space-4); border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  margin-bottom: var(--space-4);
}
.filter-bar .filter-item { display: flex; flex-direction: column; gap: 4px; }
.filter-bar label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.input, .select {
  padding: 8px 12px; border: 1px solid var(--border-mid);
  border-radius: var(--radius-md); background: var(--bg-card);
  font-size: 13px; font-family: inherit;
  min-width: 160px;
  transition: border 150ms ease;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--color-royal);
  box-shadow: 0 0 0 3px var(--color-sky);
}
.input.search { background-image: none; padding-left: 32px; }

/* ============================================================================
   Tabs
   ============================================================================ */
.tabs {
  display: flex; gap: var(--space-1);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: var(--space-6);
}
.tab {
  padding: var(--space-3) var(--space-5);
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 500; font-size: 14px;
  cursor: pointer;
  transition: all 150ms ease;
  background: none; border-left: none; border-right: none; border-top: none;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--color-royal);
  border-bottom-color: var(--color-royal);
  font-weight: 600;
}

/* ============================================================================
   Calendar UI
   ============================================================================ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  background: var(--bg-card);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
}
.calendar-grid .weekday-header {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-2);
}
.cal-cell {
  aspect-ratio: 1;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex; flex-direction: column;
  position: relative;
  cursor: pointer;
  transition: all 200ms ease;
  min-height: 100px;
  background: var(--bg-card);
}
.cal-cell:hover { transform: scale(1.02); box-shadow: var(--shadow-md); }
.cal-cell .day-num {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
}
.cal-cell .stats {
  margin-top: auto;
  font-size: 11px; color: var(--text-muted);
  line-height: 1.4;
}
.cal-cell .stats .sv { font-weight: 600; color: var(--text-secondary); }
.cal-cell.empty { border: none; background: transparent; cursor: default; }
.cal-cell.empty:hover { transform: none; box-shadow: none; }

.cal-cell.uploaded { background: #F0FDF4; border-color: var(--status-ot-border); }
.cal-cell.uploaded::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--status-ot); border-radius: 4px 4px 0 0;
}
.cal-cell.missing  { background: var(--bg-subtle); border-color: var(--border-mid); }
.cal-cell.future   {
  background: var(--bg-subtle); border-style: dashed; cursor: not-allowed;
  opacity: 0.6;
}
.cal-cell.future:hover { transform: none; box-shadow: none; }
.cal-cell.today    { border: 2px solid var(--color-royal); background: var(--color-sky); }
.cal-cell.today::before {
  content: "Hari Ini"; position: absolute; top: 8px; right: 8px;
  font-size: 9px; font-weight: 700;
  background: var(--color-royal); color: white;
  padding: 2px 6px; border-radius: var(--radius-pill);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cal-cell.dragover {
  border: 2px solid var(--color-royal); background: var(--color-sky);
  transform: scale(1.05);
}

/* ============================================================================
   Modal
   ============================================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 41, 82, 0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  max-width: 560px; width: 90%;
  max-height: 80vh; overflow-y: auto;
}
.modal-large { max-width: 800px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: var(--space-4); margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-soft);
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: var(--radius-md); font-size: 20px;
  color: var(--text-muted);
}
.modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--space-2);
  margin-top: var(--space-6); padding-top: var(--space-4);
  border-top: 1px solid var(--border-soft);
}

/* Form fields inside modal */
.form-group { margin-bottom: var(--space-4); }
.form-group label {
  display: block;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: var(--space-1); text-transform: uppercase; letter-spacing: 0.04em;
}
.form-group .input { width: 100%; min-width: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

/* ============================================================================
   Login page (centered card)
   ============================================================================ */
.login-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-royal) 100%);
  padding: var(--space-4);
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.login-card .brand {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-2); margin-bottom: var(--space-6);
}
.login-card .brand .logo {
  width: 56px; height: 56px;
  background: var(--color-royal); color: white;
  border-radius: var(--radius-lg);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800;
}
.login-card .brand h1 { font-size: 20px; }
.login-card .brand p { font-size: 13px; color: var(--text-muted); }

/* ============================================================================
   Drop zone (upload)
   ============================================================================ */
.dropzone {
  border: 2px dashed var(--border-mid);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  text-align: center;
  background: var(--bg-subtle);
  transition: all 200ms ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--color-royal); background: var(--color-sky);
}
.dropzone .icon { font-size: 32px; color: var(--text-muted); margin-bottom: var(--space-2); }
.dropzone h3 { font-size: 14px; font-weight: 600; margin-bottom: var(--space-1); }
.dropzone p { font-size: 12px; color: var(--text-muted); }
.dropzone input[type=file] { display: none; }

/* ============================================================================
   Utility classes
   ============================================================================ */
.row { display: flex; gap: var(--space-3); align-items: center; }
.col { display: flex; flex-direction: column; gap: var(--space-3); }
.gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); } .gap-6 { gap: var(--space-6); }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); } .mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); } .mb-8 { margin-bottom: var(--space-8); }
.flex-1 { flex: 1; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-detail { display: grid; grid-template-columns: 3fr 2fr; gap: var(--space-6); }

/* Flash messages */
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: 13px;
}
.flash-success { background: var(--status-ot-bg); color: var(--status-ot); border: 1px solid var(--status-ot-border); }
.flash-error   { background: var(--status-oft-bg); color: #B91C1C; border: 1px solid var(--status-oft-border); }
.flash-info    { background: var(--color-sky); color: var(--color-navy); border: 1px solid var(--color-sky-deep); }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 0%, var(--bg-hover) 50%, var(--bg-subtle) 100%);
  background-size: 200% 100%; animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Progress bar (inline) */
.progress {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress .fill {
  height: 100%;
  background: var(--color-royal);
  transition: width 300ms ease;
}
.progress .fill.warn { background: var(--status-ar); }
.progress .fill.danger { background: var(--status-oft); }

/* Page header */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-6);
}
.page-header .actions { display: flex; gap: var(--space-2); }

/* Responsive — desktop-first, 1280px+ optimized */
@media (max-width: 1024px) {
  .kpi-grid.cols-5, .kpi-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-detail { grid-template-columns: 1fr; }
}
