/* ═══════════════════════════════════════════════════════════════
   DG Transaction Monitor & Voucher Manager — Style Sheet
   Clean Light Theme with Airbnb Design Touches + Sleek Dark Mode
   Font: Inter (Google Fonts)
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg:          #F7F7F7;
  --surface:     #FFFFFF;
  --surface-sub: #FAFAFA;
  --border:      #EBEBEB;
  --border-dark: #D8D8D8;
  --text-1:      #222222;
  --text-2:      #484848;
  --text-3:      #717171;
  --text-4:      #BBBBBB;

  /* Status colors */
  --paid:        #00A699;
  --paid-bg:     #E8F8F7;
  --paid-border: #B2DFDB;
  --pending:     #F5A623;
  --pending-bg:  #FFF8E1;
  --pending-border: #FFE082;
  --failed:      #FC3C6B;
  --failed-bg:   #FFF2F2;
  --failed-border: #FFCDD2;

  --avail:       #10B981;
  --avail-bg:    #ECFDF5;
  --avail-border:#A7F3D0;
  --used:        #6B7280;
  --used-bg:     #F3F4F6;
  --used-border: #E5E7EB;

  /* Airbnb-inspired accent */
  --accent:      #FF385C;
  --accent-dark: #E31C5F;
  --accent-bg:   #FFF2F4;

  /* Sidebar */
  --sidebar-w:   250px;

  /* Shadows */
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.06);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);

  /* Radius */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
}

/* ─── Dark Mode Variables ───────────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0F1115;
  --surface:     #171A21;
  --surface-sub: #13151A;
  --border:      #262A34;
  --border-dark: #373D4B;
  --text-1:      #F9FAFB;
  --text-2:      #E5E7EB;
  --text-3:      #9CA3AF;
  --text-4:      #4B5563;

  --paid-bg:     rgba(0, 166, 153, 0.15);
  --paid-border: rgba(0, 166, 153, 0.35);
  --pending-bg:  rgba(245, 166, 35, 0.15);
  --pending-border: rgba(245, 166, 35, 0.35);
  --failed-bg:   rgba(252, 60, 107, 0.15);
  --failed-border: rgba(252, 60, 107, 0.35);

  --avail-bg:    rgba(16, 185, 129, 0.15);
  --avail-border:rgba(16, 185, 129, 0.35);
  --used-bg:     rgba(107, 114, 128, 0.2);
  --used-border: rgba(107, 114, 128, 0.35);

  --accent-bg:   rgba(255, 56, 92, 0.15);

  --shadow-sm:   0 1px 4px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
}

html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

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

/* ─── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease, background 0.25s ease, border-color 0.25s ease;
}

.sidebar-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
}
.brand-icon {
  width: 38px; height: 38px; background: var(--text-1); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.brand-icon svg { width: 20px; height: 20px; color: var(--bg); }
.brand-text h2 { font-size: 15px; font-weight: 700; color: var(--text-1); line-height: 1.2; }
.brand-text p  { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* Poller status indicator in sidebar */
.poller-badge {
  display: flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 6px 10px;
  background: var(--bg); border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500; color: var(--text-3);
  border: 1px solid var(--border);
}
.poller-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-4); transition: background 0.3s;
  flex-shrink: 0;
}
.poller-dot.active {
  background: var(--paid);
  box-shadow: 0 0 0 3px rgba(0,166,153,0.25);
  animation: pulse 2s infinite;
}
.poller-dot.error { background: var(--failed); }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(0,166,153,0.25); }
  50%      { box-shadow: 0 0 0 6px rgba(0,166,153,0.1); }
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1; padding: 16px 12px; overflow-y: auto;
}
.nav-section-label {
  font-size: 10px; font-weight: 700; color: var(--text-4); text-transform: uppercase;
  letter-spacing: 0.8px; padding: 0 8px; margin: 16px 0 6px;
}
.nav-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s, color 0.15s;
  user-select: none; position: relative;
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.75; }
.nav-item:hover { background: var(--bg); color: var(--text-1); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3.5px; background: var(--accent); border-radius: 0 3px 3px 0;
}

