/* =============================================================
   FB-Tools — Global Design System
   style.css
   ============================================================= */

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

/* -------------------------------------------------------------
   CSS Custom Properties (Design Tokens)
   Direction: warm ink & cream, single teal accent, light mode only.
   ------------------------------------------------------------- */
:root {
  /* Fonts */
  --font-body:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading:   'Sora', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Brand / Primary — deep teal, used sparingly for primary actions only */
  --primary:        #0F6E56;
  --primary-hover:  #0B5744;
  --primary-light:  #E1F2ED;
  --primary-rgb:    15, 110, 86;

  /* Status Colors */
  --success:        #10B981;
  --success-light:  #D1FAE5;
  --success-rgb:    16, 185, 129;

  --warning:        #D97706;
  --warning-light:  #FEF3C7;
  --warning-rgb:    217, 119, 6;

  --danger:         #DC2626;
  --danger-light:   #FEE2E2;
  --danger-rgb:     220, 38, 38;

  --info:           #2563AF;
  --info-light:     #E1EDF9;

  /* Backgrounds — warm off-white / cream, not cold gray */
  --bg:             #F6F5F0;
  --surface:        #FFFFFF;
  --surface-raised: #FFFFFF;

  /* Sidebar is a deliberately distinct panel: deep ink, not the app's primary color */
  --sidebar-bg:      #1B1A17;
  --sidebar-bg-alt:  #232019;
  --sidebar-hover:   rgba(255,255,255,0.06);
  --sidebar-active:  rgba(255,255,255,0.08);
  --sidebar-text:    #C9C6BD;
  --sidebar-text-dim:#8A8780;
  --sidebar-accent:  #34C2A0;

  /* Text */
  --text-primary:   #211F1B;
  --text-secondary: #5C594F;
  --text-muted:     #8A8678;
  --text-faint:     #A9A596;
  --text-inverse:   #FFFFFF;

  /* Borders */
  --border:         #E6E3D9;
  --border-strong:  #D6D2C4;

  /* Card */
  --radius-card:    12px;
  --radius-sm:      8px;
  --radius-md:      10px;
  --radius-pill:    999px;
  --shadow-card:    0 1px 2px rgba(33,31,27,.05), 0 1px 1px rgba(33,31,27,.03);
  --shadow-raised:  0 8px 24px rgba(33,31,27,.08);
  --shadow-focus:   0 0 0 3px rgba(15,110,86,0.18);

  /* Spacing */
  --sidebar-width:  220px;
  --topbar-height:  60px;

  /* Transitions */
  --transition:     0.18s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

h1, h2, h3, h4, h5, h6,
.page-title, .card-title, .modal-title, .stat-card-value,
.hero-greeting, .sidebar-logo-text, .auth-title, .empty-state-title,
.dashboard-calendar-card .card-title {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

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

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-decoration: none !important;
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: var(--sidebar-accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg { width: 18px; height: 18px; fill: #1B1A17; }

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  list-style: none;
}

.sidebar-item { position: relative; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none !important;
  border-radius: 8px;
  margin: 1px 8px;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  white-space: nowrap;
  border-left: 2px solid transparent;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-link.active,
.sidebar-link[aria-current="page"] {
  background: var(--sidebar-active);
  color: #fff;
  border-left: 2px solid var(--sidebar-accent);
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-link.active svg { opacity: 1; color: var(--sidebar-accent); }

.sidebar-label { flex: 1; }

.sidebar-badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  text-align: center;
}

/* Settings submenu */
.sidebar-submenu {
  list-style: none;
  padding: 4px 0 4px 20px;
  display: none;
}

.sidebar-submenu.open { display: block; }

.sidebar-submenu .sidebar-link {
  font-size: 12.5px;
  padding: 7px 12px;
  color: var(--sidebar-text-dim);
}

.sidebar-submenu .sidebar-link:hover { color: #fff; }
.sidebar-submenu .sidebar-link.active { color: #fff; background: rgba(255,255,255,0.1); }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: 12px 24px 4px;
}

.sidebar-chevron {
  margin-left: auto;
  width: 14px !important;
  height: 14px !important;
  transition: transform var(--transition);
}

.sidebar-link.submenu-open .sidebar-chevron { transform: rotate(90deg); }

/* Topbar */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 90;
  transition: left var(--transition);
}

.topbar-logo { display: none; }

.topbar-search {
  flex: 1;
  max-width: 380px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 38px;
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.topbar-search input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.topbar-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  position: relative;
  transition: background var(--transition), color var(--transition);
}

.topbar-icon-btn:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.topbar-icon-btn svg { width: 20px; height: 20px; }

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--radius-pill);
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--transition);
  flex-shrink: 0;
  overflow: hidden;
}

.topbar-avatar:hover { border-color: var(--primary); }
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* "+ New" Button */
.btn-new {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), box-shadow var(--transition);
}

