/* ═══════════════════════════════════════════════════════════════
   AGENCY PORTAL — Grey Theme
   getniva.ai/a/...
═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --ag-sidebar-bg:     #1e293b;   /* slate-800 */
  --ag-sidebar-hover:  #334155;   /* slate-700 */
  --ag-sidebar-active: #475569;   /* slate-600 */
  --ag-sidebar-text:   #cbd5e1;   /* slate-300 */
  --ag-sidebar-muted:  #64748b;   /* slate-500 */
  --ag-sidebar-border: rgba(255,255,255,.07);

  --ag-accent:         #64748b;   /* slate-500 — primary action */
  --ag-accent-dark:    #475569;   /* slate-600 */
  --ag-accent-light:   #f1f5f9;   /* slate-50 */

  --ag-bg:             #f1f5f9;   /* page background */
  --ag-white:          #ffffff;
  --ag-border:         #e2e8f0;   /* slate-200 */
  --ag-border-dark:    #cbd5e1;   /* slate-300 */

  --ag-text:           #0f172a;   /* slate-900 */
  --ag-text-muted:     #475569;   /* slate-600 */
  --ag-text-faint:     #94a3b8;   /* slate-400 */

  --ag-radius:         10px;
  --ag-radius-lg:      14px;
  --ag-shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --ag-shadow-md:      0 4px 12px rgba(0,0,0,.08);
  --ag-shadow-lg:      0 10px 30px rgba(0,0,0,.12);
  --ag-transition:     all .18s ease;

  /* Status */
  --ag-pending-fg:   #b45309;
  --ag-pending-bg:   #fffbeb;
  --ag-progress-fg:  #1d4ed8;
  --ag-progress-bg:  #eff6ff;
  --ag-active-fg:    #15803d;
  --ag-active-bg:    #f0fdf4;
  --ag-inactive-fg:  #64748b;
  --ag-inactive-bg:  #f8fafc;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--ag-bg);
  color: var(--ag-text);
  height: 100%;
  font-size: 14px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

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

/* ── Sidebar ── */
.ag-sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--ag-sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  border-right: 1px solid var(--ag-sidebar-border);
}

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

.ag-sidebar-logo-mark {
  width: 32px; height: 32px;
  background: var(--ag-sidebar-active);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #e2e8f0;
  font-weight: 800; font-size: 13px; letter-spacing: .04em;
}

.ag-sidebar-logo-text {
  font-size: 15px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: .04em;
}
.ag-sidebar-logo-sub {
  font-size: 10px;
  color: var(--ag-sidebar-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  line-height: 1;
}

/* Agency name chip */
.ag-agency-chip {
  margin: 14px 16px 6px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--ag-sidebar-border);
  border-radius: 8px;
  padding: 10px 12px;
}
.ag-agency-chip-label {
  font-size: 9px;
  color: var(--ag-sidebar-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.ag-agency-chip-name {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nav */
.ag-nav {
  flex: 1;
  padding: 12px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ag-nav-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ag-sidebar-muted);
  padding: 12px 8px 4px;
}

.ag-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--ag-sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: var(--ag-transition);
  position: relative;
}

.ag-nav-item i { font-size: 15px; flex-shrink: 0; }

.ag-nav-item:hover {
  background: var(--ag-sidebar-hover);
  color: #f1f5f9;
}

.ag-nav-item.active {
  background: var(--ag-sidebar-active);
  color: #fff;
  font-weight: 600;
}

.ag-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: #94a3b8;
  border-radius: 0 3px 3px 0;
}

.ag-nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  line-height: 1.6;
}

/* Sidebar bottom */
.ag-sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--ag-sidebar-border);
  margin-top: auto;
}

