/* ============================================================
   PsyOs Design Mockup — layout и компоненты.
   Всё построено на переменных из theme.css.
   ============================================================ */

* { box-sizing: border-box; border-color: var(--border); }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

.num { font-variant-numeric: tabular-nums; }

/* ---------- Каркас кабинета ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  border-right: var(--border-width) solid var(--border);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--background);
}

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: calc(var(--radius) * 0.66);
  background: var(--primary); color: var(--primary-foreground);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: calc(var(--radius) * 0.72);
  color: var(--muted-foreground); font-weight: 500; font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav a:hover { background: var(--muted); color: var(--foreground); }
.nav a.active { background: var(--accent-soft); color: var(--primary); }

.sidebar-footer {
  margin-top: auto; border-top: var(--border-width) solid var(--border);
  padding-top: 12px; display: flex; flex-direction: column; gap: 8px;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.user-chip .name { font-weight: 550; font-size: 13.5px; }
.user-chip .role { font-size: 12px; color: var(--muted-foreground); }
.sidebar-footer .nav a { font-size: 13.5px; }

.main {
  flex: 1; min-width: 0;
  padding: calc(24px * var(--density)) clamp(16px, 3vw, 40px);
}
.content { max-width: var(--content-width); margin: 0 auto; display: flex; flex-direction: column; gap: var(--section-gap); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted-foreground); margin-top: 3px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Мобильная шапка */
.mobile-bar {
  display: none; position: sticky; top: 0; z-index: 40;
  align-items: center; justify-content: space-between;
  height: 52px; padding: 0 14px;
  background: var(--background);
  border-bottom: var(--border-width) solid var(--border);
}
.burger { background: none; border: none; color: var(--foreground); padding: 8px; cursor: pointer; display: grid; place-items: center; }

@media (max-width: 900px) {
  .mobile-bar { display: flex; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; height: auto;
    transform: translateX(-100%); transition: transform 0.18s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-pop); }
  .main { padding: 16px 14px 40px; }
}
.backdrop {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: oklch(0 0 0 / 50%);
}
.backdrop.show { display: block; }

/* ---------- Карточки ---------- */

.card {
  background: var(--card);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
}
.card-pad { padding: var(--card-pad); }
.card-head {
  padding: var(--card-pad) var(--card-pad) 0;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.card-head h2 { font-size: 15px; }
.card-head .hint { font-size: 12.5px; color: var(--muted-foreground); }
.card-body { padding: calc(12px * var(--density)) var(--card-pad) var(--card-pad); display: flex; flex-direction: column; gap: var(--list-gap); }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border-radius: calc(var(--radius) * 0.72);
  border: var(--border-width) solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: filter 0.12s, background 0.12s;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; color: var(--foreground); border-color: var(--input); }
.btn-outline:hover { background: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--muted); color: var(--foreground); }
.btn-soft-danger { background: var(--danger-soft); color: var(--danger); }
.btn-soft-danger:hover { filter: brightness(1.1); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }

/* ---------- Бейджи статусов ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-muted { background: var(--muted); color: var(--muted-foreground); }
.badge-muted::before { display: none; }
.badge-accent { background: var(--accent-soft); color: var(--primary); }
.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); }

/* ---------- Поля форм ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 550; color: var(--muted-foreground); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px;
  background: transparent; color: var(--foreground);
  border: var(--border-width) solid var(--input);
  border-radius: calc(var(--radius) * 0.72);
  font: inherit; font-size: 14px; outline: none;
}
.textarea { height: auto; min-height: 72px; padding: 9px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.select { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}
.search { position: relative; }
.search .input { padding-left: 34px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-foreground); }

.switch { position: relative; width: 36px; height: 21px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--muted); border: var(--border-width) solid var(--input);
  pointer-events: none; transition: background 0.15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%; background: var(--foreground);
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .track { background: var(--primary); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(15px); background: var(--primary-foreground); }

/* ---------- Списки и строки ---------- */

.row-list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: var(--row-pad) var(--card-pad);
  border-bottom: var(--border-width) solid var(--border);
}
.row:last-child { border-bottom: none; }
.row:hover { background: oklch(from var(--muted) l c h / 40%); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .meta { font-size: 13px; color: var(--muted-foreground); margin-top: 1px; }
.row .side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.row .when { font-size: 13px; color: var(--muted-foreground); text-align: right; white-space: nowrap; }

.time-cell {
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px;
  color: var(--primary); width: 86px; flex-shrink: 0;
}

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 650;
  background: var(--accent-soft); color: var(--primary);
}
.avatar.lg { width: 46px; height: 46px; font-size: 16px; }

/* Сводка-чипы */
.stat-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stat {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; border-radius: var(--radius);
  background: var(--card); border: var(--border-width) solid var(--border);
}
.stat .value { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 12.5px; color: var(--muted-foreground); }
.stat .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.stat .dot.success { background: var(--success); }
.stat .dot.warning { background: var(--warning); }

