/* ═══ MTS Dashboard — Modern Design System ═══ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 1.5rem 1rem;
  flex-shrink: 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 1.5rem 2rem;
  max-width: 1400px;
}

/* ── Sidebar ── */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 2rem; padding-bottom: 1rem;
  border-bottom: 1px solid #1e293b;
}
.sidebar-brand img { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; }
.sidebar-brand .badge {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
}
.sidebar-brand span { color: #e2e8f0; font-weight: 700; font-size: 1.1rem; }

.sidebar-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #64748b; font-weight: 600; margin: 1.5rem 0 0.5rem 0.5rem;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 0.7rem 1rem; margin-bottom: 4px;
  border-radius: 10px; color: var(--sidebar-text);
  text-decoration: none; font-weight: 500; font-size: 0.9rem;
  transition: all 0.2s ease; border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
  transform: translateX(2px);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(37,99,235,0.3), rgba(29,78,216,0.2));
  border-color: rgba(59,130,246,0.3);
  color: #fff;
}
.nav-item .icon { font-size: 1.1rem; }

.sidebar-divider { height: 1px; background: #1e293b; margin: 1rem 0; }

/* ── Header ── */
.page-header {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 1rem; margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}
.page-header img { width: 44px; height: 44px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); object-fit: contain; }
.page-header .badge {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; color: #0f172a; }
.page-header .subtitle { color: var(--text-muted); font-size: 0.85rem; }

/* ── Status bar ── */
.status-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; background: linear-gradient(90deg, #eff6ff, #f0fdf4);
  border-radius: 10px; margin-bottom: 1.5rem; border: 1px solid #dbeafe;
  font-size: 0.82rem; color: var(--text-muted);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.fresh { background: var(--success); }
.status-dot.stale { background: var(--warning); }
.status-dot.dead { background: var(--danger); }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 4px; background: #fff; border-radius: 12px;
  padding: 4px; box-shadow: var(--shadow); border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab {
  padding: 8px 24px; border-radius: 8px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; transition: all 0.2s ease;
  border: none; background: transparent; font-size: 0.9rem;
}
.tab:hover { background: #f1f5f9; color: var(--text); }
.tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

/* ── KPI Cards ── */
.kpi-grid {
  display: grid; gap: 14px; margin-bottom: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kpi-card {
  background: linear-gradient(135deg, var(--c1, #3b82f6), var(--c2, #1d4ed8));
  border-radius: var(--radius); padding: 1.1rem 1.25rem; color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10); transition: all 0.2s ease;
  min-height: 100px; display: flex; flex-direction: column; justify-content: space-between;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.14); }
.kpi-card .icon { font-size: 1.6rem; line-height: 1; margin-bottom: 6px; }
.kpi-card .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.85; font-weight: 600; }
.kpi-card .value { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }

/* ── Section headers ── */
.section-header {
  display: flex; align-items: center; gap: 10px;
  margin: 1.5rem 0 0.75rem 0;
}
.section-header .icon { font-size: 1.3rem; }
.section-header h2 { font-size: 1.1rem; font-weight: 700; color: #0f172a; }
.section-header .sub { color: var(--text-muted); font-size: 0.8rem; }

/* ── Tables ── */
.table-wrap {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; }
thead th {
  background: #f8fafc; font-weight: 600; color: #475569;
  text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.03em;
  padding: 10px 16px; border-bottom: 2px solid var(--border); text-align: left;
}
tbody td { padding: 10px 16px; border-bottom: 1px solid #f1f5f9; font-size: 0.85rem; }
tbody tr:hover { background: #eff6ff; }
tbody tr:last-child td { border-bottom: none; }

/* ── Chart container ── */
.chart-card {
  background: #fff; border-radius: var(--radius); padding: 1.25rem;
  border: 1px solid var(--border); box-shadow: var(--shadow); margin-bottom: 1rem;
}
.chart-card h3 { font-size: 0.95rem; font-weight: 600; color: #0f172a; margin-bottom: 0.75rem; }
.chart-container { position: relative; height: 280px; }

/* ── 2-column layout ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Login page ── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
}
.login-card {
  background: #fff; border-radius: 20px; padding: 2.5rem; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card .brand { text-align: center; margin-bottom: 2rem; }
.login-card .brand img { width: 56px; height: 56px; border-radius: 12px; margin-bottom: 12px; object-fit: contain; }
.login-card .brand .badge {
  width: 56px; height: 56px; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 20px;
  box-shadow: 0 6px 20px rgba(37,99,235,0.3);
}
.login-card h1 { font-size: 1.5rem; font-weight: 700; color: #0f172a; }
.login-card .tagline { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 0.7rem 0.9rem; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 0.95rem; transition: all 0.2s ease;
  background: #fff; color: var(--text);
}
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

.btn {
  display: inline-block; padding: 0.75rem 1.5rem; border: none; border-radius: 10px;
  font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: all 0.2s ease;
  text-decoration: none; text-align: center;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.4); }
.btn-block { width: 100%; }

.alert { padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.85rem; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #16a34a; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

.login-footer { text-align: center; margin-top: 1.5rem; font-size: 0.82rem; color: var(--text-muted); }
.login-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* ── Loading ── */
.loading { text-align: center; padding: 2rem; color: var(--text-muted); }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Animations ── */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeInUp 0.4s ease-out; }

/* ── Mobile ── */
.mobile-toggle { display: none; }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 1rem; }
  .mobile-toggle {
    display: flex; align-items: center; gap: 8px;
    background: var(--sidebar-bg); color: #fff; border: none;
    padding: 0.6rem 1rem; border-radius: 10px; font-size: 1.1rem;
    cursor: pointer; margin-bottom: 1rem;
  }
  .two-col { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .table-wrap { overflow-x: auto; }
  table { min-width: 600px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Table toolbar ── */
.table-toolbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); background: #f8fafc;
  flex-wrap: wrap;
}
.table-toolbar .filter-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  flex-wrap: wrap; padding-top: 8px; border-top: 1px solid #e2e8f0;
}
.table-toolbar .search-input {
  flex: 1; min-width: 150px; padding: 7px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 0.85rem; background: #fff; color: var(--text);
}
.table-toolbar .search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.btn-download {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  background: linear-gradient(135deg, #059669, #047857); color: #fff;
  border: none; border-radius: 8px; font-weight: 600; font-size: 0.82rem;
  cursor: pointer; transition: all 0.2s ease; text-decoration: none;
  white-space: nowrap;
}
.btn-download:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(5,150,105,0.3); }
.table-count { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.table-wrap table thead th { cursor: default; }
.table-wrap { max-height: 600px; overflow-y: auto; }

/* ── Filterable table styles ── */
.filter-select {
  padding: 6px 10px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 0.82rem; background: #fff; color: var(--text); cursor: pointer;
  transition: all 0.15s ease; white-space: nowrap; max-width: 160px;
}
.filter-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.filter-select:hover { border-color: #94a3b8; }
.btn-clear-filters {
  padding: 6px 12px; background: #f1f5f9; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 8px; font-size: 0.78rem;
  cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
}
.btn-clear-filters:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
th.sortable { cursor: pointer; user-select: none; transition: background 0.15s; }
th.sortable:hover { background: #e2e8f0; }
th.sortable .sort-arrow { font-size: 0.65rem; color: var(--primary); }

/* ── Remark & Cancel styles ── */
.btn-small {
  background: #f1f5f9; border: 1px solid #cbd5e1; color: #475569;
  padding: 3px 10px; border-radius: 6px; font-size: 0.75rem; cursor: pointer;
  transition: all 0.15s ease; white-space: nowrap;
}
.btn-small:hover { background: #e2e8f0; border-color: #94a3b8; }
.remark-text {
  display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; cursor: pointer; font-size: 0.78rem; color: #334155;
  padding: 2px 6px; border-radius: 4px; background: #f8fafc; border: 1px solid #e2e8f0;
}
.remark-text:hover { background: #eef2ff; border-color: #c7d2fe; }
.btn-cancel {
  background: #fef2f2; border: 1px solid #fca5a5; color: #dc2626;
  padding: 3px 10px; border-radius: 6px; font-size: 0.75rem; cursor: pointer;
  transition: all 0.15s ease; white-space: nowrap;
}
.btn-cancel:hover { background: #fee2e2; border-color: #f87171; }
.badge-pending {
  display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 0.72rem;
  font-weight: 600; background: #fef3c7; color: #92400e; border: 1px solid #fcd34d;
  white-space: nowrap;
}
.badge-cancelled {
  display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 0.72rem;
  font-weight: 600; background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
  white-space: nowrap;
}
.badge-rejected {
  display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 0.72rem;
  font-weight: 600; background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1;
  white-space: nowrap;
}

/* Inline approve/reject icons */
.icon-approve {
  background: none; border: 1px solid #16a34a; color: #16a34a;
  border-radius: 4px; width: 22px; height: 22px; cursor: pointer;
  font-size: 0.8rem; line-height: 1; padding: 0; margin-left: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.icon-approve:hover { background: #16a34a; color: #fff; }
.icon-reject {
  background: none; border: 1px solid #dc2626; color: #dc2626;
  border-radius: 4px; width: 22px; height: 22px; cursor: pointer;
  font-size: 0.8rem; line-height: 1; padding: 0; margin-left: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.icon-reject:hover { background: #dc2626; color: #fff; }

/* Date range bar */
.date-range-bar {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; background: var(--card); border-radius: 12px;
  margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
