/* ============================================================
   Migraine Diary — styles
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #f4f5fb;
  --bg-gradient: radial-gradient(circle at 12% 0%, #e9e7ff 0%, transparent 45%),
                 radial-gradient(circle at 100% 10%, #e0f0ff 0%, transparent 40%),
                 #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fe;
  --border: #e6e8f2;
  --text: #1a1c2b;
  --text-muted: #6b7080;
  --primary: #6d5efc;
  --primary-dark: #5748e0;
  --primary-soft: #eeecff;
  --danger: #ef4b64;
  --danger-soft: #ffe9ec;
  --success: #22b07d;
  --success-soft: #e2f8ef;
  --shadow-sm: 0 1px 2px rgba(20, 22, 40, .05), 0 1px 3px rgba(20, 22, 40, .06);
  --shadow-md: 0 6px 24px rgba(30, 32, 60, .08);
  --shadow-lg: 0 18px 50px rgba(30, 32, 60, .14);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен всегда скрывать элемент, даже если у класса
   задан display (grid/flex и т.п.), иначе модалка видна сразу при загрузке. */
[hidden] { display: none !important; }

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

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.1rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); font-size: .92rem; }

/* ---------- Layout ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 22px 70px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 1.4rem; }
.nav { display: flex; align-items: center; gap: 14px; }
.nav-link { color: var(--text-muted); font-weight: 500; font-size: .92rem; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.logout:hover { color: var(--danger); }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.avatar {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: .85rem;
}
.user-name { font-weight: 600; font-size: .88rem; }

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; }

/* ---------- Period filter ---------- */
.period-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.period-bar-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.period-label {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.period-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.period-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .84rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.period-pill:hover {
  border-color: #c9c6f0;
  background: #f3f1ff;
}
.period-pill.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(109, 94, 252, .28);
}
.period-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.period-custom[hidden] { display: none !important; }
.period-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .86rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.period-date input[type="date"] {
  border: none;
  background: transparent;
  font: inherit;
  font-size: .88rem;
  color: var(--text);
  padding: 4px 0;
}
.period-date input[type="date"]:focus { outline: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(109, 94, 252, .3); }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d63a52; text-decoration: none; }
.btn-sm { padding: 8px 14px; font-size: .86rem; }
.btn-block { width: 100%; }

/* ---------- Cards / panels ---------- */
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary), #9d8dff);
}
.kpi-label { font-size: .82rem; color: var(--text-muted); font-weight: 500; }
.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  margin: 6px 0 2px;
  color: var(--text);
}
.kpi-hint { font-size: .78rem; color: var(--text-muted); }

/* ---------- Phase durations ---------- */
.phase-duration-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.phase-dur-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.phase-dur-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.phase-dur-badge {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  flex-shrink: 0;
}
.phase-dur-value {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
}
.phase-dur-hint { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ---------- Charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.panel-wide { grid-column: 1 / -1; }
.chart-box {
  position: relative;
  height: 260px;
  background: #ffffff;
  border-radius: 8px;
}
.panel-wide .chart-box { height: 300px; }
.chart-box > canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: #ffffff;
  /* Изолируем композитинг canvas — снижает «чёрный» bitmap на GPU. */
  isolation: isolate;
}
.legend { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Table ---------- */
.search-input {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .88rem;
  background: var(--surface-2);
  min-width: 260px;
}
.search-input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }
.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-dark);
  margin: 2px 3px 2px 0;
}
.pill.trigger { background: #fff2e0; color: #b26b00; }
.intensity-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: 700;
  color: #fff;
  font-size: .82rem;
}
.aura-tag { color: var(--danger); font-weight: 700; font-size: .8rem; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: .95rem;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-emoji { font-size: 2.6rem; margin-bottom: 10px; }

/* ---------- Flash ---------- */
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash-success { background: var(--success-soft); color: #14865e; border-color: #bde9d6; }
.flash-error { background: var(--danger-soft); color: #c22b45; border-color: #ffc9d2; }

/* ---------- Auth pages ---------- */
.auth-page { display: flex; align-items: center; min-height: 100vh; }
.auth-page .container { width: 100%; }
.auth-wrap {
  display: grid;
  grid-template-columns: 1fr 440px;
  gap: 48px;
  align-items: center;
  max-width: 1000px;
  margin: 0 auto;
}
.auth-hero { padding: 20px 0; }
.hero-emoji { font-size: 3rem; margin-bottom: 12px; }
.auth-hero h1 { font-size: 2.4rem; margin-bottom: 14px; }
.hero-sub { color: var(--text-muted); font-size: 1.05rem; max-width: 420px; margin: 0 0 22px; }
.hero-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.hero-features li { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.hero-features .dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary-soft);
  display: inline-grid; place-items: center;
  position: relative;
  flex-shrink: 0;
}
.hero-features .dot::after {
  content: "✓"; color: var(--primary); font-size: .75rem; font-weight: 800;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 34px;
  box-shadow: var(--shadow-lg);
}
.auth-card h2 { font-size: 1.5rem; }
.auth-card .muted { margin: 6px 0 22px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: .9rem; color: var(--text-muted); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: .88rem; font-weight: 600; color: var(--text); }
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=date],
.field input[type=time],
.field input[type=number],
.field textarea,
.field select {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .94rem;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: #fff;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.attack-form { max-width: 820px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 6px; }

/* range */
.range { width: 100%; accent-color: var(--primary); height: 6px; }
.range-scale { display: flex; justify-content: space-between; font-size: .76rem; color: var(--text-muted); margin-top: 2px; }

/* switch */
.switch-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .92rem;
  font-weight: 500;
}
.switch-field input { width: 18px; height: 18px; accent-color: var(--primary); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  transition: all .12s ease;
  user-select: none;
}
.chip input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(109, 94, 252, .28);
}
.chip:hover span { border-color: var(--primary); }

/* attack journal row */
.attack-row { cursor: pointer; }
.attack-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 40, .45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* Wide attack-detail modal must override .modal max-width */
.modal.modal-wide {
  width: min(1180px, calc(100vw - 32px));
  max-width: min(1180px, calc(100vw - 32px));
  max-height: min(92vh, 960px);
  overflow: auto;
  text-align: left;
  padding: 24px 28px 22px;
}
.attack-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.attack-detail-kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.ad-kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}
.ad-kpi-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; }
.ad-kpi-value {
  font-size: 1.05rem;
  font-weight: 800;
  margin-top: 4px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.attack-detail-phases {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.ad-phase {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fff;
  min-width: 0;
  overflow: hidden;
}
.ad-phase-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ad-phase-head h4 { margin: 0; font-size: .95rem; }
.ad-meta {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.ad-block-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin: 10px 0 6px;
}
.sign-bars { display: flex; flex-direction: column; gap: 8px; }
.sign-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(72px, 1fr) 28px;
  gap: 10px;
  align-items: center;
  font-size: .84rem;
}
.sign-bar-row > span:first-child {
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}
.sign-bar-track {
  height: 8px;
  background: #eef0f8;
  border-radius: 999px;
  overflow: hidden;
  min-width: 56px;
}
.sign-bar-fill { height: 100%; border-radius: 999px; }
.attack-detail-notes { display: grid; gap: 10px; margin-bottom: 14px; }
.ad-note {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
.ad-note p {
  margin: 4px 0 0;
  font-size: .9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.attack-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

/* ---------- Roles / badges ---------- */
.role-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.role-user { background: #e7f0ff; color: #2c66c9; }
.role-doctor { background: var(--success-soft); color: #14865e; }
.role-admin { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Patient banner (doctor view) ---------- */
.patient-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(120deg, #f0eeff, #e8f3ff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.patient-banner-main { display: flex; align-items: center; gap: 14px; }
.patient-avatar {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 800;
  font-size: 1.15rem;
  flex-shrink: 0;
}

/* ---------- Patient cards (doctor list) ---------- */
.patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.patient-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.patient-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.patient-card-head { display: flex; align-items: center; gap: 12px; }
.patient-card-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.patient-card-title strong { font-size: 1.02rem; }
.patient-card-title .muted { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; }
.chevron { color: var(--primary); font-weight: 800; font-size: 1.1rem; }
.patient-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.patient-card-stats > div { display: flex; flex-direction: column; }
.pc-num { font-size: 1.05rem; font-weight: 800; }
.pc-label { font-size: .72rem; color: var(--text-muted); }

/* ---------- Admin assign form ---------- */
.assign-form { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.inline-form { display: inline; margin: 0; }
.assign-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: .85rem;
  background: var(--surface-2);
  max-width: 190px;
}
.assign-select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

/* ---------- Attack form: phases ---------- */
.attack-form { display: flex; flex-direction: column; gap: 18px; }
.attack-section { margin: 0; }

.phase-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.phase-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: linear-gradient(90deg, var(--surface-2), #fff);
  border-bottom: 1px solid var(--border);
}
.phase-num {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: .95rem;
  box-shadow: 0 4px 12px rgba(109, 94, 252, .3);
}
.phase-title h2 { font-size: 1.05rem; }
.phase-title p { margin: 2px 0 0; font-size: .85rem; }
.phase-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }

/* Период фазы: «с» → «по» */
.dt-period {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fbfaff, #eef0ff);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.dt-period:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.dt-period.dt-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.dt-period-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 220px;
  min-width: 0;
}
.dt-period-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding-left: 2px;
}
.dt-period-arrow {
  align-self: center;
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  padding-bottom: 10px;
}
.dt-input {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}
.dt-part {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 10px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.dt-part .dt-icon { font-size: .95rem; line-height: 1; flex-shrink: 0; }
.dt-part input {
  border: none !important;
  background: transparent !important;
  padding: 7px 2px !important;
  width: 100% !important;
  font-size: .92rem !important;
  box-shadow: none !important;
}
.dt-part input:focus { outline: none; }
.dt-part input[type=date] { min-width: 0; }
.dt-part input[type=time] { min-width: 0; }
.dt-duration { margin-top: 6px; font-weight: 600; }
.dt-duration-ok { color: #14865e; }
.dt-duration-bad { color: var(--danger); }
.field-hint { font-size: .78rem; }

/* sign intensity (per-chip ratings) */
.sign-intensity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.sign-intensity-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(100px, 1fr) 28px;
  gap: 10px;
  align-items: center;
}
.sign-intensity-name {
  font-size: .86rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sign-intensity-range {
  width: 100%;
  accent-color: var(--primary);
}
.sign-intensity-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

/* chip adder */
.chip-adder { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.chip-add-input {
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .86rem;
  background: var(--surface-2);
  min-width: 180px;
}
.chip-add-input:focus { outline: none; border-color: var(--primary); background: #fff; }
.chip-custom { position: relative; }
.chip-custom span { border-style: dashed; }
.chip-remove {
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0 0 0 2px;
  display: none;
}
.chip-custom:hover .chip-remove { display: inline; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .phase-duration-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; gap: 28px; max-width: 460px; }
  .auth-hero { text-align: center; }
  .hero-features { display: none; }
  .hero-sub { margin-inline: auto; }
}
@media (max-width: 620px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .phase-duration-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .user-name { display: none; }
  .nav { gap: 10px; }
  h1 { font-size: 1.5rem; }
  .auth-card { padding: 24px; }
  .search-input { min-width: 100%; }
  .dt-period { flex-direction: column; align-items: stretch; }
  .dt-period-arrow { padding: 0; align-self: center; transform: rotate(90deg); }
  .dt-input { flex-direction: column; }
  .attack-detail-kpi { grid-template-columns: repeat(2, 1fr); }
  .attack-detail-phases { grid-template-columns: 1fr; }
  .sign-bar-row {
    grid-template-columns: minmax(0, 1fr) 28px;
  }
  .sign-bar-track { grid-column: 1 / -1; }
  .sign-intensity-row { grid-template-columns: 1fr 28px; }
  .sign-intensity-range { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .modal.modal-wide {
    width: min(100%, calc(100vw - 20px));
    max-width: min(100%, calc(100vw - 20px));
  }
  .attack-detail-phases { grid-template-columns: 1fr; }
}
