/* Werang Personal Assistant - Web Admin
   UI/UX inspired by project@01 design system (localhost:8100)
*/

:root {
  /* Brand */
  --brand-50:  #edfaf3;
  --brand-100: #d1f6e1;
  --brand-200: #a6efc8;
  --brand-300: #6fe5a5;
  --brand-600: #3c9466;
  --brand-700: #27744e;
  --brand-800: #1c5f39;
  --brand-900: #0e401f;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Semantic */
  --bg:           #f4f7fb;
  --surface:      #ffffff;
  --surface-soft: #f8fafc;
  --text:         var(--gray-900);
  --text-muted:   var(--gray-500);
  --border:       var(--gray-200);
  --primary:      var(--brand-300);
  --primary-h:    var(--brand-700);
  --danger:       #ef4444;
  --danger-h:     #dc2626;
  --warning:      #f59e0b;
  --success:      #10b981;

  /* Sidebar */
  --sidebar-bg:     #0f172a;
  --sidebar-text:   #94a3b8;
  --sidebar-text-h: #ffffff;
  --sidebar-active: rgba(15,143,85,.18);
  --sidebar-w:      220px;

  /* Misc */
  --radius:     12px;
  --radius-sm:  8px;
  --radius-xs:  6px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
  --transition: all 150ms ease;
}

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

