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

/* ================================================================
   ACT Gateway Admin — Design System
   ================================================================ */

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-text: #0f172a;
  --sidebar-w: 240px;

  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;

  --green: #10b981;
  --green-bg: #d1fae5;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --orange: #f59e0b;
  --orange-bg: #fef3c7;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
}

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

body {
  font-family: "Prompt", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { line-height: 1.3; }

/* ================================================================
   LOGIN PAGE
   ================================================================ */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #f0f9ff 0%, #f1f5f9 60%);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-logo-icon {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.auth-logo-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.auth-logo-sub {
  font-size: 12px;
  color: var(--muted);
}

.auth-heading {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-desc {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}

/* ================================================================
   FORM ELEMENTS
   ================================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.form-input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #f8fafc;
  color: var(--ink);
  transition: all 0.2s ease;
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(78, 91, 242, 0.15);
}

select.form-input {
  cursor: pointer;
}

.form-grid {
  display: grid;
  gap: 0 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-grid .span-full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
  margin-top: 8px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.auth-message {
  margin-top: 12px;
}

.settings-form {
  max-width: 560px;
}

.label-hint {
  color: var(--muted);
  font-weight: 400;
}

.table-actions {
  display: flex;
  gap: 6px;
}

.form-message {
  font-size: 13px;
  min-height: 20px;
  display: flex;
  align-items: center;
}

.form-message.success { color: var(--green); }
.form-message.error   { color: var(--red); }
.form-message.info    { color: var(--muted); }

/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 11px 22px;
  min-height: 40px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #3d49db 100%);
  color: #fff;
  box-shadow: 0 4px 10px rgba(78, 91, 242, 0.25);
  border: 1px solid rgba(78, 91, 242, 0.4);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #3d49db 0%, #343ebe 100%);
  box-shadow: 0 4px 14px rgba(78, 91, 242, 0.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.btn-ghost:hover:not(:disabled) { 
  background: #f8fafc; 
  border-color: #cbd5e1;
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fecaca;
}
.btn-danger:hover:not(:disabled) { 
  background: #fee2e2;
  border-color: #fca5a5;
}

.btn-sm {
  padding: 8px 14px;
  min-height: 34px;
  font-size: 13.5px;
}

/* ================================================================
   SIDEBAR LAYOUT
   ================================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  height: 64px;
  border-bottom: 1px solid var(--line);
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.sidebar-logo-title {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo-sub {
  color: var(--muted);
  font-size: 11px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 8px 6px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.15s;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  -webkit-user-select: none;
  user-select: none;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg);
}
.nav-item:hover .nav-icon { color: var(--accent); }

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--accent); opacity: 1; }

.nav-item.nav-danger {
  color: rgba(248, 113, 113, 0.7);
}
.nav-item.nav-danger .nav-icon { opacity: 0.6; }
.nav-item.nav-danger:hover {
  color: rgba(248, 113, 113, 0.95);
  background: rgba(248, 113, 113, 0.08);
}
.nav-item.nav-danger:hover .nav-icon { opacity: 1; }

a.nav-item.nav-external {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}
a.nav-item.nav-external:hover {
  color: var(--ink);
  background: var(--bg);
}
a.nav-item.nav-external .nav-icon { width: 14px; height: 14px; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--line);
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

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

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px 6px 8px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.page-content {
  flex: 1;
  padding: 32px;
  width: 100%;
}

/* ================================================================
   SECTIONS
   ================================================================ */

[data-section] {
  display: none;
}

[data-section].active {
  display: block;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

/* ================================================================
   SUMMARY CARDS
   ================================================================ */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.summary-card:hover {
  box-shadow: var(--shadow);
}

.sc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sc-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg);
  flex-shrink: 0;
}
.summary-card.c-blue  .sc-icon-wrap { background: var(--accent-light); }
.summary-card.c-green .sc-icon-wrap { background: var(--green-bg); }
.summary-card.c-red   .sc-icon-wrap { background: var(--red-bg); }

.sc-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.sc-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.summary-card.c-blue  .sc-value { color: var(--accent); }
.summary-card.c-green .sc-value { color: var(--green); }
.summary-card.c-red   .sc-value { color: var(--red); }

/* ================================================================
   PANEL
   ================================================================ */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.panel:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

