:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
  --background: #f4f6fa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #edf0f5;
  --surface-tint: #e8f3f1;
  --text: #161a27;
  --muted: #667085;
  --line: #d9dfe9;
  --primary: #0a105b;
  --primary-text: #ffffff;
  --accent: #ed0043;
  --accent-soft: #ffe7ee;
  --success: #087864;
  --success-soft: #e1f4ef;
  --warning: #9a5c00;
  --warning-soft: #fff0cf;
  --danger: #b42318;
  --danger-soft: #fee9e7;
  --shadow-sm: 0 5px 15px rgb(17 24 39 / 7%);
  --shadow-md: 0 14px 34px rgb(17 24 39 / 10%);
  --shadow-lg: 0 28px 75px rgb(17 24 39 / 20%);
  --radius-control: 14px;
  --radius-panel: 20px;
  --radius-shell: 26px;
  --radius-pill: 999px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #10131c;
  --surface: #191e2a;
  --surface-raised: #202634;
  --surface-soft: #282e3b;
  --surface-tint: #173630;
  --text: #f5f7fb;
  --muted: #b4bdcc;
  --line: #3a4252;
  --primary: #8c97ff;
  --primary-text: #111427;
  --accent: #ff4b79;
  --accent-soft: #4e2636;
  --success: #72d5be;
  --success-soft: #173a34;
  --warning: #ffd178;
  --warning-soft: #4a3618;
  --danger: #ff8e86;
  --danger-soft: #4c2826;
  --shadow-sm: 0 5px 15px rgb(0 0 0 / 18%);
  --shadow-md: 0 14px 34px rgb(0 0 0 / 24%);
  --shadow-lg: 0 28px 75px rgb(0 0 0 / 38%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #10131c;
    --surface: #191e2a;
    --surface-raised: #202634;
    --surface-soft: #282e3b;
    --surface-tint: #173630;
    --text: #f5f7fb;
    --muted: #b4bdcc;
    --line: #3a4252;
    --primary: #8c97ff;
    --primary-text: #111427;
    --accent: #ff4b79;
    --accent-soft: #4e2636;
    --success: #72d5be;
    --success-soft: #173a34;
    --warning: #ffd178;
    --warning-soft: #4a3618;
    --danger: #ff8e86;
    --danger-soft: #4c2826;
    --shadow-sm: 0 5px 15px rgb(0 0 0 / 18%);
    --shadow-md: 0 14px 34px rgb(0 0 0 / 24%);
    --shadow-lg: 0 28px 75px rgb(0 0 0 / 38%);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--background); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--background); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, strong { font-weight: 700; }
h1 { margin-bottom: 5px; font-size: 30px; }
h2 { margin-bottom: 7px; font-size: 24px; }
h3 { margin-bottom: 5px; font-size: 18px; }
small { color: var(--muted); }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 5px; color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.empty-state { padding: 38px 20px; color: var(--muted); text-align: center; }
.empty-state i { width: 28px; height: 28px; margin-bottom: 8px; }
.error { color: var(--danger); }
.mobile-only { display: none !important; }

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--accent);
  color: #fff;
  font-size: 21px;
  font-weight: 900;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 28%, transparent);
}
.brand-mark.large { width: 58px; height: 58px; flex-basis: 58px; border-radius: 19px; font-size: 29px; }
.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-tint);
  color: var(--success);
  font-size: 13px;
  font-weight: 800;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.large-avatar { width: 52px; height: 52px; flex-basis: 52px; font-size: 16px; }

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  flex: 0 0 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
}
.icon-button:hover { background: var(--surface-soft); }
.icon-button.ghost { border-color: transparent; background: transparent; }
.icon-button i, .primary-button i, .secondary-button i, .quick-action i, .nav-item i { width: 18px; height: 18px; }
.primary-button, .secondary-button, .ghost-button, .danger-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-weight: 750;
}
.primary-button { background: var(--primary); color: var(--primary-text); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 20%, transparent); }
.secondary-button { border-color: var(--line); background: var(--surface); }
.ghost-button { background: var(--surface-soft); }
.danger-button { background: var(--danger-soft); color: var(--danger); }
.wide { width: 100%; }