.ag-nav-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #fca5a5;
  font-size: 13px;
  font-weight: 500;
  transition: var(--ag-transition);
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
}
.ag-nav-logout i { font-size: 15px; }
.ag-nav-logout:hover { background: rgba(239,68,68,.15); color: #fca5a5; }

/* ── Main content ── */
.ag-main {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.ag-topbar {
  background: var(--ag-white);
  border-bottom: 1px solid var(--ag-border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

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

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

.ag-topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--ag-text-muted);
}

.ag-topbar-avatar {
  width: 32px; height: 32px;
  background: var(--ag-accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 700;
  text-transform: uppercase;
}

.ag-content {
  flex: 1;
  padding: 28px;
  max-width: 1300px;
  width: 100%;
}

/* ── Cards ── */
.ag-card {
  background: var(--ag-white);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-lg);
  padding: 22px 24px;
  box-shadow: var(--ag-shadow);
}

.ag-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ag-text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ag-card-title i { color: var(--ag-accent); }

/* ── Stat Cards (Dashboard) ── */
.ag-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.ag-stat-card {
  background: var(--ag-white);
  border: 1px solid var(--ag-border);
  border-radius: var(--ag-radius-lg);
  padding: 20px 22px;
  box-shadow: var(--ag-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ag-stat-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--ag-accent-light);
  display: flex; align-items: center; justify-content: center;
  color: var(--ag-accent-dark);
  font-size: 16px;
  margin-bottom: 4px;
}

.ag-stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--ag-text);
  line-height: 1;
}

.ag-stat-label {
  font-size: 12px;
  color: var(--ag-text-muted);
  font-weight: 500;
}

/* ── Buttons ── */
.ag-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: var(--ag-transition);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.ag-btn i { font-size: 14px; }

.ag-btn-primary {
  background: var(--ag-accent-dark);
  color: white;
}
.ag-btn-primary:hover {
  background: var(--ag-accent);
  color: white;
}

.ag-btn-outline {
  background: transparent;
  border: 1.5px solid var(--ag-border-dark);
  color: var(--ag-text-muted);
}
.ag-btn-outline:hover {
  background: var(--ag-accent-light);
  border-color: var(--ag-accent);
  color: var(--ag-text);
}

.ag-btn-danger {
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  color: #dc2626;
}
.ag-btn-danger:hover { background: #fee2e2; }

.ag-btn-sm { padding: 5px 12px; font-size: 12px; }
.ag-btn-lg { padding: 11px 22px; font-size: 14px; }

/* ── Tabs ── */
.ag-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--ag-border);
  margin-bottom: 20px;
}

.ag-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ag-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--ag-transition);
  border-radius: 8px 8px 0 0;
  text-decoration: none;
}

.ag-tab:hover { color: var(--ag-text); background: var(--ag-accent-light); }

.ag-tab.active {
  color: var(--ag-text);
  border-bottom-color: var(--ag-accent-dark);
  background: transparent;
}

.ag-tab-badge {
  background: var(--ag-border);
  color: var(--ag-text-muted);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}

.ag-tab.active .ag-tab-badge {
  background: var(--ag-accent-dark);
  color: white;
}

/* ── Table ── */
.ag-table-wrap { overflow-x: auto; border-radius: var(--ag-radius-lg); }

.ag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ag-table th {
  background: var(--ag-accent-light);
  color: var(--ag-text-muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--ag-border);
  white-space: nowrap;
}

.ag-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--ag-border);
  color: var(--ag-text);
  vertical-align: middle;
}

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

.ag-table tbody tr {
  transition: var(--ag-transition);
}
.ag-table tbody tr:hover { background: var(--ag-accent-light); }

