/* Hairclinic CRM — своя дизайн-система. Без сборки, без CDN, без фреймворка. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e6ea;
  --border-strong: #cbd1d8;
  --text: #16191d;
  --text-2: #5b6470;
  --text-3: #8b939d;

  --accent: #0f766e;         /* тёмная бирюза — медицина без «айтишности» */
  --accent-weak: #e6f2f1;
  --accent-strong: #0b5c56;

  --danger: #b4232b;
  --danger-weak: #fdeceb;
  --warn: #9a6206;
  --warn-weak: #fdf3e2;
  --ok: #16704a;
  --ok-weak: #e7f4ee;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 4px 16px rgba(16, 24, 40, .10);

  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1 { font-size: 22px; font-weight: 650; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 650; margin: 0 0 8px; color: var(--text-2);
     text-transform: uppercase; letter-spacing: .04em; }

.muted { color: var(--text-2); }
.dim   { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono  { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- каркас */

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

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: #10161c; color: #cfd6dd;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 18px 18px 14px; font-weight: 650; color: #fff; font-size: 15px;
  border-bottom: 1px solid #1f272f; letter-spacing: -.01em;
}
.sidebar .brand small { display: block; font-weight: 400; color: #7e8a96; font-size: 11.5px;
  letter-spacing: 0; margin-top: 2px; }
.sidebar nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: #b6c0ca; text-decoration: none; font-weight: 500; margin-bottom: 1px;
}
.sidebar nav a:hover { background: #1a222a; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav .sep { margin: 12px 10px 6px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .06em; color: #66727e; }
.sidebar .me {
  border-top: 1px solid #1f272f; padding: 12px 14px; font-size: 12.5px;
}
.sidebar .me .name { color: #fff; font-weight: 550; }
.sidebar .me .role { color: #7e8a96; }
.sidebar .me form { margin-top: 8px; }
.sidebar .me button {
  background: none; border: 1px solid #2c353e; color: #b6c0ca;
  border-radius: var(--radius-sm); padding: 5px 9px; cursor: pointer; font-size: 12px;
  font-family: var(--font);
}
.sidebar .me button:hover { background: #1a222a; color: #fff; }

.main { flex: 1; min-width: 0; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .grow { flex: 1; }
.content { padding: 22px 24px 60px; max-width: 1500px; }

/* -------------------------------------------------------------- элементы */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card > h2 { display: flex; align-items: center; gap: 8px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: -16px -16px 14px; padding: 13px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }

.stat { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.stat .value { font-size: 25px; font-weight: 650; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; }
.stat .value.danger { color: var(--danger); }
.stat .value.ok { color: var(--ok); }
.stat .sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 550; font-family: var(--font);
  cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* формы */
label { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2);
  margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; font-size: 13.5px; font-family: var(--font);
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-weak); outline-offset: 0;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* таблицы */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; margin: 0 -16px -16px; padding: 0 16px; }

/* бейджи */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-danger { background: var(--danger-weak); color: var(--danger); border-color: #f5cfcd; }
.badge-warn   { background: var(--warn-weak);   color: var(--warn);   border-color: #f2ddb8; }
.badge-ok     { background: var(--ok-weak);     color: var(--ok);     border-color: #c4e3d4; }
.badge-accent { background: var(--accent-weak); color: var(--accent-strong); border-color: #bfdedb; }

/* алерты */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px;
  margin-bottom: 14px; border: 1px solid; }
.alert-danger { background: var(--danger-weak); border-color: #f0c4c2; color: #7d1a20; }
.alert-warn   { background: var(--warn-weak);   border-color: #eed6ab; color: #6d4504; }
.alert-info   { background: var(--accent-weak); border-color: #bfdedb; color: #0b4a45; }

/* пустое состояние */
.empty { text-align: center; padding: 30px 16px; color: var(--text-3); }
.empty .big { font-size: 15px; color: var(--text-2); margin-bottom: 4px; font-weight: 550; }

/* ---------------------------------------------------------------- канбан */

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; }
.board-col {
  flex: 0 0 250px; background: #eef0f3; border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 190px);
}
.board-col .col-head {
  padding: 10px 12px; font-size: 12px; font-weight: 650; color: var(--text-2);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: #eef0f3; border-radius: var(--radius) var(--radius) 0 0;
}
.board-col .col-head .n { background: #dde1e6; border-radius: 999px; padding: 1px 7px;
  font-size: 11px; color: var(--text-2); }
.board-col .col-body { padding: 0 8px 8px; overflow-y: auto; }
.deal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px; margin-bottom: 7px;
  box-shadow: var(--shadow); display: block; color: var(--text);
}
.deal-card:hover { border-color: var(--border-strong); text-decoration: none;
  box-shadow: var(--shadow-lg); }
.deal-card .name { font-weight: 600; margin-bottom: 3px; }
.deal-card .meta { font-size: 11.5px; color: var(--text-3);
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.deal-card.stale { border-left: 3px solid var(--warn); }

/* лента событий */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed li:last-child { border-bottom: none; }
.feed .when { font-size: 11.5px; color: var(--text-3); }

/* чат/сообщения */
.msg { margin-bottom: 10px; display: flex; }
.msg .bubble {
  max-width: 74%; padding: 8px 11px; border-radius: 12px; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.msg.out { justify-content: flex-end; }
.msg.out .bubble { background: var(--accent-weak); border-color: #cbe3e1; }
.msg .who { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }

/* вкладки */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a {
  padding: 8px 13px; font-size: 13px; font-weight: 550; color: var(--text-2);
  border-bottom: 2px solid transparent; text-decoration: none;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* полоса-индикатор */
.bar { height: 6px; background: #e6e9ed; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* строка фильтров */
.filters { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters .field { margin-bottom: 0; }
.filters input, .filters select { min-width: 150px; }

/* центрированная страница входа */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px; }
.auth-box { width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 26px; }
.auth-box .logo { font-weight: 650; font-size: 17px; margin-bottom: 3px; }
.auth-box .sub { color: var(--text-2); font-size: 13px; margin-bottom: 20px; }

/* -------------------------------------------------------------- мобильный */

@media (max-width: 900px) {
  .cols, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .layout { flex-direction: column; }

  /* сайдбар превращается в шапку: строка «бренд + кто я», под ней прокручиваемое меню */
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center;
  }
  .sidebar .brand {
    flex: 1; min-width: 0; border-bottom: none; padding: 12px 14px;
  }
  .sidebar .me {
    order: 2; border-top: none; padding: 10px 14px;
    display: flex; align-items: center; gap: 10px; white-space: nowrap;
  }
  .sidebar .me .role { display: none; }
  .sidebar .me form { margin: 0; }
  .sidebar nav {
    order: 3; flex-basis: 100%;
    display: flex; gap: 4px; padding: 0 8px 8px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .sidebar nav a { white-space: nowrap; margin-bottom: 0; }
  .sidebar nav a .badge { display: none; }
  .sidebar nav .sep { display: none; }

  .content { padding: 16px 14px 50px; }
  .topbar { padding: 12px 14px; }
  .board-col { flex: 0 0 82vw; max-height: none; }
  .filters .field { flex: 1 1 100%; }
  .filters input, .filters select { min-width: 0; width: 100%; }
}

/* печать/фокус — доступность */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