.panel + .panel {
  margin-top: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.panel-header-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Add-form panels get a blue left accent */
.panel-add {
  border-top: 3px solid var(--accent);
  border-left: none;
}
.panel-add .panel-header {
  background: #ffffff;
}

.panel-body {
  padding: 20px;
}

/* ================================================================
   TABLE
   ================================================================ */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: transparent;
}

th {
  padding: 14px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 14px 20px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #f0f9ff;
}

.td-muted {
  color: var(--muted);
  font-size: 12px;
}

.td-mono {
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ================================================================
   STATUS BADGES
   ================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue   { background: var(--accent-light); color: var(--accent-hover); }
.badge-gray   { background: #f1f5f9; color: var(--muted); }
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-inactive { background: #f1f5f9; color: var(--muted); }

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  max-width: 320px;
  pointer-events: auto;
  animation: toast-in 0.18s ease;
}

.toast.success { background: #14532d; }
.toast.error   { background: #7f1d1d; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   MISC
   ================================================================ */

.loading-cell {
  text-align: center;
  color: var(--muted);
  padding: 36px !important;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 36px !important;
  font-size: 13px;
}

/* ================================================================
   PAGINATION
   ================================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.pagination .btn {
  padding: 7px 13px;
  min-height: 32px;
  font-size: 13px;
}

.pagination select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.pagination .page-info {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.search-input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  width: 200px;
  outline: none;
  color: var(--ink);
  background: var(--surface);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ================================================================
   MODAL
   ================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  transform: scale(0.95);
  animation: modal-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modal-in {
  to { transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--ink);
}

.modal-body {
  padding: 20px;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ================================================================
   TOM SELECT — style overrides to match admin UI
   ================================================================ */
.ts-wrapper {
  width: 100%;
}
.ts-wrapper.form-input {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}
.ts-control {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  padding: 9px 12px !important;
  font-size: 14px !important;
  font-family: inherit !important;
  background: #f8fafc !important;
  color: var(--ink) !important;
  box-shadow: none !important;
  min-height: unset !important;
  transition: all 0.2s ease !important;
  display: flex !important;
  align-items: center !important;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--accent) !important;
  background: #fff !important;
  box-shadow: 0 0 0 3px rgba(78, 91, 242, 0.15) !important;
}
.ts-dropdown {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  font-size: 14px !important;
  font-family: inherit !important;
  margin-top: 4px !important;
  z-index: 9999 !important;
  overflow: hidden !important;
}
.ts-dropdown .option {
  padding: 9px 12px !important;
  color: var(--ink) !important;
  transition: background 0.1s !important;
}
.ts-dropdown .option:hover,
.ts-dropdown .option.active {
  background: var(--accent-light) !important;
  color: var(--accent-hover) !important;
}
.ts-dropdown-content {
  max-height: 220px !important;
  padding: 4px !important;
}
.ts-control input {
  font-family: inherit !important;
  font-size: 14px !important;
}
/* Clear button */
.ts-wrapper .clear-button {
  opacity: 0.4;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.ts-wrapper .clear-button:hover { opacity: 0.8; }

/* ================================================================
   ENHANCED DASHBOARD STATS
   ================================================================ */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.c-blue::before   { background: var(--accent); }
.stat-card.c-green::before  { background: var(--green); }
.stat-card.c-red::before    { background: var(--red); }
.stat-card.c-orange::before { background: var(--orange); }
.stat-card.c-purple::before { background: #8b5cf6; }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-card-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #f1f5f9;
  color: var(--muted);
}
.stat-card.c-blue   .stat-card-icon { background: var(--accent-light); color: var(--accent); }
.stat-card.c-green  .stat-card-icon { background: var(--green-bg); color: var(--green); }
.stat-card.c-red    .stat-card-icon { background: var(--red-bg); color: var(--red); }
.stat-card.c-orange .stat-card-icon { background: var(--orange-bg); color: var(--orange); }
.stat-card.c-purple .stat-card-icon { background: #ede9fe; color: #7c3aed; }

.stat-card-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 4px;
}
.stat-card.c-blue   .stat-card-value { color: var(--accent); }
.stat-card.c-green  .stat-card-value { color: var(--green); }
.stat-card.c-red    .stat-card-value { color: var(--red); }
.stat-card.c-orange .stat-card-value { color: var(--orange); }
.stat-card.c-purple .stat-card-value { color: #7c3aed; }

.stat-card-sub { font-size: 12px; color: var(--muted); }

.rate-bar-wrap { margin-top: 12px; }
.rate-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
}
.rate-bar {
  height: 5px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.rate-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.rate-bar-fill.danger  { background: var(--red); }
.rate-bar-fill.warning { background: var(--orange); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 1024px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ================================================================
   FILTER BAR
   ================================================================ */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .form-input { flex: 1; min-width: 180px; }
.filter-bar select.form-input { flex: none; min-width: 160px; }

/* ================================================================
   ICON BUTTONS
   ================================================================ */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-icon:hover         { background: var(--bg); color: var(--ink); border-color: #cbd5e1; }
.btn-icon.danger:hover  { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.btn-icon.warning:hover { background: var(--orange-bg); color: var(--orange); border-color: #fcd34d; }
.btn-icon.primary:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* ================================================================
   MODAL SIZES + DETAIL VIEW
   ================================================================ */
.modal-lg { width: min(720px, 100%); }
.modal-xl { width: min(900px, 100%); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
.detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 3px;
}
.detail-value { font-size: 14px; color: var(--ink); font-weight: 500; }
.detail-divider {
  grid-column: 1 / -1;
  border: none;
  border-top: 1px solid var(--line);
  margin: 6px 0;
}

.img-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.img-preview-item {
  width: 200px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--line);
}
.img-preview-item img { 
  width: 100%; 
  height: auto; 
  display: block; 
}
.img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

/* ================================================================
   GPS STATUS
   ================================================================ */
.gps-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.gps-dot.online  { background: var(--green); box-shadow: 0 0 0 2px rgba(16,185,129,.2); }
.gps-dot.stale   { background: var(--orange); }
.gps-dot.offline { background: #cbd5e1; }

/* ================================================================
   TABLE FOOTER PAGINATION
   ================================================================ */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  background: #fafbfc;
}
.table-footer-count { font-weight: 600; }
.page-btns { display: flex; gap: 4px; }
.page-btn {
  min-width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { background: var(--bg); border-color: #cbd5e1; }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ================================================================
   CHIPS / TABS
   ================================================================ */
.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  width: fit-content;
  margin-bottom: 18px;
}
.tab-btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.tab-btn.active {
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.chip-blue   { background: var(--accent-light); border-color: rgba(78,91,242,.2);  color: var(--accent-hover); }
.chip-green  { background: var(--green-bg);     border-color: rgba(16,185,129,.2); color: var(--green); }
.chip-orange { background: var(--orange-bg);    border-color: rgba(245,158,11,.2); color: var(--orange); }
.chip-red    { background: var(--red-bg);       border-color: rgba(239,68,68,.2);  color: var(--red); }

/* ================================================================
   SHOPZY-STYLE DONUT STAT CARDS
   ================================================================ */

.stat-donut-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat-donut-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.stat-donut-info { flex: 1; min-width: 0; }
.stat-donut-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-donut-value {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 4px;
}
.stat-donut-sub {
  font-size: 11.5px;
  color: var(--muted);
}
.stat-donut-ring {
  flex-shrink: 0;
  width: 70px;
  height: 70px;
}
.stat-donut-ring circle {
  transition: stroke-dasharray 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ================================================================
   DASHBOARD 2-COLUMN LAYOUT (chart + activity)
   ================================================================ */
.dash-2col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) { .dash-2col { grid-template-columns: 1fr; } }

.chart-canvas-wrap {
  padding: 8px 20px 20px;
  position: relative;
}

/* ================================================================
   ACTIVITY LIST (right panel in dashboard)
   ================================================================ */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  transition: background 0.1s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg); }

.activity-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.activity-avatar.pass { background: var(--green-bg); color: var(--green); }
.activity-avatar.fail { background: var(--red-bg); color: var(--red); }
.activity-avatar.error { background: var(--orange-bg); color: var(--orange); }

.activity-info { flex: 1; min-width: 0; }
.activity-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }

.activity-badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 9px;
  border-radius: 5px;
  white-space: nowrap;
}
.activity-badge.pass  { background: var(--green-bg); color: var(--green); }
.activity-badge.fail  { background: var(--red-bg); color: var(--red); }
.activity-badge.error { background: var(--orange-bg); color: var(--orange); }

/* ================================================================
   DARK THEME SYSTEM
   ================================================================ */

body.dark-theme,
html.dark-theme {
  --bg: #151521;
  --card: #20202e;
  --sidebar-bg: #181926;
  --sidebar-text: #b6b4d3;
  --ink: #e1e0f6;
  --muted: #9492ad;
  --line: rgba(78, 79, 96, 0.35);

  --accent: #4078fb;
  --accent-hover: #5c8ffd;
  --accent-light: rgba(64, 120, 251, 0.15);

  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.15);
  --orange: #f59e0b;
  --orange-bg: rgba(245, 158, 11, 0.15);
}

body.dark-theme .topbar,
body.dark-theme .sidebar,
body.dark-theme .panel-header,
body.dark-theme .panel-add .panel-header,
body.dark-theme .form-input:focus,
body.dark-theme .form-input,
body.dark-theme .ts-wrapper.focus .ts-control,
body.dark-theme .btn-icon,
body.dark-theme .page-btn,
body.dark-theme .tab-btn.active {
  background-color: var(--card) !important;
}

body.dark-theme .sidebar-logo {
  border-bottom-color: var(--line) !important;
}

body.dark-theme .nav-section-label {
  color: var(--muted) !important;
}

body.dark-theme .nav-item {
  color: var(--sidebar-text) !important;
}
body.dark-theme .nav-item:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--ink) !important;
}
body.dark-theme .nav-item.active {
  background: var(--accent) !important;
  color: #fff !important;
}

body.dark-theme .user-chip {
  background: var(--card) !important;
  border-color: var(--line) !important;
  color: var(--ink) !important;
}

body.dark-theme .form-input,
body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea {
  background-color: #27283c !important;
  border-color: var(--line) !important;
  color: #cfcde9 !important;
}

body.dark-theme .form-input:focus,
body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus {
  background-color: #27283c !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(64, 120, 251, 0.25) !important;
}

body.dark-theme tbody tr:hover {
  background: rgba(255, 255, 255, 0.03) !important;
}

body.dark-theme .ts-dropdown,
body.dark-theme .ts-control,
body.dark-theme .ts-dropdown-content,
body.dark-theme .ts-control input {
  background-color: #27283c !important;
  color: #cfcde9 !important;
  border-color: var(--line) !important;
}

body.dark-theme .ts-dropdown .active {
  background-color: rgba(64, 120, 251, 0.15) !important;
  color: #4078fb !important;
}

body.dark-theme .btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
body.dark-theme .btn-primary:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}

body.dark-theme .btn-ghost {
  color: var(--muted) !important;
}
body.dark-theme .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--ink) !important;
}