.btn-new:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(79,70,229,0.35);
}

.btn-new svg { width: 16px; height: 16px; }

/* Dropdown menus */
.dropdown-wrapper { position: relative; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
  min-width: 180px;
  z-index: 200;
  display: none;
  overflow: hidden;
  animation: dropdownIn 0.15s ease;
}

.dropdown-menu.open { display: block; }

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none !important;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--bg); color: var(--text-primary); }
.dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-light); }

.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* Notification dropdown */
.notif-dropdown {
  width: 340px;
  max-height: 480px;
  overflow-y: auto;
}

.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13.5px;
}

.notif-dropdown-header button {
  font-size: 12px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item.unread:hover { background: #E0E7FF; }

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 5px;
}

.notif-body { font-size: 13px; color: var(--text-secondary); }
.notif-body strong { color: var(--text-primary); }
.notif-time { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

/* Main content area */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-height));
  flex: 1;
}

/* -------------------------------------------------------------
   Page Header
   ------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* -------------------------------------------------------------
   Cards
   ------------------------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
  border: 1px solid var(--border);
}

.card-sm { padding: 16px; }
.card-lg { padding: 32px; }

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* -------------------------------------------------------------
   Buttons
   ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  text-decoration: none !important;
  line-height: 1.4;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg); color: var(--text-primary); }

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

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

.btn:disabled, .btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-loading { position: relative; }
.btn-loading::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* -------------------------------------------------------------
   Tables
   ------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead tr {
  border-bottom: 2px solid var(--border);
}

.data-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table thead th:first-child { padding-left: 20px; }

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }

.data-table tbody td {
  padding: 12px 14px;
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody td:first-child { padding-left: 20px; }

.col-num {
  width: 44px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
}

.col-checkbox { width: 40px; }

/* Checkbox */
.table-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Avatar cell */
.cell-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-lg { width: 44px; height: 44px; font-size: 14px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

.cell-name { font-weight: 500; color: var(--text-primary); }
.cell-sub  { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* -------------------------------------------------------------
   Status Pills / Badges
   ------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.pill-success  { background: var(--success-light);  color: #065F46; }
.pill-warning  { background: var(--warning-light);  color: #92400E; }
.pill-danger   { background: var(--danger-light);   color: #991B1B; }
.pill-info     { background: var(--info-light);     color: #1E40AF; }
.pill-gray     { background: var(--bg);             color: var(--text-muted); }
.pill-primary  { background: var(--primary-light);  color: var(--primary); }

/* -------------------------------------------------------------
   Form Controls
   ------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.form-control::placeholder { color: var(--text-faint); }
.form-control:disabled { opacity: 0.6; cursor: not-allowed; background: var(--bg); }

textarea.form-control { resize: vertical; min-height: 100px; line-height: 1.6; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; display: none; }
.form-error.visible { display: block; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Toggle Switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-wrapper:last-child { border-bottom: none; }

.toggle-info .toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-info .toggle-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* -------------------------------------------------------------
   Modals
   ------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  padding: 20px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.94) translateY(10px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-sm { max-width: 380px; }
.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 0;
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  border-radius: 4px;
  display: flex;
  transition: color var(--transition);
  flex-shrink: 0;
}

.modal-close:hover { color: var(--text-primary); }
.modal-close svg { width: 20px; height: 20px; }

.modal-body { padding: 20px 24px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 22px;
}

/* -------------------------------------------------------------
   Pages Visibility Dialog (Settings > Facebook Accounts)
   ------------------------------------------------------------- */
.btn-link-pages {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}
.btn-link-pages:hover { text-decoration: underline; }

.pages-dialog-account {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pages-dialog-list {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pages-dialog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
}
.pages-dialog-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.pages-dialog-row:hover { background: var(--bg); }

.pages-dialog-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pages-dialog-num {
  font-size: 12px;
  color: var(--text-faint);
  width: 20px;
  flex-shrink: 0;
}

/* -------------------------------------------------------------
   Toast Notifications
   ------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: toastIn 0.25s ease;
  font-size: 13.5px;
}

.toast.dismissing { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-message { flex: 1; color: var(--text-secondary); line-height: 1.4; }
.toast-message strong { display: block; color: var(--text-primary); font-weight: 600; margin-bottom: 2px; }

.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--info); }

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

.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  opacity: 0.35;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state-desc { font-size: 13.5px; margin-bottom: 20px; }

/* -------------------------------------------------------------
   Loading Spinner
   ------------------------------------------------------------- */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
.spinner-lg { width: 48px; height: 48px; border-width: 4px; }

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

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

/* -------------------------------------------------------------
   Stat Cards
   ------------------------------------------------------------- */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-change {
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.stat-icon svg { width: 20px; height: 20px; }
.stat-icon-primary { background: var(--primary-light); color: var(--primary); }
.stat-icon-success { background: var(--success-light); color: var(--success); }
.stat-icon-warning { background: var(--warning-light); color: var(--warning); }
.stat-icon-info    { background: var(--info-light);    color: var(--info); }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-cols-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

/* -------------------------------------------------------------
   Progress Bar
   ------------------------------------------------------------- */
.progress-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 7px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: width 0.4s ease;
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger  { background: var(--danger); }

.progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

/* -------------------------------------------------------------
   Tabs
   ------------------------------------------------------------- */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color var(--transition);
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform var(--transition);
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); font-weight: 600; }
.tab-btn.active::after { transform: scaleX(1); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* -------------------------------------------------------------
   Action Menu (gear/dots)
   ------------------------------------------------------------- */
.action-menu-wrapper { position: relative; display: inline-block; }

.action-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 5px;
  border-radius: 6px;
  display: flex;
  transition: background var(--transition), color var(--transition);
}

.action-menu-btn:hover { background: var(--bg); color: var(--text-primary); }
.action-menu-btn svg { width: 17px; height: 17px; }

/* -------------------------------------------------------------
   Support Widget
   ------------------------------------------------------------- */
.support-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
}

.support-btn {
  width: 50px;
  height: 50px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(79,70,229,0.4);
  transition: transform var(--transition), box-shadow var(--transition);
}

.support-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(79,70,229,0.5);
}

.support-btn svg { width: 22px; height: 22px; }

.support-dismiss {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
}

.support-dismiss svg { width: 11px; height: 11px; }

/* -------------------------------------------------------------
   Filter / Toolbar Row
   ------------------------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar-search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.toolbar-search input {
  width: 100%;
  padding: 7px 10px 7px 33px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
}

.toolbar-search input:focus { border-color: var(--primary); }

.toolbar-search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.toolbar-select {
  padding: 7px 30px 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: none;
}

.toolbar-select:focus { border-color: var(--primary); }

/* -------------------------------------------------------------
   Misc
   ------------------------------------------------------------- */
.text-muted    { color: var(--text-muted); }
.text-primary  { color: var(--primary); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.justify-between { justify-content: space-between; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.external-link { display: inline-flex; align-items: center; gap: 3px; }
.external-link svg { width: 12px; height: 12px; }

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.confirm-box {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-raised);
  padding: 28px;
  max-width: 380px;
  width: 100%;
}

.confirm-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.confirm-body  { font-size: 13.5px; color: var(--text-muted); margin-bottom: 22px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* -------------------------------------------------------------
   Responsive
   ------------------------------------------------------------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  .sidebar {
    transform: translateX(-220px);
    width: 220px;
    transition: transform var(--transition);
  }

  .sidebar.open { transform: translateX(0); }

  .topbar { left: 0; }
  .topbar-logo { display: flex; }

  .main-content { margin-left: 0; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .form-row { grid-template-columns: 1fr; }

  .page-header { flex-direction: column; align-items: flex-start; }
}
