/* ─────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active-bg: rgba(59,130,246,.15);
  --sidebar-active-color: #60a5fa;
  --sidebar-text: #94a3b8;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --green: #16a34a;
  --green-light: #dcfce7;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --coral: #e11d48;
  --coral-light: #ffe4e6;
  --red: #dc2626;
  --red-light: #fee2e2;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: 'Inter', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.6; }

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

/* ── SIDEBAR ── */
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); position: fixed; top: 0; left: 0; bottom: 0; display: flex; flex-direction: column; z-index: 200; overflow-y: auto; transition: transform .28s ease; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg,#2563eb,#7c3aed); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; color: #fff; letter-spacing: -.5px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.brand-sub  { font-size: 10px; color: #64748b; }
.sidebar-close-btn { display: none; align-items: center; justify-content: center; width: 28px; height: 28px; background: rgba(255,255,255,.1); border: none; border-radius: 6px; color: #94a3b8; font-size: 14px; cursor: pointer; margin-left: auto; flex-shrink: 0; }
.sidebar-close-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0; }
.user-avatar-sm { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#2563eb,#7c3aed); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0; }
.user-details { min-width: 0; }
.user-name-sm { color: #e2e8f0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-badge { display: inline-block; padding: 2px 8px; border-radius: 100px; font-size: 10px; font-weight: 600; margin-top: 3px; }
.role-admin       { background: rgba(124,58,237,.25); color: #a78bfa; }
.role-coordinator { background: rgba(13,148,136,.25);  color: #5eead4; }
.role-dsm         { background: rgba(217,119,6,.25);   color: #fcd34d; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav-group-label { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #475569; padding: 12px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--sidebar-text); text-decoration: none; font-weight: 500; font-size: 13px; transition: background .15s, color .15s; }
.nav-item:hover  { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-color); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); flex-shrink: 0; }
.logout-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; background: rgba(255,255,255,.05); color: #94a3b8; border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; transition: background .15s, color .15s; }
.logout-btn:hover { background: rgba(239,68,68,.15); color: #fca5a5; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 199; }
.sidebar-overlay.open { display: block; }

/* ── TOPBAR ── */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 50; }
.page-title { font-size: 17px; font-weight: 700; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
/* Hamburger — hidden on desktop */
.hamburger-btn { display: none; flex-direction: column; justify-content: center; gap: 5px; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; padding: 6px; width: 38px; height: 38px; flex-shrink: 0; }
.hamburger-btn span { display: block; height: 2px; background: var(--text); border-radius: 2px; transition: all .25s; }
.hamburger-btn:hover { background: var(--bg); }

/* ── CONTENT ── */
.content-area { padding: 24px; flex: 1; }
.mt-4 { margin-top: 20px; } .mb-4 { margin-bottom: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── ALERTS ── */
.alert { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; font-weight: 500; }
.alert-success { background: var(--green-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-light);   color: #991b1b; border: 1px solid #fecaca; }
.alert-close   { background: none; border: none; cursor: pointer; color: inherit; font-size: 16px; opacity: .7; padding: 0; margin-left: 8px; }

/* ── CARDS ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 14px 20px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border); background: #fafafa; display: flex; align-items: center; justify-content: space-between; }
.card-body     { padding: 20px; }
.card-body.p-0 { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); border-left: 4px solid transparent; }
.stat-card.accent-blue   { border-left-color: var(--blue); }
.stat-card.accent-teal   { border-left-color: var(--teal); }
.stat-card.accent-green  { border-left-color: var(--green); }
.stat-card.accent-amber  { border-left-color: var(--amber); }
.stat-card.accent-purple { border-left-color: var(--purple); }
.stat-card.accent-coral  { border-left-color: var(--coral); }
.stat-icon  { font-size: 22px; flex-shrink: 0; }
.stat-label { color: var(--text-muted); font-size: 12px; font-weight: 500; margin-bottom: 2px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── TABLE ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
.table th { text-align: left; padding: 11px 16px; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: #fafafa; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.font-medium { font-weight: 600; } .text-muted { color: var(--text-muted); }
.actions-cell { white-space: nowrap; text-align: right; }
.cumulative-table th, .cumulative-table td { text-align: center; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 11px; font-weight: 600; }
.badge-blue   { background: var(--blue-light);   color: #1e40af; }
.badge-teal   { background: var(--teal-light);   color: #0f766e; }
.badge-green  { background: var(--green-light);  color: #166534; }
.badge-amber  { background: var(--amber-light);  color: #92400e; }
.badge-purple { background: var(--purple-light); color: #5b21b6; }
.badge-red    { background: var(--red-light);    color: #991b1b; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; border: none; transition: all .15s; white-space: nowrap; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger  { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-sm   { padding: 5px 11px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── FORMS ── */
.form-card { max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; color: var(--text); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; }
.form-group select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-group input[readonly] { background: #f8fafc; color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-hint-banner { background: var(--blue-light); color: #1e40af; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; margin-bottom: 18px; }
.form-section-note { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; padding: 10px 14px; background: #f8fafc; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.form-row-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.optional-tag { font-size: 10px; font-weight: 400; color: var(--text-muted); background: #f1f5f9; padding: 1px 6px; border-radius: 4px; margin-left: 4px; }
.radio-group  { display: flex; gap: 12px; flex-wrap: wrap; }
.radio-option { flex: 1; min-width: 80px; cursor: pointer; }
.radio-option input { display: none; }
.radio-card   { display: flex; align-items: center; justify-content: center; padding: 12px; border: 2px solid var(--border); border-radius: var(--radius); transition: all .15s; }
.radio-label  { font-size: 14px; font-weight: 600; }
.radio-option input:checked + .radio-card { border-color: var(--blue); background: var(--blue-light); color: var(--blue); }
.filter-form .filter-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.filter-form .form-group { margin-bottom: 0; min-width: 150px; }

/* ── SUMMARY BAR ── */
.summary-bar { display: flex; gap: 20px; flex-wrap: wrap; padding: 12px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }

/* ── SECTION LABEL ── */
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 10px; display: block; }

/* ── DAILY STATS BLOCK ── */
.daily-stats-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px 20px; box-shadow: var(--shadow); }
.daily-stats-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.daily-date-form input[type="date"] { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; color: var(--text); background: #fff; outline: none; cursor: pointer; transition: border-color .15s, box-shadow .15s; min-width: 160px; }
.daily-date-form input[type="date"]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.daily-card { border-style: dashed !important; }

/* ── REPORT ── */
.report-date-banner { padding: 12px 18px; margin-bottom: 16px; background: linear-gradient(135deg,var(--blue-light),var(--purple-light)); border-radius: var(--radius); font-size: 14px; color: #1e1b4b; border: 1px solid #c7d2fe; }
.totals-row td { background: #f0fdf4; font-size: 16px; padding: 16px !important; }

/* ── DSM DASHBOARD ── */
.today-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.today-row:last-child { border-bottom: none; }
.today-phone { flex: 1; font-weight: 500; font-size: 13px; }
.today-val   { font-weight: 600; font-size: 13px; }
.daily-summary-badge { background: var(--green-light); color: #166534; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; text-align: center; margin-top: 6px; }

/* ── SUMMARY GRID ── */
.summary-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.summary-item { text-align: center; padding: 14px 10px; background: #f8fafc; border-radius: var(--radius-sm); }
.summary-label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.summary-val   { display: block; font-size: 20px; font-weight: 700; color: var(--text); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); font-size: 14px; }
.empty-state a { color: var(--blue); text-decoration: none; }

/* ── LOGIN ── */
.login-body     { background: linear-gradient(135deg,#0f172a 0%,#1e3a6e 50%,#1e1b4b 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrapper  { width: 100%; max-width: 420px; padding: 20px; }
.login-card     { background: white; border-radius: 16px; padding: 40px 36px; box-shadow: 0 25px 60px rgba(0,0,0,.35); }
.login-header   { text-align: center; margin-bottom: 32px; }
.login-logo     { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg,#2563eb,#7c3aed); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; color: #fff; margin: 0 auto 12px; letter-spacing: -.5px; }
.login-header h1 { font-size: 24px; font-weight: 800; color: #0f172a; margin-bottom: 4px; }
.login-header p  { color: #64748b; font-size: 13px; }
.login-footer    { text-align: center; margin-top: 24px; color: #94a3b8; font-size: 12px; }

/* ══════════════════════════════════════
   RESPONSIVE — single source of truth
══════════════════════════════════════ */

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

@media (max-width: 768px) {
  /* Show hamburger */
  .hamburger-btn { display: flex; }

  /* Sidebar slides off-screen, opens to 85vw */
  .sidebar { width: 85vw; max-width: 320px; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.4); }
  .sidebar-close-btn { display: flex; }

  /* Full-width content */
  .main-content { margin-left: 0; }

  /* Topbar */
  .topbar     { padding: 0 14px; height: 54px; }
  .page-title { font-size: 15px; }
  .topbar-actions .btn { font-size: 12px; padding: 6px 10px; }

  /* Layout */
  .content-area { padding: 14px; }
  .two-col      { grid-template-columns: 1fr; }
  .stats-grid   { grid-template-columns: 1fr 1fr; }
  .form-row-2   { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }

  /* Cards */
  .card-body    { padding: 14px; }
  .card-header  { padding: 12px 14px; }
  .form-card    { padding: 18px 16px; max-width: 100%; }
  .stat-card    { padding: 14px; gap: 10px; }
  .stat-value   { font-size: 20px; }

  /* Filters stack vertically */
  .filter-form .filter-row { flex-direction: column; gap: 10px; }
  .filter-form .form-group { min-width: 100%; width: 100%; }

  /* Summary bar stacks */
  .summary-bar { flex-direction: column; gap: 8px; padding: 12px 14px; }

  /* Daily picker stretches */
  .daily-stats-header  { flex-direction: column; align-items: flex-start; gap: 10px; }
  .daily-date-form input[type="date"] { width: 100%; min-width: unset; }

  /* Form actions wrap */
  .form-actions { flex-wrap: wrap; }
  .report-date-banner { font-size: 13px; padding: 10px 14px; }
  .actions-cell .btn  { font-size: 11px; padding: 4px 8px; }
}

@media (max-width: 480px) {
  .stats-grid   { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .stat-value   { font-size: 18px; }
  .content-area { padding: 10px; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .login-card   { padding: 28px 18px; }
  .login-wrapper { padding: 12px; }
  .radio-option { min-width: 70px; }
}