html, body {
  height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ━━ Layout shell ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.app-shell { display: flex; min-height: 100vh; }

/* ━━ Sidebar ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1.2rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand-300), var(--brand-700));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; font-weight: 800;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: .88rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -.01em;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: .72rem;
  color: var(--sidebar-text);
  font-weight: 400;
}

.sidebar-nav { padding: .75rem .6rem; flex: 1; }
.sidebar-section { margin-bottom: .2rem; }
.sidebar-section-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gray-600);
  padding: .75rem .5rem .3rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .52rem .75rem;
  margin-bottom: 2px;
  border-radius: var(--radius-xs);
  font-size: .84rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: var(--sidebar-active); color: #14d399; }
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: .75rem .6rem 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
}

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

.topbar {
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.6rem;
  gap: 1rem;
  justify-content: space-between;
}

.topbar-title { font-size: .9rem; font-weight: 600; color: var(--gray-700); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: var(--gray-600);
  font-weight: 500;
}

.topbar-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--brand-300), var(--brand-700));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; color: #fff; font-weight: 700;
}

.page-content { padding: 1.5rem; }

/* ━━ Page hero ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.page-hero {
  background: linear-gradient(135deg, #0f172a 0%, #0c3425 55%, var(--brand-700) 100%);
  border-radius: var(--radius);
  padding: 1.6rem;
  margin-bottom: 1.2rem;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: "";
  position: absolute;
  top: -60px; right: -60px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(52,211,153,.25) 0%, transparent 70%);
  border-radius: 50%;
}

.page-hero-eyebrow {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6ee7b7;
  margin-bottom: .4rem;
}

.page-hero-title { font-size: 1.5rem; font-weight: 800; line-height: 1.2; letter-spacing: -.02em; }
.page-hero-sub { font-size: .85rem; color: #a7f3d0; margin-top: .35rem; }

/* ━━ Cards ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: .88rem;
  color: var(--gray-700);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: .9rem;
  color: var(--gray-800);
}

.card-body { padding: 1.2rem; }
.card-footer { padding: .75rem 1.2rem; border-top: 1px solid var(--border); }

/* ━━ KPI stat cards ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-icon.green { background: var(--brand-100); color: var(--brand-600); }
.stat-icon.blue  { background: #dbeafe; color: #2563eb; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.red   { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-800);
  line-height: 1;
  letter-spacing: -.02em;
}

.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

/* ━━ Integration status cards ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.integration-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.2rem;
  border-left: 3px solid var(--border);
  transition: var(--transition);
}

.integration-card.connected { border-left-color: var(--success); }
.integration-card.disconnected { border-left-color: var(--gray-300); }

.integration-name { font-weight: 700; font-size: .9rem; color: var(--gray-800); margin-bottom: .25rem; }
.integration-status { font-size: .78rem; }
.integration-status.on { color: var(--success); }
.integration-status.off { color: var(--text-muted); }

/* ━━ Buttons ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  line-height: 1;
  font-size: .84rem;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--brand-600);
  color: #fff;
  border-color: var(--brand-600);
  box-shadow: 0 1px 3px rgba(15,143,85,.3);
}
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover { background: #059669; color: #fff; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-h); color: #fff; }

.btn-outline-primary {
  background: transparent;
  color: var(--brand-600);
  border-color: var(--brand-600);
}
.btn-outline-primary:hover { background: var(--brand-50); }

.btn-outline-secondary {
  background: #fff;
  color: var(--gray-600);
  border-color: var(--gray-300);
}
.btn-outline-secondary:hover { background: var(--gray-50); }

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-outline-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: .35rem .7rem; font-size: .78rem; border-radius: var(--radius-xs); }
.btn-lg { padding: .72rem 1.4rem; font-size: .96rem; }

.btn-link {
  background: none; border: none;
  color: var(--brand-600);
  padding: 0; font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
}
.btn-link:hover { color: var(--brand-700); text-decoration-color: currentColor; }

/* ━━ Forms ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: .3rem;
  letter-spacing: .01em;
}

.form-control, .form-select, textarea {
  width: 100%;
  padding: .58rem .75rem;
  font-size: .84rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-xs);
  background: #fff;
  color: var(--text);
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 120ms, box-shadow 120ms;
}

.form-control::placeholder, .form-select::placeholder { color: var(--gray-400); }

.form-control:focus, .form-select:focus, textarea:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(60,148,102,.15);
}

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.15); }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
  padding-right: 2.5rem;
  appearance: none;
  cursor: pointer;
}

.form-text { font-size: .74rem; color: var(--text-muted); margin-top: .25rem; }
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check-input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--brand-600); }
.form-check-label { font-size: .84rem; color: var(--gray-700); cursor: pointer; }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-xs) 0 0 var(--radius-xs); flex: 1; }
.input-group .btn { border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }

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

/* ━━ Tables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.table th, .table td { padding: .62rem .8rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; text-align: left; }
.table thead {
  background: var(--gray-50);
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--gray-500);
  white-space: nowrap;
}
.table-hover tbody tr { transition: background 80ms; }
.table-hover tbody tr:hover { background: #f0fdf7; }
.table-striped tbody tr:nth-child(even) { background: var(--gray-50); }

/* ━━ Badges ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.badge {
  display: inline-flex; align-items: center;
  padding: .22em .65em;
  font-size: .7rem; font-weight: 700;
  border-radius: 99px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-primary { background: var(--brand-100); color: var(--brand-800); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* ━━ Alerts ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .84rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: 1rem;
}
.alert-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert-success { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.alert-warning { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
.alert-info    { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }

.alert-close {
  margin-left: auto;
  background: none; border: none;
  cursor: pointer; opacity: .6;
  font-size: 1rem; line-height: 1;
  color: inherit;
}
.alert-close:hover { opacity: 1; }

/* ━━ Toast notification ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  background: var(--gray-900);
  color: #f1f5f9;
  padding: .8rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: .5rem;
  pointer-events: auto;
  animation: toastIn .22s ease;
  max-width: 360px;
}
.toast.toast-success { border-left: 3px solid #34d399; }
.toast.toast-error   { border-left: 3px solid #ef4444; }
.toast.toast-info    { border-left: 3px solid #60a5fa; }
.toast.toast-warning { border-left: 3px solid #fbbf24; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* ━━ Login page ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #083422 50%, var(--brand-700) 100%);
  padding: 1.5rem;
}

.login-card {
  background: rgba(255,255,255,.97);
  border-radius: var(--radius);
  padding: 2.4rem 2.2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.8rem;
}

.login-logo-icon {
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--brand-300), var(--brand-700));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff; font-weight: 800;
  flex-shrink: 0;
}

.login-logo-text {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.02em;
  line-height: 1.2;
}

.login-logo-sub {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: .3rem;
}

.login-subtitle {
  font-size: .84rem;
  color: var(--text-muted);
  margin-bottom: 1.6rem;
}

/* ━━ Register page ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.register-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #083422 50%, var(--brand-700) 100%);
  padding: 2rem 1.5rem;
}

.register-card {
  background: rgba(255,255,255,.97);
  border-radius: var(--radius);
  padding: 2.2rem;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

/* ━━ Settings tabs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.settings-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.settings-tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1rem;
  font-size: .84rem;
  font-weight: 600;
  color: var(--gray-500);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  white-space: nowrap;
}

.settings-tab:hover { color: var(--gray-700); }
.settings-tab.active { color: var(--brand-600); border-bottom-color: var(--brand-600); }

/* ━━ Connection test block ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.connection-test-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 1rem;
}

.connection-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gray-300);
  flex-shrink: 0;
  transition: background 300ms;
}
.connection-dot.success { background: var(--success); }
.connection-dot.error   { background: var(--danger); }
.connection-dot.testing { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.connection-status-text { font-size: .82rem; color: var(--text-muted); flex: 1; }

/* ━━ API key masked input ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.api-key-group { position: relative; }
.api-key-group .form-control { padding-right: 2.8rem; }
.api-key-toggle {
  position: absolute;
  right: .5rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--gray-400);
  padding: .2rem;
}
.api-key-toggle:hover { color: var(--gray-600); }

/* ━━ Section heading ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  margin-bottom: 1rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}

/* ━━ Divider ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ━━ Utilities ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.d-flex { display: flex; }
.d-grid { display: grid; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.w-100 { width: 100%; }
.flex-1 { flex: 1; }
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.small { font-size: .82rem; }
.smaller { font-size: .74rem; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .35rem !important; }
.mb-2 { margin-bottom: .6rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.4rem !important; }
.mt-1 { margin-top: .35rem !important; }
.mt-2 { margin-top: .6rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.4rem !important; }
.me-1 { margin-right: .35rem !important; }
.me-2 { margin-right: .6rem !important; }
.ms-auto { margin-left: auto !important; }
.p-0 { padding: 0 !important; }

/* ━━ Empty state ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
.empty-state-text { font-size: .9rem; }

/* ━━ Responsive sidebar toggle ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 250ms ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 1rem; }
  .sidebar-toggle { display: flex; }
  .page-content { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

/* Genspark chat thread */
.chat-thread {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.75rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-bubble {
  max-width: 92%;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.chat-bubble-user {
  align-self: flex-end;
  background: var(--brand-100);
  color: var(--gray-900);
}
.chat-bubble-assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* Page flow (UI ↔ backend SSOT) */
.page-flow {
  border: 1px dashed var(--border);
  background: var(--surface-soft);
}
.page-flow-label {
  letter-spacing: 0.02em;
}
.page-flow-steps li {
  margin-bottom: 0.15rem;
}

/* PWA install hint (dashboard) */
.pwa-install-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.55);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.pwa-install-dialog {
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

/* ━━ Loading spinner ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
.spinner-dark {
  border-color: rgba(0,0,0,.1);
  border-top-color: var(--brand-600);
}

@keyframes spin { to { transform: rotate(360deg); } }