/* Badge on nav items */
.nav-badge {
  margin-left: auto; background: var(--failed); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  min-width: 18px; text-align: center; line-height: 1.4;
}
.nav-badge.pending { background: var(--pending); color: #fff; }
.nav-badge.avail { background: var(--avail); color: #fff; }
.nav-badge.hidden { display: none; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}

.theme-toggle-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-2); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.theme-toggle-btn:hover { border-color: var(--border-dark); color: var(--text-1); }
.theme-toggle-btn svg { width: 16px; height: 16px; }

.btn-logout {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; border-radius: var(--radius-sm); border: none;
  background: none; cursor: pointer; color: var(--text-3);
  font-size: 13px; font-family: inherit; transition: background 0.15s, color 0.15s;
}
.btn-logout:hover { background: var(--failed-bg); color: var(--failed); }
.btn-logout svg { width: 16px; height: 16px; }

/* ─── Main Content ──────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
  background: var(--bg);
}

.topbar {
  background: var(--surface); border-bottom: 1.5px solid var(--border);
  padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 90;
  transition: background 0.25s, border-color 0.25s;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text-1); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-time { font-size: 12px; color: var(--text-3); }

/* Quick dark mode switch in topbar */
.btn-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text-1); border-color: var(--border-dark); }
.btn-icon svg { width: 17px; height: 17px; }

/* Poll Now button */
.btn-poll-now {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; background: var(--text-1); color: var(--bg); border: none;
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s; font-family: inherit;
}
.btn-poll-now:hover { opacity: 0.85; }
.btn-poll-now svg { width: 14px; height: 14px; }
.btn-poll-now.loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Page Content ──────────────────────────────────────────────── */
.page { display: none; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

.page-header { margin-bottom: 24px; display: flex; align-items: flex-start; justify-content: space-between; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text-1); letter-spacing: -0.3px; }
.page-header p  { font-size: 13px; color: var(--text-3); margin-top: 3px; }