body.dark-theme .modal-overlay {
  background: rgba(15, 23, 42, 0.75) !important;
}

body.dark-theme .modal {
  background: var(--card) !important;
  border-color: var(--line) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}

body.dark-theme .modal-header,
body.dark-theme .modal-footer {
  border-bottom-color: var(--line) !important;
}

body.dark-theme table {
  background: transparent !important;
}

body.dark-theme thead th,
body.dark-theme table thead th {
  background: #27283c !important;
  color: var(--ink) !important;
  border-bottom-color: var(--line) !important;
}

body.dark-theme tbody td,
body.dark-theme table tbody td {
  border-bottom-color: var(--line) !important;
}

body.dark-theme .td-mono {
  background: #27283c !important;
  color: #cfcde9 !important;
}

body.dark-theme .tab-bar {
  background: #181926 !important;
  border-color: var(--line) !important;
}

body.dark-theme .tab-btn.active {
  background: #27283c !important;
  color: var(--ink) !important;
}

body.dark-theme .btn-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.05) !important;
}

/* Auth Pages (Login.html) Dark overrides */
body.dark-theme .auth-shell {
  background: linear-gradient(135deg, #151521 0%, #1e1e2d 100%) !important;
}
body.dark-theme .auth-card {
  background: var(--card) !important;
  border-color: var(--line) !important;
}
body.dark-theme .auth-card p {
  color: var(--muted) !important;
}
body.dark-theme .link-btn {
  color: var(--accent) !important;
}
body.dark-theme .link-btn:hover {
  color: var(--accent-hover) !important;
}
body.dark-theme .otp-inputs input {
  background: #27283c !important;
  border-color: var(--line) !important;
  color: #fff !important;
}
body.dark-theme .otp-inputs input:focus {
  border-color: var(--accent) !important;
}
body.dark-theme .back-link {
  color: var(--muted) !important;
}
body.dark-theme .back-link:hover {
  color: var(--ink) !important;
}

/* Scrollbar overrides */
body.dark-theme ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1) !important;
}
body.dark-theme ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