/* ---------- Меню «⋯» ---------- */

details.menu { position: relative; }
details.menu summary {
  list-style: none; cursor: pointer;
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: calc(var(--radius) * 0.6);
  color: var(--muted-foreground);
}
details.menu summary::-webkit-details-marker { display: none; }
details.menu summary:hover { background: var(--muted); color: var(--foreground); }
details.menu .menu-pop {
  position: absolute; right: 0; top: 34px; z-index: 30;
  min-width: 200px; padding: 5px;
  background: var(--card); border: var(--border-width) solid var(--border);
  border-radius: calc(var(--radius) * 0.85);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
}
details.menu .menu-pop button {
  display: flex; align-items: center; gap: 9px;
  background: none; border: none; cursor: pointer;
  padding: 8px 10px; border-radius: calc(var(--radius) * 0.55);
  font: inherit; font-size: 13.5px; text-align: left; color: var(--foreground);
}
details.menu .menu-pop button:hover { background: var(--muted); }
details.menu .menu-pop button.danger { color: var(--danger); }
details.menu .menu-pop hr { border: none; border-top: var(--border-width) solid var(--border); margin: 4px 0; }

/* ---------- Диалог ---------- */

.dialog-root { position: fixed; inset: 0; z-index: 80; display: none; }
.dialog-root.open { display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog-root .overlay { position: absolute; inset: 0; background: oklch(0 0 0 / 55%); }
.dialog {
  position: relative; z-index: 1;
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto;
  background: var(--card); border: var(--border-width) solid var(--border);
  border-radius: var(--radius); padding: var(--card-pad);
  display: flex; flex-direction: column; gap: 14px;
}
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { font-size: 16px; }
.dialog-close { background: none; border: none; color: var(--muted-foreground); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.dialog-close:hover { background: var(--muted); color: var(--foreground); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Календарь ---------- */

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--muted); border-radius: calc(var(--radius) * 0.8); }
.seg button {
  border: none; background: none; cursor: pointer;
  height: 28px; padding: 0 13px; border-radius: calc(var(--radius) * 0.55);
  font: inherit; font-size: 13px; font-weight: 550; color: var(--muted-foreground);
}
.seg button.on { background: var(--primary); color: var(--primary-foreground); }

.cal-wrap { border-top: var(--border-width) solid var(--border); }
.cal-head { display: flex; justify-content: space-between; padding: 9px var(--card-pad); border-bottom: var(--border-width) solid var(--border); }
.cal-head .day-name { font-weight: 600; font-size: 13px; }
.cal-head .day-name.today { color: var(--primary); }
.cal-head .count { font-size: 12.5px; color: var(--muted-foreground); }

.day-grid { position: relative; display: flex; }
.hours { width: 52px; flex-shrink: 0; position: relative; }
.hours span { position: absolute; right: 8px; font-size: 10.5px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.cal-canvas { position: relative; flex: 1; }
.hline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.hline.work-off { border-color: transparent; background: oklch(0 0 0 / 18%); }
body.light .hline.work-off { background: oklch(0 0 0 / 5%); }
.now-line { position: absolute; left: 0; right: 0; border-top: 2px solid var(--danger); z-index: 5; }
.now-line::before {
  content: ""; position: absolute; left: -1px; top: -5px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
}

.event {
  position: absolute; left: 6px; right: 6px; z-index: 6;
  border-radius: calc(var(--radius) * 0.6);
  border: var(--border-width) solid transparent;
  padding: 4px 9px; overflow: hidden; cursor: pointer;
  font-size: 12.5px; line-height: 1.35;
}
.event .t { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event .s { display: block; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.event.scheduled { background: var(--accent-soft); border-color: oklch(from var(--primary) l c h / 35%); color: var(--foreground); }
.event.completed { background: var(--success-soft); border-color: oklch(from var(--success) l c h / 35%); }
.event.noshow { background: var(--warning-soft); border-color: oklch(from var(--warning) l c h / 35%); }
.event.cancelled { background: var(--muted); color: var(--muted-foreground); }
.event.cancelled .t { text-decoration: line-through; }
.event.block { background: transparent; border-style: dashed; border-color: var(--input); color: var(--muted-foreground); }

.week-cols { display: flex; }
.week-col { flex: 1; min-width: 0; position: relative; border-left: var(--border-width) solid var(--border); }
.week-col:first-child { border-left: none; }
.week-col .week-events { position: relative; }
@media (max-width: 760px) {
  .week-scroll { overflow-x: auto; }
  .week-cols { min-width: 640px; }
}

/* ---------- Публичный визард ---------- */

.public-wrap { max-width: 620px; margin: 0 auto; padding: 40px 16px 80px; display: flex; flex-direction: column; gap: 16px; }
.public-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; }
.public-head .sub { color: var(--muted-foreground); max-width: 460px; }

.steps { display: flex; align-items: center; gap: 8px; justify-content: center; margin-bottom: 4px; }
.step-dot { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted-foreground); font-weight: 550; }
.step-dot .n {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.step-dot.on { color: var(--primary); }
.step-dot.on .n { background: var(--primary); color: var(--primary-foreground); }
.step-dot.done .n { background: var(--accent-soft); color: var(--primary); }
.steps .dash { width: 26px; height: 1px; background: var(--border); }

.svc-option {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: transparent; color: inherit; font: inherit;
  border: var(--border-width) solid var(--input);
  border-radius: calc(var(--radius) * 0.9);
  padding: 12px 14px;
}
.svc-option:hover { border-color: var(--primary); }
.svc-option.on { border-color: var(--primary); background: var(--accent-soft); }
.svc-option .name { font-weight: 600; display: block; }
.svc-option .meta { font-size: 13px; color: var(--muted-foreground); margin-top: 3px; display: block; }

.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month .dow { text-align: center; font-size: 11px; color: var(--muted-foreground); padding: 4px 0; font-weight: 550; }
.month .day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: calc(var(--radius) * 0.62); cursor: pointer;
  font-size: 13px; font-variant-numeric: tabular-nums;
  border: var(--border-width) solid transparent; background: none; color: var(--foreground);
  position: relative; gap: 2px;
}
.month .day:hover { background: var(--muted); }
.month .day.off { color: var(--muted-foreground); opacity: 0.45; cursor: default; }
.month .day .dots { display: flex; gap: 2px; height: 3px; }
.month .day .dots i { width: 3px; height: 3px; border-radius: 50%; background: var(--primary); }
.month .day.on { border-color: var(--primary); background: var(--accent-soft); }
.month .day.today-tag { color: var(--primary); font-weight: 650; }

.slot-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.slot {
  min-width: 64px; height: 34px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: calc(var(--radius) * 0.62); cursor: pointer;
  border: var(--border-width) solid var(--input);
  background: transparent; color: var(--foreground);
  font: inherit; font-size: 13.5px; font-weight: 550; font-variant-numeric: tabular-nums;
}
.slot:hover { border-color: var(--primary); }
.slot.on { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }

.summary-line {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-radius: calc(var(--radius) * 0.8);
  background: var(--muted); font-size: 13.5px;
}
.success-icon {
  width: 52px; height: 52px; border-radius: 50%; margin: 4px auto 0;
  background: var(--accent-soft); color: var(--primary);
  display: grid; place-items: center;
}
.success-icon svg { width: 26px; height: 26px; }

/* ---------- Панель настройки темы ---------- */

.theme-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--primary); color: var(--primary-foreground);
  border: none; cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow-pop);
}
.theme-fab svg { width: 21px; height: 21px; }
.theme-panel {
  position: fixed; right: 18px; bottom: 74px; z-index: 90;
  width: 320px; max-height: min(78vh, 640px); overflow: auto;
  background: var(--card); border: var(--border-width) solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow-pop);
  padding: 16px; display: none; flex-direction: column; gap: 14px;
}
.theme-panel.open { display: flex; }
.theme-panel h3 { font-size: 14px; }
.theme-panel .grp { display: flex; flex-direction: column; gap: 8px; }
.theme-panel .grp-title { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-foreground); }
.theme-panel label.cfg { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.theme-panel input[type="color"] {
  width: 34px; height: 26px; padding: 0 2px; border: var(--border-width) solid var(--input);
  border-radius: 6px; background: none; cursor: pointer;
}
.theme-panel input[type="range"] { width: 130px; accent-color: var(--primary); }
.theme-panel select { height: 32px; }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.preset-chip {
  display: flex; align-items: center; gap: 7px;
  border: var(--border-width) solid var(--input); background: none; cursor: pointer;
  border-radius: calc(var(--radius) * 0.6); padding: 7px 9px;
  font: inherit; font-size: 12.5px; color: var(--foreground);
}
.preset-chip:hover { border-color: var(--primary); }
.preset-chip .sw { display: flex; }
.preset-chip .sw i { width: 11px; height: 11px; border-radius: 50%; }
.preset-chip .sw i:first-child { margin-right: -4px; }
.seg.small button { height: 26px; padding: 0 10px; font-size: 12px; }
.theme-panel .actions { display: flex; gap: 8px; }
.theme-panel .actions .btn { flex: 1; }
.mock-note { font-size: 11.5px; color: var(--muted-foreground); text-align: center; }

/* ---------- Экспорт-модалка ---------- */
.export-pre {
  background: var(--muted); border-radius: calc(var(--radius) * 0.7);
  padding: 12px; font-family: ui-monospace, monospace; font-size: 12px;
  max-height: 300px; overflow: auto; white-space: pre; user-select: all;
}

/* ---------- Логин ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.login-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 2px; }

/* ---------- Утилиты ---------- */

.muted { color: var(--muted-foreground); }
.small { font-size: 12.5px; }
.flex { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.link { color: var(--primary); cursor: pointer; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.divider { border: none; border-top: var(--border-width) solid var(--border); margin: 4px 0; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--section-gap); align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
