:root {
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --sidebar:   #0f172a;
  --text:      #0f172a;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --primary:   #6366f1;
  --primary-h: #4f46e5;
  --green:     #10b981;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --sw:        260px;
  --nh:        62px;
}

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

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sw);
  background: var(--sidebar);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 2px;
  z-index: 200;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  margin-bottom: 6px;
  min-width: 0;
}

.brand-mark {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: 7px;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-mark.has-logo {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.7);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-text {
  min-width: 0;
  flex: 1;
}

.brand-name {
  font-size: .88rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub  {
  font-size: .7rem;
  color: rgba(255,255,255,.38);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 7px;
  text-decoration: none;
  font-size: .84rem;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  transition: background .13s, color .13s;
}

.nav-link:hover  { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.nav-link.active { background: rgba(99,102,241,.25);  color: #fff; }

.nav-icon { width: 17px; height: 17px; display: grid; place-items: center; flex-shrink: 0; }
.nav-icon svg { width: 17px; height: 17px; }
.nav-icon i { font-size: 15px; line-height: 1; width: 15px; text-align: center; }

.sidebar-promo {
  margin-top: auto;
  padding-top: 16px;
}

.sidebar-promo-inner {
  background: rgba(99,102,241,.15);
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 10px;
  padding: 14px;
}

.sidebar-promo-inner p:first-child { font-size: .8rem; font-weight: 700; color: #fff; margin-bottom: 4px; }
.sidebar-promo-inner p:last-of-type { font-size: .73rem; color: rgba(255,255,255,.45); line-height: 1.5; margin-bottom: 12px; }

/* ── Main ── */
.main {
  margin-left: var(--sw);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Navbar ── */
.navbar {
  height: var(--nh);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.menu-btn {
  display: none;
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 7px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  place-items: center;
  flex-shrink: 0;
}

.nav-search {
  flex: 1;
  max-width: 300px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  position: relative;
}

.nav-search svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.nav-search i { width: 14px; font-size: 13px; color: var(--muted); flex-shrink: 0; text-align: center; }
.nav-search input { border: none; background: none; outline: none; font-family: inherit; font-size: .83rem; color: var(--text); width: 100%; }
.nav-search input::placeholder { color: var(--muted); }

.global-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 180;
  overflow: hidden;
  max-height: min(68vh, 520px);
  overflow-y: auto;
}

.global-search-empty {
  padding: 12px;
  font-size: .8rem;
  color: var(--muted);
}

.global-search-group + .global-search-group {
  border-top: 1px solid var(--border);
}

.global-search-group-title {
  padding: 9px 12px 6px;
  font-size: .67rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.global-search-item {
  display: block;
  text-decoration: none;
  padding: 8px 12px 10px;
  border-top: 1px dashed rgba(148, 163, 184, 0.16);
}

.global-search-item:hover {
  background: rgba(59, 130, 246, 0.09);
}
.global-search-item.global-search-item-active {
  background: rgba(59, 130, 246, 0.12);
}

.global-search-item:first-of-type {
  border-top: none;
}

.global-search-item-title {
  font-size: .8rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
}

.global-search-item-subtitle {
  margin-top: 2px;
  font-size: .74rem;
  color: var(--muted);
  line-height: 1.35;
}

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; position: relative; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--muted);
  position: relative;
  transition: background .13s, color .13s;
}

.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn i { font-size: 15px; line-height: 1; }

.icon-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notifications-popover {
  position: absolute;
  top: 42px;
  right: 0;
  width: min(420px, calc(100vw - 28px));
  max-height: min(520px, calc(100vh - 90px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .2);
  overflow: hidden;
  z-index: 420;
}

.notifications-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text);
}

.notifications-popover-head .row-btn {
  width: auto;
  height: auto;
  min-height: 30px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.notifications-popover-head .row-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #c7d0db;
}

.notifications-popover-list {
  max-height: min(430px, calc(100vh - 150px));
  overflow: auto;
}

.notifications-item {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.notifications-item:hover {
  background: #f8fafc;
}

.notifications-item.unread {
  background: #f8fbff;
}

.notifications-item-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text);
}

.notifications-item-message {
  margin-top: 2px;
  font-size: .74rem;
  color: #475569;
  line-height: 1.4;
}

.notifications-item-time {
  margin-top: 4px;
  font-size: .7rem;
  color: #94a3b8;
}

.notifications-empty {
  padding: 14px 12px;
  font-size: .78rem;
  color: var(--muted);
}

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  background: var(--primary);
  border-radius: 50%;
  border: 1.5px solid var(--card);
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: grid; place-items: center;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

/* ── Page ── */
.page {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.page-header h1   { font-size: 1.3rem; font-weight: 700; }
.page-header .sub { font-size: .82rem; color: var(--muted); margin-top: 3px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: inherit; font-size: .83rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: background .13s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-ghost    { background: var(--card); color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover    { color: var(--text); }
.btn.action-delete {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.btn.action-delete:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}
.btn-promo    { background: rgba(99,102,241,.2); color: #a5b4fc; border: 1px solid rgba(99,102,241,.3); width: 100%; justify-content: center; }
.btn-small { padding: 7px 12px; font-size: .76rem; }
.btn-full { width: 100%; justify-content: center; }

.backup-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.backup-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: .83rem;
  font-weight: 600;
}

.backup-switch-label {
  line-height: 1;
}

.backup-switch-track {
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: #cbd5e1;
  border: 1px solid #94a3b8;
  padding: 1px;
  display: inline-flex;
  align-items: center;
}

.backup-switch-track.on {
  background: #22c55e;
  border-color: #16a34a;
}

.backup-switch-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transform: translateX(0);
  transition: transform .15s ease;
}

.backup-switch-track.on .backup-switch-thumb {
  transform: translateX(14px);
}

.btn-with-icon {
  gap: 7px;
}

.save-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.save-icon svg {
  width: 14px;
  height: 14px;
}

.save-icon i {
  font-size: 14px;
  line-height: 1;
}

.create-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.create-icon svg {
  width: 14px;
  height: 14px;
}

.create-icon i {
  font-size: 13px;
  line-height: 1;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ── Stat grid ── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stats.stats-compact {
  padding: 0 20px 20px;
}

.stats.stats-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat { padding: 18px 20px; }
.stat-label { font-size: .73rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.9rem; font-weight: 800; margin: 8px 0 4px; line-height: 1; }
.stat-hint  { font-size: .76rem; color: var(--muted); }
.stat-hint.up   { color: var(--green); }
.stat-hint.down { color: var(--red); }

/* ── Table card ── */
.table-card { overflow: hidden; }
.form-card { overflow: hidden; }
.ie-form {
  padding: 14px 16px 16px;
}
.ie-action {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
}

/* ── Notion-style toolbar ── */
.notion-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.notion-toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.notion-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.notion-search {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  width: 200px;
  transition: border-color .15s, box-shadow .15s;
}

.notion-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
  background: #fff;
}

.notion-search svg {
  width: 13px; height: 13px;
  color: var(--muted);
  flex-shrink: 0;
}
.notion-search i {
  width: 13px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
  text-align: center;
}

.notion-search input {
  border: none;
  background: none;
  outline: none;
  font: inherit;
  font-size: .8rem;
  color: var(--text);
  width: 100%;
}

.notion-search input::placeholder { color: var(--muted); }

.notion-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

.notion-filters {
  display: flex;
  align-items: center;
  gap: 3px;
}

.notion-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  font: inherit;
  font-size: .76rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}

.notion-filter-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.notion-filter-btn.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  border-color: var(--border);
}

.filter-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.notion-filter-btn.pending .filter-dot  { background: #d97706; }
.notion-filter-btn.confirmed .filter-dot { background: #16a34a; }
.notion-filter-btn.cancelled .filter-dot { background: #dc2626; }

.notion-count {
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap;
}

.notion-sort {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 9px;
}

.notion-sort svg {
  width: 13px; height: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.notion-sort select {
  border: none;
  background: none;
  outline: none;
  font: inherit;
  font-size: .78rem;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.table-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.flash-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flash {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 12px;
  font-size: .82rem;
  font-weight: 600;
}

.flash-success {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.flash-error {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

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

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.field span {
  font-size: .73rem;
  font-weight: 600;
  color: var(--muted);
}

.field-note {
  font-size: .72rem;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: .83rem;
  color: var(--text);
  background: #fff;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(99,102,241,.2);
  border-color: var(--primary);
}

.field input[type="color"] {
  padding: 2px;
  height: 38px;
  min-height: 38px;
  border-radius: 8px;
  cursor: pointer;
}

.field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.field input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

.inline-link {
  border: none;
  background: none;
  color: #2563eb;
  text-decoration: underline;
  font-size: .76rem;
  font-weight: 600;
  padding: 0;
  margin-top: 2px;
  cursor: pointer;
  width: fit-content;
}

.field-head .inline-link {
  margin-top: 0;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  color: var(--muted);
}

.check-row input {
  width: 14px;
  height: 14px;
}

.default-chip {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .66rem;
  font-weight: 700;
  background: #e0e7ff;
  color: #4338ca;
}

.force-visible {
  opacity: 1;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.table-wrap { overflow-x: auto; }

.settings-tabs-card {
  overflow: hidden;
}

.settings-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.settings-tab {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-tab:hover {
  border-color: #cbd5e1;
  color: var(--text);
}

.settings-tab.active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-note-panel {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
}

.settings-note-panel .sub {
  margin: 0;
  max-width: 700px;
}

.settings-submit-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
}

.settings-logo-preview {
  width: 64px;
  height: 64px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 600;
  overflow: hidden;
}

.settings-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 400;
  visibility: hidden;
  pointer-events: none;
}

.drawer.open {
  visibility: visible;
  pointer-events: auto;
}

.drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .35);
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(560px, 100%);
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 25px rgba(15, 23, 42, .12);
  transform: translateX(100%);
  transition: transform .2s ease;
  overflow-y: auto;
}

.drawer.open .drawer-panel {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
  font-size: .94rem;
  font-weight: 700;
}

.drawer-head.no-divider {
  border-bottom: none;
}

.drawer-head .row-btn {
  width: auto;
  height: auto;
  min-height: 30px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.drawer-head .row-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #c7d0db;
}

.drawer-form {
  padding-top: 14px;
}

.drawer-form .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

.drawer-form > .btn {
  grid-column: 1 / -1;
}

.drawer-submit-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
}

.drawer-form.compact {
  padding-top: 10px;
  padding-bottom: 8px;
}

.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 16px 0;
}

.drawer-subtitle {
  padding: 12px 16px 0;
  font-size: .77rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .03em;
  text-transform: uppercase;
}

.drawer-alert {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
  font-size: .82rem;
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  visibility: hidden;
  pointer-events: none;
}

.modal.open {
  visibility: visible;
  pointer-events: auto;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
}

.modal-panel {
  position: relative;
  width: min(520px, calc(100% - 24px));
  margin: 8vh auto 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, .22);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-panel-wide {
  width: min(900px, calc(100% - 24px));
}

.modal-panel .table-wrap {
  overflow-x: auto;
}

.modal-wide-table table {
  min-width: 700px;
}

.modal-data-scroll {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}

.role-modal-form {
  display: flex;
  flex-direction: column;
  height: calc(86vh - 68px);
  min-height: 0;
  padding-top: 0;
}

.role-modal-body {
  overflow-y: auto;
  padding: 12px 16px 10px;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.role-modal-body .field:first-child {
  grid-column: 1 / -1;
}

.role-modal-actions {
  border-top: 1px solid var(--border);
  padding: 10px 16px 12px;
  display: flex;
  justify-content: center;
  background: #fff;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form input {
  width: 180px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  font: inherit;
  font-size: .8rem;
}

table { width: 100%; border-collapse: collapse; }

th {
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.th-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.th-icon {
  width: 12px;
  min-width: 12px;
  display: inline-flex;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: #94a3b8;
  flex-shrink: 0;
}

td {
  font-size: .855rem;
  color: var(--text);
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

th:not(:last-child),
td:not(:last-child) {
  border-right: 1px solid var(--border);
}

/* Tags cell — wraps and constrains width */
td.tags-cell {
  white-space: normal;
  max-width: 200px;
  min-width: 120px;
  padding-top: 10px;
  padding-bottom: 10px;
  height: auto;
  vertical-align: top;
}

/* Actions cell — never shrinks, always visible */
td.actions-cell {
  width: 1%;
  white-space: nowrap;
  padding-left: 8px;
  padding-right: 12px;
  position: sticky;
  right: 0;
  z-index: 2;
  background: #fff;
  box-shadow: -1px 0 0 var(--border);
}

th:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #fff;
  box-shadow: -1px 0 0 var(--border);
}

.table-text-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.table-text-clip {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.view-all-link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: .76rem;
  line-height: 1;
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
  flex-shrink: 0;
}

.longtext-modal-panel {
  width: min(640px, calc(100% - 24px));
}

.longtext-modal-body {
  padding: 16px;
  font-size: .88rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(70vh, 620px);
  overflow: auto;
}

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

tbody tr {
  transition: background .1s;
}

/* Rows that contain a tags-cell stretch naturally — align all other tds to middle */
tbody tr td:not(.tags-cell) {
  vertical-align: middle;
}

tbody tr:hover { background: #f8fafc; }

tbody tr:hover td.actions-cell { background: #f8fafc; }

tbody tr:hover .row-actions { opacity: 1; }

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

.client-avatar {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  background: none !important;
  color: var(--text);
}

.client-name { font-weight: 500; }

/* Row actions */
.row-actions {
  opacity: 1;
  transition: opacity .13s;
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

.row-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .1s, color .1s;
}

.row-btn:hover { background: var(--border); color: var(--text); }
.row-btn svg { width: 14px; height: 14px; }

/* ── Tag chips (comma-separated values in Tags column) ── */
.tags-cell {
  display: table-cell; /* keep as td */
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 500;
  background: #f1f5f9;
  color: #475569;
  border: none !important;
  margin: 2px 3px 2px 0;
  white-space: nowrap;
  line-height: 1.5;
}

.muted-dash {
  color: var(--muted);
  font-size: .85rem;
}

/* ── Row action buttons (Edit / Delete) ── */
.action-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: .76rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  text-decoration: none;
  color: var(--muted);
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
  height: 28px;
}

.action-btn:hover {
  color: var(--text);
  background: var(--bg);
  border-color: #c7d0db;
}

.action-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

.action-icon-btn svg {
  width: 14px;
  height: 14px;
}
.action-icon-btn i {
  font-size: 13px;
  line-height: 1;
}

.action-icon-btn:hover {
  background: var(--bg);
  border-color: #c7d0db;
  color: var(--text);
}

.action-icon-view:hover {
  color: #0284c7;
  border-color: rgba(2,132,199,.35);
  background: rgba(2,132,199,.08);
}

.action-icon-email:hover {
  color: #7c3aed;
  border-color: rgba(124,58,237,.35);
  background: rgba(124,58,237,.08);
}

.action-icon-edit:hover {
  color: var(--primary);
  border-color: rgba(99,102,241,.35);
  background: rgba(99,102,241,.08);
}

.action-icon-delete:hover {
  color: var(--red);
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.08);
}

.action-edit:hover {
  color: var(--primary);
  border-color: rgba(99,102,241,.35);
  background: rgba(99,102,241,.05);
}

.action-delete:hover {
  color: var(--red);
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.05);
}


/* === field-footer === */
.field-footer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* === Multi-select tag picker === */
.ms-wrap {
  position: relative; display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px; min-height: 38px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  cursor: text; transition: border-color .15s, box-shadow .15s;
}
.ms-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.ms-tags { display: contents; }
.ms-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px 2px 8px; border-radius: 5px;
  background: #ede9fe; color: #4f46e5; font-size: .73rem; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.ms-tag-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border: none; background: none; color: #6d28d9;
  cursor: pointer; font-size: .9rem; line-height: 1; padding: 0; border-radius: 3px; transition: background .1s;
}
.ms-tag-remove:hover { background: rgba(109,40,217,.15); }
.ms-input {
  flex: 1; min-width: 80px; border: none !important; outline: none !important;
  box-shadow: none !important; background: transparent !important;
  padding: 2px 4px !important; font: inherit; font-size: .83rem; color: var(--text);
}
.ms-input::placeholder { color: var(--muted); }
.ms-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,.12); z-index: 300; max-height: 200px; overflow-y: auto;
}
.ms-dropdown[hidden] { display: none; }
.ms-option { padding: 8px 12px; font-size: .83rem; cursor: pointer; transition: background .1s; }
.ms-option:hover { background: #f1f5f9; }
.ms-option mark { background: #ede9fe; color: #4f46e5; border-radius: 2px; padding: 0 1px; font-style: normal; }

/* === Custom time picker === */
.tp-wrap { position: relative; }
.tp-display {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px;
  background: #fff; cursor: pointer; font: inherit; font-size: .83rem;
  color: var(--text); transition: border-color .15s, box-shadow .15s; user-select: none;
}
.tp-display:hover { border-color: #c7d0db; }
.tp-wrap:has(.tp-dropdown:not([hidden])) .tp-display { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.tp-display svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.tp-display i { width: 14px; font-size: 13px; color: var(--muted); flex-shrink: 0; text-align: center; }
.tp-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 300;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,.12); padding: 8px; min-width: 210px;
}
.tp-dropdown[hidden] { display: none; }
.tp-cols { display: flex; align-items: flex-start; gap: 4px; }
.tp-col { flex: 1; display: flex; flex-direction: column; gap: 1px; max-height: 180px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.tp-ampm { flex: 0 0 48px; }
.tp-sep { font-size: 1rem; font-weight: 700; color: var(--muted); padding: 6px 0; align-self: flex-start; margin-top: 4px; }
.tp-item { padding: 6px 8px; border-radius: 6px; font-size: .8rem; font-weight: 500; color: var(--muted); cursor: pointer; text-align: center; transition: background .1s, color .1s; white-space: nowrap; }
.tp-item:hover { background: var(--bg); color: var(--text); }
.tp-item.active { background: var(--primary); color: #fff; font-weight: 600; }

/* === Custom timezone picker === */
.tz-wrap { position: relative; }
.tz-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: .83rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.tz-input:hover { border-color: #c7d0db; }
.tz-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.tz-wrap:has(.tz-dropdown:not([hidden])) .tz-input {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.tz-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 320;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
  max-height: 170px;
  overflow-y: auto;
  padding: 6px;
}
.tz-dropdown[hidden] { display: none; }
.tz-option {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 8px;
  padding: 7px 8px;
  font: inherit;
  font-size: .8rem;
  color: #334155;
  cursor: pointer;
}
.tz-option:hover { background: #f1f5f9; color: #0f172a; }
.tz-empty {
  padding: 8px;
  color: var(--muted);
  font-size: .8rem;
}


.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  font-size: .73rem; font-weight: 600;
}

.tag::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

.tag.confirmed { background: #f0fdf4; color: #16a34a; }
.tag.pending   { background: #fffbeb; color: #d97706; }
.tag.cancelled { background: #fef2f2; color: #dc2626; }

.new-booking-badge {
  min-width: 42px;
  justify-content: center;
  letter-spacing: .04em;
}

.new-booking-badge::before {
  display: none;
}

.view-grid {
  padding: 14px 16px 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.view-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.view-item.full {
  grid-column: 1 / -1;
}

.view-item > span {
  font-size: .73rem;
  font-weight: 600;
  color: var(--muted);
}

.view-value {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
  font-size: .83rem;
  display: flex;
  align-items: center;
}

.view-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.pager-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .73rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* ── Calendar ── */
.calendar-card {
  overflow: hidden;
}

.calendar-nav-bar {
  border: none;
  border-bottom: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}

.calendar-weekday {
  background: #f8fafc;
  padding: 10px 12px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.calendar-day {
  background: var(--card);
  min-height: 104px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: inherit;
}

.calendar-day.muted .day-num {
  opacity: .45;
}

.calendar-day.today {
  outline: 2px solid rgba(99,102,241,.35);
  outline-offset: -2px;
}

.calendar-day.selected {
  background: #eef2ff;
}

.day-num {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
}

.event-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 2px;
}

.event-dot.confirmed { background: #16a34a; }
.event-dot.pending { background: #d97706; }
.event-dot.cancelled { background: #dc2626; }

.calendar-event {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-event.confirmed { background: #f0fdf4; color: #16a34a; }
.calendar-event.pending { background: #fffbeb; color: #d97706; }
.calendar-event.cancelled { background: #fef2f2; color: #dc2626; }

.calendar-more {
  font-size: .66rem;
  font-weight: 600;
  color: var(--muted);
}

.calendar-agenda {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calendar-agenda-scroll {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.day-agenda-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.day-agenda-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.calendar-agenda-count {
  padding: 0 12px 8px;
}

.calendar-agenda-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.calendar-agenda-title {
  font-size: .84rem;
  font-weight: 700;
  color: var(--text);
}

.calendar-agenda-sub {
  margin-top: 2px;
  font-size: .76rem;
  color: var(--muted);
}

/* ── Auth ── */
.auth-shell {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 10% 8%, rgba(37, 99, 235, 0.14), transparent 60%),
    radial-gradient(900px 500px at 90% 96%, rgba(14, 165, 233, 0.12), transparent 62%),
    #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.auth-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.56) 0%, rgba(248, 250, 252, 0.72) 100%);
  z-index: 1;
  pointer-events: none;
}

.auth-bg-photo {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  opacity: .22;
}

.auth-bg-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.9) contrast(1.02) blur(1px);
}

.auth-bg-photo-right {
  width: 100%;
  max-width: none;
  min-width: 0;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  transform: none;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  justify-content: center;
}

.auth-brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #dbe7ff;
}

.auth-brand-name {
  font-size: .95rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

.auth-brand-sub {
  margin-top: 2px;
  font-size: .74rem;
  color: #64748b;
  line-height: 1.1;
}

.auth-card {
  width: min(430px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 42px rgba(15, 23, 42, .12);
  padding: 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.auth-head {
  text-align: center;
}

.auth-head .sub {
  margin: 0;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
}

.auth-head h2 {
  margin-top: 5px;
  font-size: 1.48rem;
  font-weight: 800;
  color: #0f172a;
}

.auth-form {
  margin-top: 10px;
  gap: 12px;
}

.auth-meta {
  margin: 12px 0 0;
  text-align: center;
  font-size: .82rem;
  color: #64748b;
}

.auth-link {
  color: #0f766e;
  text-decoration: none;
  font-weight: 700;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-note {
  margin-top: 12px;
  border: 1px solid #dbe4ee;
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px;
}

.auth-note p {
  margin: 0 0 6px;
  font-size: .76rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
}

.mono-url {
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .78rem;
  color: #0f172a;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats.stats-5 { grid-template-columns: repeat(2, 1fr); }
  .calendar-day { min-height: 92px; }
  .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notion-search { width: 160px; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
}

@media (max-width: 540px) {
  .stats { grid-template-columns: 1fr; }
  .stats.stats-compact { grid-template-columns: 1fr; }
  .stats.stats-5 { grid-template-columns: 1fr; }
  .page { padding: 20px 16px; }
  .calendar-weekday { padding: 8px 6px; font-size: .66rem; text-align: center; }
  .calendar-day { min-height: 72px; padding: 6px; }
  .calendar-event { font-size: .62rem; padding: 2px 5px; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .notion-toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .notion-toolbar-right { width: 100%; }
  .notion-search { width: 100%; }
  .table-pager { flex-direction: column; align-items: flex-start; }
  .view-grid { grid-template-columns: 1fr; }
  .auth-bg-photo { display: none; }
}
