/* ==========================================================
   Vista Ultimate Dashboard Panel â€” Design System
   Brand: #0185cd (Vista Blue)
   ========================================================== */

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

:root {
  /* Brand blue + shades */
  --brand-900: #012840;
  --brand-800: #013a5c;
  --brand-700: #015680;
  --brand-600: #016ba3;
  --brand-500: #0185cd;   /* base brand */
  --brand-400: #2ea1e0;
  --brand-300: #6cc0ec;
  --brand-200: #a9dcf5;
  --brand-100: #dcf0fb;
  --brand-050: #f1f9fd;

  /* Neutrals */
  --ink-900: #0e1b26;
  --ink-700: #33495a;
  --ink-500: #64748b;
  --ink-300: #b3c1cf;
  --ink-100: #e7edf2;
  --paper: #f6f9fb;
  --white: #ffffff;

  /* Status */
  --ok: #17a06b;
  --warn: #d68b00;
  --danger: #d1373f;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(1, 40, 64, 0.06);
  --shadow-md: 0 8px 24px rgba(1, 40, 64, 0.10);
  --shadow-lg: 0 20px 48px rgba(1, 40, 64, 0.16);

  --font-display: 'Sora', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink-900);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* ---------------- Auth (login) screen ---------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.auth-side {
  position: relative;
  background: radial-gradient(120% 140% at 15% 10%, var(--brand-600) 0%, var(--brand-800) 55%, var(--brand-900) 100%);
  color: var(--white);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.auth-side::before {
  content: "";
  position: absolute;
  inset: -20%;
  background-image:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 30% 30%, black 0%, transparent 70%);
  opacity: 0.7;
}

.auth-side .brandmark {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.2px;
}
.auth-side .brandmark .logo-dot {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--white);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  box-shadow: var(--shadow-md);
}

.auth-side .pitch {
  position: relative;
  max-width: 420px;
}
.auth-side .pitch h1 {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 14px;
}
.auth-side .pitch p {
  color: var(--brand-100);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}

.auth-side .footnote {
  position: relative;
  font-size: 12.5px;
  color: var(--brand-200);
}

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--white);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink-900);
}
.auth-card .sub {
  color: var(--ink-500);
  font-size: 14px;
  margin: 0 0 30px;
}

.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  font-size: 14.5px;
  border: 1.5px solid var(--ink-100);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink-900);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--brand-500);
  background: var(--white);
  box-shadow: 0 0 0 4px var(--brand-100);
}

.password-field { position: relative; }
.password-field input {
  padding-right: 42px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--ink-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
  transition: color .15s, background .15s;
}
.password-toggle:hover { color: var(--brand-600); background: var(--brand-050); }
.password-toggle:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand-500);
  color: var(--white);
  box-shadow: 0 6px 16px rgba(1, 133, 205, .32);
}
.btn-primary:hover { background: var(--brand-600); }
.btn-block { width: 100%; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--ink-100);
  color: var(--ink-700);
}
.btn-outline:hover { border-color: var(--brand-400); color: var(--brand-600); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b32e35; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.alert-error { background: #fdecee; color: #9c2b31; border: 1px solid #f6c8cb; }
.alert-success { background: #e8f7f0; color: #0f6b47; border: 1px solid #bfe8d5; }
.alert-info { background: var(--brand-050); color: var(--brand-700); border: 1px solid var(--brand-200); }

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 13px;
}

/* ---------------- App shell (post-login) ---------------- */
.app-shell {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--brand-900) 0%, var(--brand-800) 100%);
  color: var(--white);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar .brand .logo-dot {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--white);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-family: var(--font-display);
  flex-shrink: 0;
}
.sidebar .brand .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
}
.sidebar .brand .name small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--brand-200);
}

.nav-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--brand-300);
  padding: 0 10px;
  margin-bottom: 2px;
}

.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--brand-100);
  transition: background .15s;
}
.nav-links a:hover { background: rgba(255,255,255,.08); color: var(--white); }
.nav-links a.active { background: var(--brand-500); color: var(--white); font-weight: 600; }
.nav-links a i { font-size: 16px; width: 18px; text-align: center; }

.sidebar .spacer { flex: 1; }

.sidebar .user-box {
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  transition: background .15s;
  margin: 0 -6px;
  padding-left: 6px;
  padding-right: 6px;
  padding-bottom: 4px;
}
.sidebar .user-box:hover {
  background: rgba(255,255,255,.07);
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-400);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.user-box .who { font-size: 13px; line-height: 1.3; overflow: hidden; }
.user-box .who .uname { font-weight: 600; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.user-box .who .role { color: var(--brand-300); font-size: 11.5px; text-transform: capitalize; }

.main {
  padding: 28px 36px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
}
.topbar .eyebrow {
  font-size: 12.5px;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}
.topbar .actions { display: flex; gap: 10px; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 20px;
}

.preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--brand-600);
  color: var(--white);
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 20px;
}
.preview-banner i { margin-right: 4px; }

.preview-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
}
.preview-picker-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.preview-picker select {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--ink-100);
  background: var(--white);
  font-size: 13.5px;
  color: var(--ink-900);
  font-family: var(--font-body);
}
.preview-picker select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px var(--brand-100);
}