/* ─── Stats Cards (Airbnb Touch) ────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border-radius: var(--radius-md);
  border: 1.5px solid var(--border); padding: 18px 20px;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-dark); }
.stat-card-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.stat-card-icon svg { width: 20px; height: 20px; }
.stat-card-icon.total   { background: var(--bg); }
.stat-card-icon.paid    { background: var(--paid-bg); }
.stat-card-icon.pending { background: var(--pending-bg); }
.stat-card-icon.failed  { background: var(--failed-bg); }
.stat-card-icon.avail   { background: var(--avail-bg); }
.stat-card-icon.used    { background: var(--used-bg); }

.stat-card-icon.total   svg { color: var(--text-2); }
.stat-card-icon.paid    svg { color: var(--paid); }
.stat-card-icon.pending svg { color: var(--pending); }
.stat-card-icon.failed  svg { color: var(--failed); }
.stat-card-icon.avail   svg { color: var(--avail); }
.stat-card-icon.used    svg { color: var(--used); }

.stat-label { font-size: 12px; font-weight: 500; color: var(--text-3); margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-1); line-height: 1.1; letter-spacing: -0.5px; }
.stat-value.paid    { color: var(--paid); }
.stat-value.pending { color: var(--pending); }
.stat-value.failed  { color: var(--failed); }
.stat-value.avail   { color: var(--avail); }
.stat-value.used    { color: var(--used); }

/* ─── Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius-md);
  border: 1.5px solid var(--border); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: border-color 0.2s, background 0.25s;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-1); }
.card-body { padding: 20px; }

/* ─── Filter Tabs ───────────────────────────────────────────────── */
.filter-tabs {
  display: flex; gap: 6px; padding: 16px 20px 0; overflow-x: auto;
}
.filter-tab {
  padding: 7px 16px; border-radius: 20px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-2); transition: all 0.15s; font-family: inherit; white-space: nowrap;
}
.filter-tab:hover { border-color: var(--border-dark); color: var(--text-1); }
.filter-tab.active { background: var(--text-1); color: var(--bg); border-color: var(--text-1); }
.filter-tab.active.paid    { background: var(--paid);    border-color: var(--paid); color: #fff; }
.filter-tab.active.pending { background: var(--pending); border-color: var(--pending); color: #fff; }
.filter-tab.active.failed  { background: var(--failed);  border-color: var(--failed); color: #fff; }
.filter-tab.active.avail   { background: var(--avail);   border-color: var(--avail); color: #fff; }
.filter-tab.active.used    { background: var(--used);    border-color: var(--used); color: #fff; }

/* ─── Search Bar ────────────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.search-bar svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; outline: none; font-size: 13.5px;
  font-family: inherit; color: var(--text-1); background: none;
}
.search-bar input::placeholder { color: var(--text-4); }

/* ─── Table ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 11px 16px; text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px;
  background: var(--surface-sub); border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--text-2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-sub); }

.td-code {
  font-family: 'Courier New', monospace; font-size: 12.5px;
  color: var(--text-1); font-weight: 600;
}
.td-user { font-weight: 600; color: var(--text-1); }
.td-nick { font-size: 11.5px; color: var(--text-3); display: block; }
.td-item { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-date { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.td-seen { font-size: 11px; color: var(--text-4); white-space: nowrap; }
.td-price { font-weight: 600; color: var(--paid); }

/* Status Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge.PAID    { background: var(--paid-bg);    color: var(--paid);    border: 1px solid var(--paid-border); }
.badge.PAID::before    { background: var(--paid); }
.badge.PENDING { background: var(--pending-bg); color: #B45309; border: 1px solid var(--pending-border); animation: pendingGlow 2s ease infinite; }
.badge.PENDING::before { background: var(--pending); animation: pendingPulse 2s ease infinite; }
.badge.FAILED  { background: var(--failed-bg);  color: var(--failed);  border: 1px solid var(--failed-border); }
.badge.FAILED::before  { background: var(--failed); }

.badge.AVAILABLE { background: var(--avail-bg); color: var(--avail); border: 1px solid var(--avail-border); }
.badge.AVAILABLE::before { background: var(--avail); }
.badge.SUCCESS   { background: var(--paid-bg);  color: var(--paid);  border: 1px solid var(--paid-border); }
.badge.SUCCESS::before   { background: var(--paid); }
.badge.USED      { background: var(--used-bg);  color: var(--used);  border: 1px solid var(--used-border); }
.badge.USED::before      { background: var(--used); }
.badge.PROCESSING{ background: var(--pending-bg); color: var(--pending); border: 1px solid var(--pending-border); }
.badge.PROCESSING::before{ background: var(--pending); }

.filter-tab.success.active { background: var(--paid); color: #fff; border-color: var(--paid); }
.filter-tab.success:hover  { border-color: var(--paid); color: var(--paid); }

.stat-card-icon.success { background: var(--paid-bg); }
.stat-card-icon.success svg { color: var(--paid); }
.stat-value.success { color: var(--paid); }

/* Profile Box & Details */
.profile-box {
  background: var(--surface-sub); border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 16px; font-size: 13px;
}
.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.profile-row:last-child { border-bottom: none; }
.profile-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.profile-val { font-size: 13px; font-weight: 600; color: var(--text-1); }

.alert-step {
  background: var(--pending-bg); border: 1.5px solid var(--pending-border);
  border-radius: var(--radius-sm); padding: 14px; margin-top: 14px;
}

@keyframes pendingGlow {
  0%,100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px rgba(245,166,35,0.2); }
}
@keyframes pendingPulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.5; }
}

/* Notified indicator */
.notif-sent {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--paid); font-weight: 500;
}
.notif-pending { font-size: 11px; color: var(--text-4); }

/* ─── Empty State ───────────────────────────────────────────────── */
.empty-state {
  padding: 60px 20px; text-align: center;
}
.empty-state svg { width: 44px; height: 44px; color: var(--text-4); margin-bottom: 12px; }
.empty-state h4 { font-size: 15px; color: var(--text-2); margin-bottom: 4px; }
.empty-state p  { font-size: 13px; color: var(--text-3); }

/* ─── Form & Settings ───────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; font-family: inherit;
  color: var(--text-1); background: var(--surface-sub); transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,56,92,0.12);
  background: var(--surface);
}
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; line-height: 1.4; }

/* ─── Buttons (Airbnb Touch) ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm); border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease; font-family: inherit; text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 2px 8px rgba(255,56,92,0.25); }
.btn-dark      { background: var(--text-1); color: var(--bg); }
.btn-dark:hover{ opacity: 0.9; }
.btn-secondary { background: var(--surface); color: var(--text-2); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text-1); border-color: var(--border-dark); }
.btn-danger    { background: var(--failed-bg); color: var(--failed); border: 1.5px solid var(--failed-border); }
.btn-danger:hover { background: var(--failed); color: #fff; }
.btn-success   { background: var(--paid-bg); color: var(--paid); border: 1.5px solid var(--paid-border); }
.btn-success:hover { background: var(--paid); color: #fff; }
.btn:disabled  { opacity: 0.5; cursor: not-allowed; }

/* ─── Toggle Switch ─────────────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-info h4 { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.toggle-info p  { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.4; }
.toggle-switch {
  width: 44px; height: 24px; background: var(--border-dark); border-radius: 12px;
  cursor: pointer; position: relative; transition: background 0.25s;
  border: none; flex-shrink: 0;
}
.toggle-switch.on { background: var(--paid); }
.toggle-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  transition: transform 0.25s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on::after { transform: translateX(20px); }

/* ─── Status Grid ───────────────────────────────────────────────── */
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.status-item {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 18px;
}
.status-item-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.status-item-value { font-size: 15px; font-weight: 700; color: var(--text-1); }
.status-item-value.ok     { color: var(--paid); }
.status-item-value.warn   { color: var(--pending); }
.status-item-value.error  { color: var(--failed); }

.log-box {
  background: #0B0D11; color: #00D4AA; font-family: 'Courier New', monospace;
  font-size: 12px; padding: 16px; border-radius: var(--radius-md); min-height: 90px;
  max-height: 220px; overflow-y: auto; line-height: 1.6; white-space: pre-wrap;
  border: 1px solid var(--border);
}

/* ─── Modal Dialog ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-dialog {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1.5px solid var(--border); width: 90%; max-width: 540px;
  box-shadow: var(--shadow-lg); overflow: hidden; transform: scale(0.95);
  transition: transform 0.2s ease;
}
.modal-overlay.open .modal-dialog { transform: scale(1); }
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text-1); }
.modal-close {
  background: none; border: none; font-size: 20px; color: var(--text-3);
  cursor: pointer; padding: 4px; line-height: 1; border-radius: 6px;
}
.modal-close:hover { color: var(--text-1); background: var(--bg); }
.modal-body { padding: 22px; max-height: 75vh; overflow-y: auto; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  background: var(--surface-sub);
}

/* ─── Toast Notification ────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--text-1); color: var(--bg); padding: 12px 18px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); pointer-events: all;
  animation: toastIn 0.3s ease; max-width: 340px;
  border: 1px solid var(--border);
}
.toast.success { background: #00A699; color: #fff; }
.toast.error   { background: #FC3C6B; color: #fff; }
.toast.warning { background: #F5A623; color: #fff; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Pagination / Info ─────────────────────────────────────────── */
.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
}
.clear-btn {
  display: flex; align-items: center; gap: 5px;
  color: var(--failed); font-size: 12px; font-weight: 500;
  background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 4px 8px; border-radius: 6px; transition: background 0.15s;
}
.clear-btn:hover { background: var(--failed-bg); }
.clear-btn svg { width: 13px; height: 13px; }

