/* ============================================================
   ClinicPlugin Admin — Complete Design System
   Palette: teal accent (#0d9488), slate neutrals, white surfaces
   ============================================================ */

/* ---- Variables ---- */
:root {
  --bg:          #f8fafc;
  --bg-2:        #f1f5f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --border-2:    #cbd5e1;
  --ink:         #0f172a;
  --ink-2:       #475569;
  --ink-3:       #94a3b8;
  --ink-4:       #cbd5e1;
  --accent:      #0d9488;
  --accent-2:    #0f766e;
  --accent-bg:   #f0fdfa;
  --accent-ink:  #134e4a;
  --warn:        #d97706;
  --warn-bg:     #fffbeb;
  --warn-border: #fde68a;
  --ok:          #16a34a;
  --ok-bg:       #f0fdf4;
  --ok-border:   #bbf7d0;
  --bad:         #dc2626;
  --bad-bg:      #fef2f2;
  --bad-border:  #fecaca;
  --info:        #3b82f6;
  --info-bg:     #eff6ff;
  --info-border: #bfdbfe;
  --radius:      8px;
  --radius-sm:   6px;
  --radius-lg:   12px;
  --shadow-1:    0 1px 2px rgba(15,23,42,.06), 0 1px 0 rgba(15,23,42,.04);
  --shadow-2:    0 4px 6px rgba(15,23,42,.07), 0 10px 15px rgba(15,23,42,.1);
  --sidebar-w:   232px;
  --topbar-h:    56px;
  --mono:        "JetBrains Mono", "Courier New", monospace;
  --sans:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
img { max-width: 100%; }

/* ============================================================
   LAYOUT SHELL
   ============================================================ */

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
}
.logo-mark::after {
  content: "";
  position: absolute;
  width: 8px; height: 2px;
  background: var(--accent);
  bottom: 6px;
}
.logo-mark::before {
  content: "";
  position: absolute;
  width: 2px; height: 8px;
  background: var(--accent);
  bottom: 3px;
}
.brand-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.ver-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.sidebar__nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}
.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-4);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13px;
  text-decoration: none;
  position: relative;
  transition: background 80ms, color 80ms;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.nav-item.is-active {
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 500;
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -8px; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-icon {
  width: 16px; height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-icon svg { width: 16px; height: 16px; stroke-linecap: round; stroke-linejoin: round; }
.nav-item .nav-icon { color: var(--ink-3); }
.nav-item.is-active .nav-icon { color: var(--accent); }
.nav-label { flex: 1; }

.sidebar__foot {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--ink-3); }
.logout-btn {
  color: var(--ink-3);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  transition: background 80ms, color 80ms;
  flex-shrink: 0;
}
.logout-btn svg { width: 15px; height: 15px; }
.logout-btn:hover { background: var(--bad-bg); color: var(--bad); text-decoration: none; }

/* ---- Topbar ---- */
.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.breadcrumb {
  font-size: 12px;
  color: var(--ink-3);
}
.breadcrumb strong { color: var(--ink); }
.sep { margin: 0 6px; color: var(--ink-4); }
.topbar-spacer { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.search-form { display: flex; }
.search-input {
  width: 260px;
  height: 32px;
  padding: 0 10px 0 32px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--bg-2)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>")
    no-repeat 10px center;
  font-size: 12.5px;
  outline: none;
  transition: border-color 80ms, box-shadow 80ms;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
  background-color: var(--surface);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
}
.hamburger span {
  display: block;
  width: 18px; height: 2px;
  background: var(--ink-2);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ---- Main content ---- */
.main-content {
  grid-area: main;
  padding: 24px 28px 48px;
  overflow-x: auto;
  min-width: 0;
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 18px;
  animation: slideDown .2s ease;
}
.flash--success { background: var(--ok-bg); color: #14532d; border: 1px solid var(--ok-border); }
.flash--error   { background: var(--bad-bg); color: #7f1d1d; border: 1px solid var(--bad-border); }
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 80ms, border-color 80ms;
}
.btn:hover { background: var(--bg-2); text-decoration: none; color: var(--ink); }
.btn:active { background: var(--border); }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn--primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn--primary:hover { background: #1e293b; color: #fff; }

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

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

.btn--danger { border-color: var(--bad); color: var(--bad); background: var(--surface); }
.btn--danger:hover { background: var(--bad-bg); }

.btn--sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn--icon { width: 32px; padding: 0; justify-content: center; }
.btn--icon.btn--sm { width: 26px; }

.btn-group {
  display: inline-flex;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.btn-group .btn {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--border);
}
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn.is-active { background: var(--ink); color: #fff; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.field .req { color: var(--bad); }
.field .help { font-size: 11.5px; color: var(--ink-3); }
.field-row { display: flex; gap: 12px; align-items: flex-end; }

.input, .select, .textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 80ms, box-shadow 80ms;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
.textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
.input--sm, .select--sm { height: 28px; font-size: 12px; }

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}
.checkbox input, .radio input { width: 14px; height: 14px; accent-color: var(--accent); }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 8px; }
.toggle { position: relative; display: inline-block; width: 32px; height: 18px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-2);
  border-radius: 999px;
  transition: background 120ms;
  cursor: pointer;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 120ms;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); }

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: var(--bg-2);
  color: var(--ink-3);
  font-size: 12.5px;
  cursor: pointer;
}
.dropzone strong { color: var(--ink); font-weight: 600; }
.dropzone:hover { border-color: var(--accent); background: var(--accent-bg); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.badge--plain::before { display: none; }
.badge--pending   { background: var(--warn-bg);  color: #92400e; border: 1px solid var(--warn-border); }
.badge--pending::before   { background: var(--warn); }
.badge--confirmed { background: var(--ok-bg);   color: #14532d; border: 1px solid var(--ok-border); }
.badge--confirmed::before { background: var(--ok); }
.badge--cancelled { background: var(--bad-bg);  color: #7f1d1d; border: 1px solid var(--bad-border); }
.badge--cancelled::before { background: var(--bad); }
.badge--info      { background: var(--info-bg); color: #1e40af; border: 1px solid var(--info-border); }
.badge--info::before      { background: var(--info); }
.badge--accent    { background: var(--accent-bg); color: var(--accent-ink); border: 1px solid rgba(13,148,136,.3); }
.badge--accent::before    { background: var(--accent); }
.badge--plain     { background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--border); padding: 0 8px; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  border: 1px solid rgba(13,148,136,.2);
}
.avatar--lg { width: 40px; height: 40px; font-size: 13px; }
.avatar--sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-name { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card__head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card__head .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.card__body { padding: 16px; }
.card__foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 12px;
  color: var(--ink-3);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.table-toolbar .input--search { width: 260px; }
.table-toolbar .spacer { flex: 1; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--ink);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-2); }
.col-id    { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.col-check { width: 32px; }
.col-right { text-align: right; }
.col-actions { text-align: right; white-space: nowrap; }
.col-num   { font-variant-numeric: tabular-nums; text-align: right; }
.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  font-size: 12px;
  color: var(--ink-3);
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: inline-flex; gap: 3px; }
.pg {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 80ms;
}
.pg:hover { background: var(--bg-2); text-decoration: none; color: var(--ink); }
.pg.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.pg.disabled { opacity: 0.4; pointer-events: none; cursor: default; }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  background: var(--surface);
  overflow-x: auto;
}
.tab {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
  transition: color 80ms;
}
.tab .count {
  background: var(--bg-2);
  color: var(--ink-3);
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 7px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 500;
}
.tab.is-active .count { background: var(--accent-bg); color: var(--accent-ink); }

.subtabs {
  display: inline-flex;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.subtab {
  padding: 5px 12px;
  font-size: 12.5px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink-2);
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  white-space: nowrap;
}
.subtab:hover { color: var(--ink); text-decoration: none; }
.subtab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
}

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}
.kpi .label {
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.kpi .value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
}
.kpi .delta {
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi .delta.up   { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }

/* ============================================================
   PAGE HEAD
   ============================================================ */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.page-head p  { margin: 0; font-size: 13px; color: var(--ink-3); }
.page-head-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.modal--lg { max-width: 720px; }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal__head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal__body { padding: 20px; overflow-y: auto; flex: 1; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.modal-close {
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}
.modal-close:hover { color: var(--ink); }
.modal-close svg { width: 16px; height: 16px; }

/* ============================================================
   GRID UTILITIES
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.row    { display: flex; align-items: center; gap: 8px; }
.stack  { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }
.col-2 { grid-column: 1 / -1; }
.muted  { color: var(--ink-3); }
.mono   { font-family: var(--mono); font-size: 12px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; border: none; }
.spacer { flex: 1; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mb-0  { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-16 { margin-top: 16px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fs-12  { font-size: 12px; }
.fs-11  { font-size: 11.5px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-3);
}
.empty svg { width: 32px; height: 32px; margin-bottom: 10px; }
.empty h4  { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.empty p   { margin: 0; font-size: 12.5px; }

/* ============================================================
   ICON BUTTON
   ============================================================ */
.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  transition: background 80ms;
}
.icon-btn:hover { background: var(--bg-2); }
.icon-btn svg { width: 14px; height: 14px; }

/* ============================================================
   CALENDAR PAGE
   ============================================================ */
.cal-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: flex-start;
}
.cal-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-list__head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-list__head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.cal-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background 80ms;
}
.cal-item:hover { background: var(--bg-2); text-decoration: none; }
.cal-item.is-active { background: var(--accent-bg); }
.cal-item.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.cal-swatch { width: 10px; height: 10px; border-radius: 3px; margin-top: 4px; flex-shrink: 0; }
.cal-item-info .n { font-size: 13px; font-weight: 500; }
.cal-item-info .m { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

.cal-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-grid__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.cal-grid__head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.cal-month-table {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-dow {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
}
.cal-dow:last-child { border-right: none; }
.cal-day {
  min-height: 80px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 12px;
  background: var(--surface);
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.muted-day { background: var(--bg-2); color: var(--ink-4); }
.cal-day.is-today { background: rgba(13,148,136,.05); }
.cal-day.is-today .day-num {
  background: var(--accent);
  color: #fff;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.cal-day.is-holiday { background: rgba(220,38,38,.04); }
.day-num { font-weight: 500; }
.holiday-tag { display: block; font-size: 10px; color: var(--bad); margin-top: 2px; }
.cal-event {
  display: block;
  background: var(--accent-bg);
  color: var(--accent-ink);
  border-left: 2px solid var(--accent);
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 3px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event.warn { background: var(--warn-bg); border-color: var(--warn); color: #92400e; }
.cal-event.bad  { background: var(--bad-bg);  border-color: var(--bad); color: #7f1d1d; }

/* Slot grid */
.slot-grid {
  display: grid;
  grid-template-columns: 72px repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 11.5px;
}
.slot-grid .sh, .slot-grid .st {
  padding: 6px 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.slot-grid .sh {
  background: var(--bg-2);
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  font-size: 10.5px;
  text-align: center;
  letter-spacing: 0.04em;
}
.slot-grid .sh.off { color: var(--ink-4); }
.slot-grid .st.time-label {
  font-family: var(--mono);
  color: var(--ink-3);
  background: var(--bg-2);
  text-align: right;
  padding-right: 8px;
  font-size: 10.5px;
}
.slot-grid .st.on  { background: rgba(13,148,136,.08); color: var(--accent-ink); cursor: pointer; text-align: center; }
.slot-grid .st.on:hover { background: rgba(13,148,136,.15); }
.slot-grid .st.off { background: var(--bg-2); color: var(--ink-4); text-align: center; }
.slot-grid .st.full { background: var(--bad-bg); color: #7f1d1d; text-align: center; font-weight: 600; }

/* ============================================================
   LEADS KANBAN
   ============================================================ */
.pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.pipe-col {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 300px;
}
.pipe-col__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 4px;
}
.pipe-col__head .t {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-2);
}
.pipe-col__head .c { font-size: 11px; color: var(--ink-3); }
.pipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  box-shadow: var(--shadow-1);
}
.pipe-card .n { font-size: 13px; font-weight: 500; }
.pipe-card .m { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.pipe-card .actions { display: flex; gap: 4px; margin-top: 8px; }

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.tpl-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: flex-start;
}
.tpl-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tpl-item {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  text-decoration: none;
  display: block;
  color: inherit;
  transition: background 80ms;
}
.tpl-item:last-child { border-bottom: none; }
.tpl-item:hover { background: var(--bg-2); text-decoration: none; }
.tpl-item.is-active { background: var(--accent-bg); }
.tpl-item.is-active::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
}
.tpl-item .n { font-size: 13px; font-weight: 500; }
.tpl-item .m { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

.var-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  border: 1px solid rgba(13,148,136,.3);
  margin: 2px;
}
.var-chip:hover { background: rgba(13,148,136,.15); }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: flex-start;
}
.settings-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  position: sticky;
  top: 76px;
}
.settings-nav a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 80ms, color 80ms;
  margin-bottom: 2px;
}
.settings-nav a:hover { background: var(--bg-2); color: var(--ink); }
.settings-nav a.is-active { background: var(--accent-bg); color: var(--accent-ink); font-weight: 500; }

/* ============================================================
   API KEYS
   ============================================================ */
.api-key-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
}
.api-key-box .v { flex: 1; color: var(--ink); letter-spacing: 0.02em; }
.endpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
}
.method {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.method.post { background: var(--ok-bg); color: #14532d; }
.method.get  { background: var(--info-bg); color: #1e40af; }
.method.del  { background: var(--bad-bg); color: #7f1d1d; }
.endpoint .path { font-family: var(--mono); font-size: 12.5px; flex: 1; }

.code-box {
  background: #1e293b;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 12px;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  overflow-x: auto;
}

/* ============================================================
   PERMISSIONS MATRIX
   ============================================================ */
.perm-matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.perm-matrix th, .perm-matrix td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.perm-matrix th { background: var(--bg-2); font-weight: 600; color: var(--ink-2); text-align: center; font-size: 11.5px; }
.perm-matrix th:first-child { text-align: left; }
.perm-matrix td:first-child { font-weight: 500; color: var(--ink-2); }
.perm-matrix td.center { text-align: center; }
.check-yes { color: var(--ok); }
.check-no  { color: var(--ink-4); }

/* ============================================================
   FORMS BUILDER
   ============================================================ */
.fb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-1);
}
.fb-card .fb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.fb-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-left {
  background: linear-gradient(160deg, #0f766e 0%, #134e4a 100%);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; }
.login-logo .mark {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
}
.login-logo .name { font-size: 17px; font-weight: 600; }
.login-hero h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 14px; line-height: 1.15; }
.login-hero p  { font-size: 15px; line-height: 1.55; opacity: .85; margin: 0 0 28px; max-width: 380px; }
.login-feat { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; margin-bottom: 10px; opacity: .9; }
.login-feat-check {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  margin-top: 1px;
}
.login-footer { font-size: 11.5px; opacity: .55; font-family: var(--mono); }
.login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-box {
  width: 100%;
  max-width: 400px;
}
.login-box h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.login-box .sub { color: var(--ink-3); font-size: 13.5px; margin-bottom: 28px; }
.login-box .field { margin-bottom: 14px; }
.login-box .btn { width: 100%; height: 38px; justify-content: center; font-size: 14px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 45;
}

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    width: var(--sidebar-w);
    transition: left .25s ease;
    z-index: 50;
  }
  .sidebar.is-open { left: 0; }
  .sidebar-overlay.is-on { display: block; }
  .hamburger { display: flex; }
  .topbar { grid-column: 1; }
  .main-content { grid-column: 1; padding: 16px; }
  .cal-shell, .tpl-shell, .settings-shell { grid-template-columns: 1fr; }
  .login-body { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .search-input { width: 160px; }
  .fb-stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
}