.dash-card {
  background: var(--white);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.dash-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
}
.dash-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-200);
}
.dash-card .icon-badge {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--brand-050);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px;
}
.dash-card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0;
  font-weight: 700;
}
.dash-card p {
  font-size: 13.5px;
  color: var(--ink-500);
  margin: 0;
  line-height: 1.5;
  flex: 1;
}
.dash-card .open-link {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--brand-600);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dash-card .open-link i { transition: transform .15s; }
.dash-card:hover .open-link i { transform: translateX(3px); }

.dash-card.is-inactive {
  opacity: 0.6;
}
.dash-card.is-inactive::before { background: var(--ink-300); }
.dash-card.is-inactive:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--ink-100); }
.dash-card.is-inactive .icon-badge { background: var(--ink-100); color: var(--ink-500); }

/* Toggle switch */
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: var(--ink-300);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background .18s ease;
}
.switch.on { background: var(--brand-500); }
.switch-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .18s ease;
}
.switch.on .switch-knob { transform: translateX(18px); }
.switch:hover { filter: brightness(1.05); }

.empty-state {
  border: 1.5px dashed var(--ink-300);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-500);
}
.empty-state i { font-size: 32px; color: var(--brand-300); margin-bottom: 12px; display: block; }

/* Panels / tables */
.panel {
  background: var(--white);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.panel-head h2 {
  font-family: var(--font-display);
  font-size: 16.5px;
  margin: 0;
  font-weight: 700;
}
.panel-head .desc { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-500);
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--ink-100);
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--brand-050); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-super { background: var(--brand-100); color: var(--brand-700); }
.badge-admin { background: var(--ink-100); color: var(--ink-700); }
.badge-active { background: #e5f6ee; color: var(--ok); }
.badge-inactive { background: #fdecee; color: var(--danger); }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--brand-050);
  color: var(--brand-700);
  border: 1px solid var(--brand-200);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 15, 26, .55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%; max-width: 460px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 18px;
}
.modal .actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.checkbox-grid label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
}

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--ink-100);
  background: var(--white);
  color: var(--ink-500);
  cursor: pointer;
  transition: all .15s;
}
.icon-btn:hover { border-color: var(--brand-400); color: var(--brand-600); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

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

/* ---------------- Mobile topbar (hidden on desktop) ---------------- */
.mobile-topbar {
  display: none;
}
.sidebar-backdrop {
  display: none;
}
.sidebar-close-btn {
  display: none;
}

@media (max-width: 980px) {
  html, body { overflow-x: hidden; }

  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { padding: 28px 20px; }

  .app-shell { grid-template-columns: 1fr; }

  /* Fixed top bar with hamburger, shown only on mobile */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--brand-900);
    color: var(--white);
    padding: 12px 16px;
  }
  .mobile-topbar .mobile-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
  }
  .mobile-topbar .logo-dot {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--white);
    color: var(--brand-600);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 13px;
  }
  .hamburger-btn, .sidebar-close-btn {
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 22px;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9px;
    cursor: pointer;
  }
  .hamburger-btn:active, .sidebar-close-btn:active { background: rgba(255,255,255,.12); }
  .mobile-avatar-link .avatar { width: 30px; height: 30px; font-size: 12px; }

  /* Off-canvas sidebar */
  .sidebar {
    position: fixed;
    z-index: 45;
    top: 0; left: 0;
    width: 78vw;
    max-width: 300px;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex; align-self: flex-end; margin-bottom: -8px; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(2, 15, 26, .55);
    z-index: 44;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  .main { padding: 18px 16px 48px; }

  /* Topbar inside page content */
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .topbar h1 { font-size: 20px; }
  .topbar .actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .topbar .actions .btn { width: 100%; }

  .preview-picker {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .preview-picker select { width: 100%; }

  .preview-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .preview-banner form { width: 100%; }
  .preview-banner button { width: 100%; }

  .dash-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .panel { padding: 18px; }

  /* Responsive tables: collapse into stacked cards */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100%;
  }
  .data-table tr {
    border: 1px solid var(--ink-100);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    padding: 6px 4px;
    box-shadow: var(--shadow-sm);
  }
  .data-table tr:hover td { background: transparent; }
  .data-table td {
    border-bottom: none;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-500);
    text-align: left;
    margin-right: auto;
  }
  .data-table td .chip-list,
  .data-table td .row-actions {
    justify-content: flex-end;
  }
  .data-table td[data-label="Dashboard Access"] {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .data-table td[data-label="Dashboard Access"]::before {
    margin-right: 0;
  }
  .data-table td[data-label="Dashboard Access"] .chip-list {
    justify-content: flex-start;
    width: 100%;
  }

  /* Modals full-width with tighter padding */
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal {
    max-width: 100%;
    width: 100%;
    padding: 20px;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 85vh;
  }
  .checkbox-grid { grid-template-columns: 1fr; }

  .auth-card { max-width: 100%; }
}

@media (max-width: 420px) {
  .main { padding: 14px 12px 40px; }
  .panel { padding: 14px; }
  .auth-main { padding: 20px 14px; }
  .topbar h1 { font-size: 18px; }
}