.auth-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(420px, .88fr);
}
.auth-visual {
  position: relative;
  min-height: 680px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 42px;
  background: #08105b;
  color: #fff;
}
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-lockup div { display: grid; }
.brand-lockup strong { font-size: 24px; }
.brand-lockup span:last-child { color: #cdd3ff; }
.auth-message { position: relative; z-index: 2; max-width: 620px; }
.auth-message h1 { max-width: 520px; font-size: 48px; }
.auth-message p:last-child { max-width: 560px; margin-bottom: 0; color: #d5daf8; font-size: 18px; }
.auth-scene {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 480px;
  height: 480px;
  transform: translate(-50%, -50%);
}
.scene-ring { position: absolute; border: 1px solid #8793ff66; border-radius: 50%; }
.ring-one { inset: 42px; }
.ring-two { inset: 108px; }
.scene-center, .scene-node {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #08105b;
  box-shadow: 0 18px 45px rgb(0 0 0 / 25%);
}
.scene-center { inset: 182px; }
.scene-center i { width: 44px; height: 44px; }
.scene-node { width: 64px; height: 64px; }
.scene-node i { width: 26px; height: 26px; }
.node-one { top: 38px; left: 208px; }
.node-two { right: 28px; bottom: 120px; }
.node-three { left: 28px; bottom: 120px; }
.auth-panel { display: grid; align-content: center; gap: 30px; padding: 56px max(40px, 10vw); background: var(--background); }
.mobile-brand { display: none; }
.auth-form { width: min(440px, 100%); display: grid; gap: 18px; }
.auth-form label, .field { display: grid; gap: 7px; color: var(--text); font-size: 13px; font-weight: 700; }
.auth-form input, .field input, .field select, .field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  padding: 10px 13px;
}
.field textarea { min-height: 100px; resize: vertical; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 52px; }
.password-field button { position: absolute; top: 3px; right: 3px; }
.form-message { min-height: 20px; margin: 0; }
.auth-footer { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.auth-footer i { width: 16px; height: 16px; }
.back-link { width: fit-content; display: inline-flex; align-items: center; gap: 7px; padding: 0; border: 0; background: transparent; color: var(--primary); font-weight: 700; }
.back-link i { width: 16px; height: 16px; }

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template: 76px minmax(0, 1fr) / 224px minmax(0, 1fr);
}
.topbar {
  grid-column: 1 / -1;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}
.topbar-brand, .topbar-actions, .user-button, .user-menu-head { display: flex; align-items: center; gap: 10px; }
.brand-copy, .user-copy { display: grid; min-width: 0; }
.brand-copy span, .user-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { min-width: 0; }
.notification-button { position: relative; }
.notification-dot { position: absolute; top: -2px; right: -2px; min-width: 18px; height: 18px; padding: 0 4px; border: 2px solid var(--surface); border-radius: 99px; background: var(--accent); color: #fff; font-size: 10px; line-height: 14px; }
.user-button {
  max-width: 260px;
  min-height: 48px;
  padding: 5px 9px 5px 6px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  text-align: left;
}
.user-button > i { width: 16px; height: 16px; color: var(--muted); }

.sidebar {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 10px 0 10px 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.area-button {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  text-align: left;
}
.area-button > span:nth-child(2) { min-width: 0; display: grid; }
.area-button strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.area-color { width: 12px; height: 28px; border-radius: var(--radius-pill); background: var(--accent); }
.area-menu {
  position: absolute;
  z-index: 12;
  top: 70px;
  left: 10px;
  right: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}
.area-option {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
}
.area-option:hover, .area-option.active { background: var(--surface-soft); }
.area-option .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--area-color, var(--accent)); }
.main-navigation { display: grid; align-content: start; gap: 3px; margin-top: 14px; }
.nav-label { margin: 14px 10px 5px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.nav-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  text-align: left;
}
.nav-item:hover { background: var(--surface-soft); }
.nav-item.active { background: var(--primary); color: var(--primary-text); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 20%, transparent); }
.nav-item .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding-top: 12px; }
.security-state { min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-control); background: var(--success-soft); color: var(--success); }
.security-state i { width: 20px; height: 20px; }
.security-state span { display: grid; }
.security-state small { color: currentColor; opacity: .8; }