/* ─── Code Snippet ──────────────────────────────────────────────── */
.code-preview {
  background: var(--surface-sub); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12px;
  font-family: 'Courier New', monospace; color: var(--text-2); line-height: 1.6;
  overflow-x: auto;
}

/* ─── Responsive ────────────────────────────────────────────────── */

/* Mobile hamburger button — hidden on desktop */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-1);
  flex-shrink: 0;
  margin-right: 4px;
  transition: background 0.15s;
}
.mobile-menu-btn:hover { background: var(--bg-2); }
.mobile-menu-btn svg { width: 20px; height: 20px; }

/* Sidebar backdrop — hidden on desktop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.active { display: block; }

@media (max-width: 960px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr; }
}

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

  /* Sidebar slides in from left */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }

  /* Main takes full width */
  .main { margin-left: 0; }

  /* Topbar adjustments */
  .topbar { padding: 0 12px; gap: 6px; }
  .topbar-title { font-size: 14px; }
  .topbar-time { display: none; }
  .btn-poll-now span { display: none; }

  /* Stats stack */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Cards padding */
  .card-body { padding: 14px; }
  .page > div:first-child { padding: 16px 14px 0 !important; }

  /* Tables: horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 540px; }

  /* Modal full-width on mobile */
  .modal-box { max-width: 96vw; padding: 18px; }

  /* Settings grid 1 col */
  div[style*="grid-template-columns:1fr 1fr"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
}

/* ─── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }
