/* InstaPulse — светлый, спокойный интерфейс: белые карточки, мягкий фон, один акцент */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e7e9ee;
  --border-strong: #d6d9e0;
  --text: #16181d;
  --text-2: #5b6170;
  --text-3: #8b91a0;
  --accent: #e8467c;
  --accent-soft: #fdeef3;
  --accent-ink: #b8235a;
  --ok: #16a34a;   --ok-soft: #e9f8ef;
  --warn: #c2790a; --warn-soft: #fdf4e3;
  --bad: #dc2626;  --bad-soft: #fdeceb;
  --info: #2563eb; --info-soft: #eaf1fe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar: 232px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: inherit; text-decoration: none; }
a.link { color: var(--accent-ink); }
a.link:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* ---------- каркас ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; font-weight: 700; font-size: 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #f472b6, #e8467c 55%, #a855f7);
  display: grid; place-items: center; color: #fff; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--text-3); }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-3); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px 18px; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--text-3); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi.accent { background: linear-gradient(180deg, #fff, #fff7fa); border-color: #f6d3df; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.om { background: #a855f7; } .dot.ig { background: var(--accent); }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
th a:hover { color: var(--text); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fcfcfd; }
tr.total td { font-weight: 600; background: var(--surface-2); }
.acc { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 600; font-size: 13px; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.acc .name { font-weight: 600; }
.acc .meta { font-size: 12px; color: var(--text-3); }

/* ---------- бейджи ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge.count { background: var(--bad); color: #fff; border: none; padding: 0 7px; min-width: 20px; justify-content: center; }

/* ---------- формы ---------- */
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); }
label.field .help { font-weight: 400; color: var(--text-3); }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }
form.inline { display: inline; }

/* ---------- сегменты периода ---------- */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg a { padding: 5px 12px; border-radius: 6px; color: var(--text-2); font-weight: 500; }
.seg a.on { background: var(--text); color: #fff; }
.period-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period-bar form { display: flex; gap: 6px; align-items: center; }
.period-bar input[type=date] { padding: 5px 8px; }

/* ---------- прочее ---------- */
.flash { background: var(--text); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; display: flex; justify-content: space-between; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .big { font-size: 15px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.callout { border: 1px dashed #f0b6ca; background: #fff8fb; border-radius: var(--radius); padding: 14px 18px; display: flex; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.alert-item { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.alert-item:last-child { border-bottom: none; }
.alert-item .body { flex: 1; min-width: 0; }
.alert-item .title { font-weight: 600; }
.alert-item .msg { color: var(--text-2); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--accent-ink); border-color: var(--accent); }
.chart-box { position: relative; height: 260px; }
details.panel summary { cursor: pointer; list-style: none; font-weight: 600; }
details.panel summary::-webkit-details-marker { display: none; }
.week { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: 10px; overflow-x: auto; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 160px; display: flex; flex-direction: column; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.day-head { padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; }
.slot { margin: 6px 8px 0; padding: 7px 9px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; display: flex; gap: 8px; align-items: flex-start; }
.slot.done { background: var(--ok-soft); border-color: transparent; }
.slot.late { background: var(--bad-soft); border-color: transparent; }
.slot button.tick { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); background: #fff; cursor: pointer; padding: 0; flex-shrink: 0; display: grid; place-items: center; font-size: 11px; color: #fff; }
.slot.done button.tick { background: var(--ok); border-color: var(--ok); }
.slot .s-acc { font-weight: 600; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); min-width: 60px; }
.progress > span { display: block; height: 100%; background: var(--ok); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: 12px 18px; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 10px; align-items: center; }

@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 10px; }
  .brand { padding: 4px 10px; } .sidebar-foot { display: none; }
  .nav { display: flex; gap: 2px; }
  .main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* поправки сетки и мелочи */
.grid > .card, .grid > div > .card:first-child { margin-top: 0; }
.badge svg { width: 12px; height: 12px; }
.row input.grow, .row input[name=note], .row input[name=message] { min-width: 160px; flex: 1; }

/* пользователь в сайдбаре, страницы входа */
.sidebar-user { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.sidebar-user a { min-width: 0; flex: 1; border-radius: var(--radius-sm); padding: 4px; }
.sidebar-user a:hover, .sidebar-user a.active { background: var(--surface-2); }
.sidebar-user .name { font-weight: 600; display: block; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #fde7ef, transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .card-body { display: grid; gap: 14px; padding: 24px; }
.auth-card .brand { justify-content: center; padding: 0 0 6px; font-size: 18px; }
.error-box { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 24px; }
.perm-group h3 { margin-bottom: 6px; }
.perm-group label { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; font-size: 13px; cursor: pointer; }
.perm-group input { margin-top: 2px; }
.user-card summary { list-style: none; cursor: pointer; }
.user-card summary::-webkit-details-marker { display: none; }
.user-card[open] summary { border-bottom: 1px solid var(--border); }
@media (max-width: 860px) { .sidebar-user { display: none; } }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; padding: 0; flex-shrink: 0; accent-color: var(--accent); box-shadow: none; }