.main-content { min-width: 0; padding: 22px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.page-heading > div:first-child { min-width: 0; }
.page-heading h1, .page-heading p:last-child { margin-bottom: 0; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}
.quick-action {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
}
.quick-action:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); transform: translateY(-1px); }
.quick-action span { min-width: 0; display: grid; }
.quick-action small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view { min-width: 0; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .75fr); gap: 14px; }
.column { min-width: 0; display: grid; align-content: start; gap: 14px; }
.panel {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.panel.terrace-two { margin-left: 12px; }
.panel.terrace-three { margin-left: 24px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.panel-header h2, .panel-header h3, .panel-header p { margin-bottom: 0; }
.panel-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.metric {
  min-height: 92px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border-radius: 16px;
  background: var(--surface-soft);
}
.metric i { width: 22px; height: 22px; color: var(--primary); }
.metric span { display: grid; min-width: 0; }
.metric strong { font-size: 23px; }
.metric small { font-size: 12px; line-height: 1.2; overflow-wrap: break-word; hyphens: auto; }
.dashboard-grid > .column:last-child .metric { padding-inline: 11px; }
.status-list, .data-list { display: grid; gap: 7px; }
.list-row {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  text-align: left;
}
.list-row:hover { background: color-mix(in srgb, var(--surface-soft) 65%, var(--surface-tint)); }
.row-main { min-width: 0; display: flex; align-items: center; gap: 10px; }
.row-copy { min-width: 0; display: grid; gap: 2px; }
.row-copy strong, .row-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { flex: 0 0 auto; color: var(--muted); text-align: right; }
.status-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: var(--primary); }
.status-dot.success { background: var(--success); }
.status-dot.warning { background: var(--warning); }
.status-dot.danger { background: var(--accent); }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.service-mark {
  min-width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--service-bg, var(--primary));
  color: var(--service-text, #fff);
  font-size: 12px;
  font-weight: 900;
}
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.week-day { min-height: 104px; padding: 9px 6px; border-radius: 16px; background: var(--surface-soft); text-align: center; }
.week-day.today { background: var(--primary); color: var(--primary-text); box-shadow: 0 9px 20px color-mix(in srgb, var(--primary) 22%, transparent); }
.week-day strong, .week-day small { display: block; }
.week-day.today small { color: currentColor; opacity: .8; }
.calendar-chip { display: block; margin-top: 7px; padding: 4px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; }

.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 14px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  white-space: nowrap;
}
.tabs button.active { background: var(--primary); color: var(--primary-text); }
.tabs button i { width: 17px; height: 17px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
}
.segmented button { min-height: 34px; padding: 5px 10px; border: 0; border-radius: var(--radius-pill); background: transparent; }
.segmented button.active { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--primary); font-weight: 750; }
.segmented.compact button { min-height: 30px; padding: 4px 8px; font-size: 11px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.calendar-weekday { padding: 4px; color: var(--muted); font-size: 12px; font-weight: 750; text-align: center; }
.calendar-day {
  min-height: 118px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--surface-soft);
}
.calendar-day.outside { opacity: .45; }
.calendar-day.today { border-color: var(--primary); }
.calendar-day > span:first-child { font-size: 12px; font-weight: 800; }
.calendar-event {
  width: 100%;
  overflow: hidden;
  padding: 5px 6px;
  border: 0;
  border-radius: 9px;
  background: var(--event-bg, var(--primary));
  color: var(--event-text, #fff);
  font-size: 11px;
  font-weight: 750;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-event.appointment { background: var(--surface-tint); color: var(--success); }
.year-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.year-month { min-height: 108px; padding: 13px; border: 0; border-radius: 16px; background: var(--surface-soft); text-align: left; }
.year-month strong, .year-month span { display: block; }
.year-month span { margin-top: 18px; color: var(--muted); }

.chat-layout { min-height: 580px; display: grid; grid-template-columns: minmax(230px, .7fr) minmax(0, 1.3fr); gap: 12px; }
.conversation-list, .chat-panel { min-height: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); box-shadow: var(--shadow-md); }
.conversation-list { display: flex; flex-direction: column; }
.conversation-list .data-list { overflow: auto; }
.conversation-row { border: 1px solid transparent; }
.conversation-row.active { border-color: var(--primary); background: var(--surface-tint); }
.chat-panel { display: grid; grid-template-rows: auto minmax(260px, 1fr) auto; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 4px 12px; border-bottom: 1px solid var(--line); }
.messages { display: flex; flex-direction: column; gap: 8px; overflow: auto; padding: 16px 5px; }
.message { max-width: min(78%, 580px); align-self: flex-start; padding: 10px 12px; border-radius: 16px 16px 16px 5px; background: var(--surface-soft); }
.message.own { align-self: flex-end; border-radius: 16px 16px 5px 16px; background: var(--primary); color: var(--primary-text); }
.message p { margin-bottom: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message small { color: currentColor; opacity: .72; }
.message-form { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.message-form input { min-width: 0; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface-soft); color: var(--text); padding: 9px 15px; }
.message-form button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--primary); color: var(--primary-text); }