/* ── Status Badges ── */
.ag-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.ag-badge-pending   { background: var(--ag-pending-bg); color: var(--ag-pending-fg); }
.ag-badge-progress  { background: var(--ag-progress-bg); color: var(--ag-progress-fg); }
.ag-badge-active    { background: var(--ag-active-bg); color: var(--ag-active-fg); }
.ag-badge-inactive  { background: var(--ag-inactive-bg); color: var(--ag-inactive-fg); }
.ag-badge-open      { background: #fffbeb; color: #b45309; }
.ag-badge-in_progress { background: #eff6ff; color: #1d4ed8; }
.ag-badge-resolved  { background: #f0fdf4; color: #15803d; }
.ag-badge-closed    { background: #f8fafc; color: #64748b; }
.ag-badge-high      { background: #fef2f2; color: #dc2626; }
.ag-badge-medium    { background: #fffbeb; color: #b45309; }
.ag-badge-low       { background: #f0fdf4; color: #15803d; }

/* ── Forms ── */
.ag-form-group { margin-bottom: 18px; }

.ag-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ag-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.ag-label .req { color: #ef4444; margin-left: 2px; }

.ag-input, .ag-select, .ag-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--ag-border-dark);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ag-text);
  background: var(--ag-white);
  transition: var(--ag-transition);
  outline: none;
}

.ag-input:focus, .ag-select:focus, .ag-textarea:focus {
  border-color: var(--ag-accent);
  box-shadow: 0 0 0 3px rgba(100,116,139,.15);
}

.ag-input.error, .ag-select.error, .ag-textarea.error {
  border-color: #ef4444;
}

.ag-textarea { min-height: 100px; resize: vertical; }

.ag-field-error {
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
}

.ag-form-hint {
  font-size: 12px;
  color: var(--ag-text-faint);
  margin-top: 4px;
}

/* ── Page header ── */
.ag-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.ag-page-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ag-text);
}

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

/* ── Empty State ── */
.ag-empty {
  text-align: center;
  padding: 52px 20px;
  color: var(--ag-text-muted);
}

.ag-empty i {
  font-size: 40px;
  color: var(--ag-border-dark);
  margin-bottom: 14px;
}

.ag-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ag-text);
  margin-bottom: 6px;
}

.ag-empty-sub { font-size: 13px; color: var(--ag-text-muted); margin-bottom: 18px; }

/* ── Alerts ── */
.ag-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 18px;
}

.ag-alert i { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.ag-alert-success { background: var(--ag-active-bg); color: #15803d; border: 1px solid #bbf7d0; }
.ag-alert-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.ag-alert-info    { background: var(--ag-progress-bg); color: #1d4ed8; border: 1px solid #bfdbfe; }
.ag-alert-warning { background: var(--ag-pending-bg); color: var(--ag-pending-fg); border: 1px solid #fde68a; }

/* ── Grid utilities ── */
.ag-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ag-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

@media (max-width: 900px) {
  .ag-grid-2, .ag-grid-3 { grid-template-columns: 1fr; }
}

/* ── Login Page ── */
.ag-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ag-sidebar-bg);
  padding: 24px;
}

.ag-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--ag-white);
  border-radius: var(--ag-radius-lg);
  padding: 40px 36px 36px;
  box-shadow: var(--ag-shadow-lg);
}

.ag-login-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 30px;
}

.ag-login-logo-mark {
  width: 38px; height: 38px;
  background: var(--ag-accent-dark);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 14px; letter-spacing: .04em;
}

.ag-login-logo-text { font-size: 18px; font-weight: 800; color: var(--ag-text); }
.ag-login-logo-sub  { font-size: 11px; color: var(--ag-text-faint); }

.ag-login-title {
  font-size: 22px; font-weight: 800; color: var(--ag-text); margin-bottom: 6px;
}

.ag-login-sub {
  font-size: 13px; color: var(--ag-text-muted); margin-bottom: 28px; line-height: 1.55;
}

.ag-login-btn {
  width: 100%; justify-content: center; font-size: 14px;
  padding: 11px 16px; border-radius: 9px; margin-top: 4px;
}

.ag-login-footer {
  text-align: center; font-size: 12px; color: var(--ag-text-faint);
  margin-top: 24px; line-height: 1.6;
}

/* ── Credentials Box ── */
.ag-credentials-box {
  background: #f8fafc;
  border: 1.5px dashed var(--ag-border-dark);
  border-radius: 10px;
  padding: 14px 18px;
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  color: var(--ag-text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.7;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .ag-sidebar { display: none; }
  .ag-content  { padding: 16px; }
  .ag-stats-grid { grid-template-columns: 1fr 1fr; }
  .ag-topbar { padding: 0 16px; }
}

/* ── Divider ── */
.ag-divider {
  height: 1px;
  background: var(--ag-border);
  margin: 20px 0;
}

/* ── Detail list ── */
.ag-detail-list { list-style: none; }
.ag-detail-list li {
  display: flex; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ag-border);
  font-size: 13px;
}
.ag-detail-list li:last-child { border-bottom: none; }
.ag-detail-label {
  width: 140px; flex-shrink: 0;
  font-weight: 700; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ag-text-faint);
  padding-top: 2px;
}
.ag-detail-value { color: var(--ag-text); }