.admin-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; }
.admin-nav { display: grid; align-content: start; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); box-shadow: var(--shadow-sm); }
.admin-nav button { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 0; border-radius: var(--radius-control); background: transparent; text-align: left; }
.admin-nav button.active { background: var(--primary); color: var(--primary-text); }
.admin-nav i { width: 17px; height: 17px; }
.admin-content { min-width: 0; }
.table-wrap { overflow-x: auto; border-radius: var(--radius-control); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
td { font-size: 13px; }
.table-action { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--surface-soft); }
.hierarchy-name { display: flex; align-items: center; gap: 8px; padding-left: calc(var(--depth, 0) * 18px); }
.settings-form, .dialog-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field.full, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.check-field { min-height: 46px; display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: var(--radius-control); background: var(--surface-soft); font-size: 13px; font-weight: 650; }
.check-field input { width: 18px; height: 18px; }
.color-input { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 8px; }
.color-input input[type="color"] { height: 46px; padding: 4px; }

.popover {
  position: fixed;
  z-index: 30;
  width: min(360px, calc(100% - 24px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}
.user-menu { top: 76px; right: 12px; }
.user-menu-head { padding: 8px; margin-bottom: 5px; }
.user-menu-head > div { min-width: 0; display: grid; }
.user-menu > button, .theme-control {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  text-align: left;
}
.user-menu > button:hover { background: var(--surface-soft); }
.user-menu > button i, .theme-control i { width: 18px; height: 18px; }
.theme-control { align-items: flex-start; justify-content: space-between; flex-direction: column; }
.theme-control > span { display: flex; align-items: center; gap: 10px; }
.danger-action { color: var(--danger); }

dialog {
  width: min(720px, calc(100% - 24px));
  max-height: calc(100vh - 30px);
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-shell);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgb(14 18 33 / 58%); backdrop-filter: blur(3px); }
.dialog-shell { padding: 0; }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 12px; background: var(--surface-raised); }
.dialog-header h2 { margin-bottom: 0; }
.dialog-body { padding: 4px 18px 20px; }
.command-dialog { width: min(680px, calc(100% - 24px)); margin-top: 9vh; }
.command-dialog form { padding: 10px; }
.command-input { display: grid; grid-template-columns: 24px minmax(0, 1fr) 40px; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 17px; background: var(--surface-soft); }
.command-input input { width: 100%; height: 42px; border: 0; outline: 0; background: transparent; color: var(--text); }
.command-results { display: grid; gap: 5px; max-height: 430px; overflow: auto; margin-top: 8px; }
.command-result { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 11px; border: 0; border-radius: var(--radius-control); background: transparent; text-align: left; }
.command-result:hover { background: var(--surface-soft); }
.toast { position: fixed; z-index: 60; top: 14px; left: 50%; max-width: calc(100% - 24px); padding: 12px 17px; border-radius: var(--radius-pill); background: var(--primary); color: var(--primary-text); box-shadow: var(--shadow-lg); transform: translate(-50%, -110px); transition: transform .22s ease; }
.toast.show { transform: translate(-50%, 0); }
.loading { min-height: 220px; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.help-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr); align-items: center; gap: 24px; overflow: hidden; }
.help-hero > div { position: relative; padding-left: 58px; }
.help-hero-icon { position: absolute; left: 0; top: 2px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-control); background: var(--accent-soft); color: var(--accent); }
.help-hero h2 { margin: 2px 0 5px; }
.help-search label { min-height: 52px; display: flex; align-items: center; gap: 9px; padding: 5px 5px 5px 14px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); box-shadow: var(--shadow-sm); }
.help-search input { min-width: 0; flex: 1; border: 0; background: transparent; box-shadow: none; }
.help-search input:focus { outline: 0; }
.help-layout { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: 14px; align-items: start; }
.help-topics { position: sticky; top: 92px; display: grid; gap: 7px; }
.help-category { width: 100%; min-height: 54px; display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid transparent; border-radius: var(--radius-control); background: transparent; color: var(--text); text-align: left; }
.help-category:hover, .help-category.active { border-color: var(--line); background: var(--surface-soft); }
.help-category.active { box-shadow: inset 3px 0 0 var(--accent); }
.help-category-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-raised); color: var(--primary); }
.help-category span:last-child { min-width: 0; display: grid; gap: 2px; }
.help-category small { color: var(--muted); }
.help-content { min-width: 0; display: grid; gap: 14px; }
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.help-card { min-height: 174px; display: flex; flex-direction: column; align-items: flex-start; gap: 9px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface-soft); color: var(--text); text-align: left; box-shadow: var(--shadow-sm); }
.help-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.help-card > strong { font-size: 17px; }
.help-card > span:not(.help-card-top, .help-card-meta) { color: var(--muted); line-height: 1.45; }
.help-card-top { width: 100%; display: flex; justify-content: space-between; gap: 6px; }
.help-card-meta { margin-top: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.release-list { display: grid; gap: 7px; }
.release-row { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-soft); color: var(--text); text-align: left; }
.release-row span { display: grid; gap: 2px; }
.release-row small { color: var(--accent); font-weight: 800; }
.help-article { display: grid; gap: 14px; }
.help-article .lead { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.help-prose { line-height: 1.65; }
.help-prose h2, .help-prose h3, .help-prose h4 { margin: 22px 0 8px; }
.help-prose p, .help-prose ul { margin: 0 0 10px; }
.help-video { display: grid; gap: 8px; }
.help-video video { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-card); background: #000; }
.help-media-planned { min-height: 70px; display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius-control); background: var(--surface-soft); }
.help-media-planned > svg { color: var(--accent); }
.help-media-planned span { display: grid; gap: 2px; }
.help-media-planned small { color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1080px) {
  .mobile-only { display: inline-grid !important; }
  .workspace { display: block; padding-top: 76px; }
  .topbar { position: fixed; top: 0; left: 0; right: 0; margin: 8px; }
  .sidebar {
    position: fixed;
    z-index: 25;
    top: 76px;
    left: 0;
    bottom: 0;
    width: min(294px, calc(100% - 34px));
    margin: 8px;
    transform: translateX(calc(-100% - 24px));
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; z-index: 20; inset: 0; background: rgb(14 18 33 / 45%); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-layout { grid-template-columns: 1fr; }
  .help-layout { grid-template-columns: 1fr; }
  .help-topics { position: static; display: flex; overflow-x: auto; }
  .help-category { min-width: 210px; }
  .admin-nav { display: flex; overflow-x: auto; border-radius: var(--radius-pill); }
  .admin-nav { scrollbar-width: none; }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav button { white-space: nowrap; }
}

@media (max-width: 720px) {
  h1 { font-size: 26px; }
  .mobile-only { display: inline-grid !important; }
  .auth-view { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; align-content: center; padding: 28px 20px; }
  .mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
  .brand-copy span, .user-copy, .user-button > i { display: none; }
  .user-button { padding: 4px; }
  .topbar-actions { gap: 5px; }
  .main-content { padding: 16px 12px 24px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-actions { justify-content: flex-start; }
  .page-actions .primary-button, .page-actions .secondary-button { flex: 1; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .help-hero { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr; }
  .help-search label { border-radius: var(--radius-control); }
  .help-search .primary-button { padding-inline: 12px; }
  .quick-action { min-height: 62px; align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .week-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .week-strip > :nth-child(n+5) { display: none; }
  .panel, .panel.terrace-two, .panel.terrace-three { margin-left: 0; padding: 14px; }
  .calendar-grid { gap: 4px; }
  .calendar-day { min-height: 82px; padding: 6px 4px; }
  .calendar-event { padding: 4px; font-size: 10px; }
  .year-grid { grid-template-columns: 1fr 1fr; }
  .chat-layout { min-height: auto; grid-template-columns: 1fr; }
  .conversation-list { max-height: 330px; }
  .chat-panel { min-height: 500px; }
  .settings-form, .dialog-form { grid-template-columns: 1fr; }
  .field.full, .form-actions { grid-column: auto; }
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody { display: grid; gap: 9px; }
  .table-wrap tr { position: relative; padding: 10px 48px 10px 10px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-soft); }
  .table-wrap td {
    min-height: 31px;
    display: grid;
    grid-template-columns: minmax(84px, .42fr) minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  .table-wrap td::before { content: attr(data-label); color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
  .table-wrap td:last-child { position: absolute; top: 10px; right: 9px; width: 34px; padding: 0; }
  .table-wrap td:last-child::before { display: none; }
  .dialog-header { padding: 15px 14px 10px; }
  .dialog-body { padding: 4px 14px 16px; }
  .row-meta { max-width: 38%; }
  .row-copy strong, .row-copy small { white-space: normal; }
}

@media (max-width: 420px) {
  .brand-copy { display: none; }
  .quick-actions { grid-template-columns: 1fr; }
  .week-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .week-strip > :nth-child(4) { display: none; }
  .year-grid { grid-template-columns: 1fr; }
  .topbar { padding-inline: 8px; }
  .metric strong { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
