:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --panel: #ffffff;
  --panel-muted: #eef6fb;
  --ink: #172638;
  --muted: #66778a;
  --line: #d7e4ee;
  --accent: #0877b9;
  --accent-strong: #045985;
  --accent-soft: #dff2fb;
  --teal: #1aa39a;
  --danger: #d2353b;
  --danger-strong: #ad2028;
  --shadow: 0 20px 60px rgba(29, 67, 96, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 310px),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

button,
input,
select {
  font: inherit;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-panel {
  display: grid;
  width: min(100%, 390px);
  gap: 16px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

select {
  min-height: 38px;
  padding: 7px 34px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 119, 185, 0.14);
}

.form-error {
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.login-panel button,
.secondary-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}

.login-panel button {
  color: #fff;
  background: var(--accent);
}

.login-panel button:hover {
  background: var(--accent-strong);
}

.app-screen {
  width: min(1872px, 100%);
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  cursor: pointer;
  min-width: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.topbar-status {
  margin: 0;
  min-height: 42px;
  max-width: min(520px, 50vw);
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--muted);
  background: #f8fbfd;
  white-space: nowrap;
}

.secondary-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.topbar-back-button {
  min-width: 76px;
}

.mobile-logout-slot {
  display: none;
}

/* Admin account: only the Статистика / Пользователи / Клиенты / Выйти actions —
   no patient list, patient page, or grid/amplitude controls. */
.app-screen.admin-mode #listPanel,
.app-screen.admin-mode #patientPanel,
.app-screen.admin-mode #emptyState,
.app-screen.admin-mode #statusBar,
.app-screen.admin-mode #patientPreviewControls {
  display: none !important;
}

.status-bar,
.empty-state {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-bar {
  color: var(--muted);
}

.status-bar.topbar-status {
  margin: 0;
  min-height: 42px;
  padding: 10px 14px;
}

.empty-state {
  text-align: center;
}

.page-loader {
  margin-bottom: 16px;
}

.page-loader-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid #cfe2ef;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0, #f3f9fd 100%);
  box-shadow: 0 10px 26px rgba(29, 67, 96, 0.08);
}

.page-loader-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.page-loader-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #dbeaf3;
}

.page-loader-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 160ms ease;
}

.empty-state p {
  margin: 8px auto 0;
  max-width: 520px;
  color: var(--muted);
}

.patient-preview-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid #d8e7f0;
  border-radius: 6px;
  background: #f7fbfe;
}

.patient-preview-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.patient-preview-controls select {
  min-height: 32px;
  min-width: 124px;
  padding-block: 5px;
  font-weight: 800;
}

.patient-preview-debug {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 10000;
  width: min(900px, calc(100vw - 24px));
  max-height: 38vh;
  margin: 0;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid rgba(106, 224, 255, 0.42);
  border-radius: 6px;
  background: rgba(7, 18, 29, 0.94);
  box-shadow: 0 16px 44px rgba(5, 18, 30, 0.28);
  color: #d8f8ff;
  font: 11px/1.45 Consolas, "Cascadia Mono", monospace;
  white-space: pre-wrap;
}

.groups-list {
  display: grid;
  gap: 16px;
}

.institution {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 32px rgba(29, 67, 96, 0.08);
}

.institution-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #f7fbfe 0, var(--panel-muted) 100%);
}

.institution-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
}

.patient-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.patient-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid #e3edf4;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  color: inherit;
  background: #fff;
}

.patient-row-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 42%);
  align-items: start;
  gap: 14px;
}

.patient-row:last-child {
  border-bottom: 1px solid #e3edf4;
}

.patient-row:hover {
  border-color: #b8d9ea;
  background: #fbfdff;
}

.patient-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  row-gap: 6px;
}

.patient-tab {
  width: max-content;
  padding: 3px 9px;
  border: 1px solid #c8e4f1;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.patient-name {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 800;
}

.patient-hr {
  width: max-content;
  padding: 3px 8px;
  border: 1px solid #cbe5ef;
  border-radius: 6px;
  color: var(--accent-strong);
  background: #f0f8fc;
  font-size: 13px;
  font-weight: 800;
}

.patient-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.patient-ecg-preview {
  display: block;
  width: 100%;
  height: 94px;
  margin-top: 6px;
  border: 1px solid #123327;
  border-radius: 6px;
  background: #07120f;
}

.patient-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
  justify-self: end;
  padding: 4px;
  border: 1px solid #dbe8f1;
  border-radius: 8px;
  background: #f6fbfe;
}

.action-button {
  flex: 1 1 0;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--accent-strong);
  background: transparent;
  font-weight: 800;
  white-space: nowrap;
}

.action-button:hover {
  border-color: #c5dce9;
  background: #fff;
  box-shadow: 0 6px 18px rgba(29, 67, 96, 0.08);
}

.live-button {
  color: #fff;
  border-color: #0b75ad;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  box-shadow: 0 8px 20px rgba(8, 119, 185, 0.16);
}

.live-button:hover {
  border-color: var(--accent-strong);
  background: linear-gradient(135deg, var(--accent-strong), #12867f);
}

.info-button {
  color: var(--teal);
}

.patient-panel {
  display: grid;
  gap: 16px;
}

.patient-page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0 4px;
}

.chart-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 10px 32px rgba(29, 67, 96, 0.07);
}

.live-section {
  overflow: hidden;
  width: 100%;
  border: 1px solid #111917;
  border-radius: 16px;
  background: #0a0c0b;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.live-section .chart-head {
  display: none;
}

#heartRateSection {
  overflow: hidden;
  border: 1px solid #111917;
  border-radius: 16px;
  background: #0a0c0b;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
}

#heartRateSection .chart-head {
  display: none;
}

#heartRateSection .chart-wrap {
  height: 210px;
  padding: 10px;
  background: #050706;
}

#heartRateSection canvas {
  cursor: crosshair;
  border-radius: 12px;
}

.record-trend-controls {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  border-top: 1px solid #1a2420;
  background: #101413;
}

.record-trend-controls > span {
  flex: 0 0 auto;
  color: #8d9894;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.record-trend-controls button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #263832;
  border-radius: 8px;
  color: #d9e3df;
  background: #151c1a;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.record-trend-controls button:hover {
  border-color: #38564c;
  color: #ffffff;
  background: #1a2421;
}

.live-vitals {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px 0;
}

.live-vital-card {
  display: grid;
  min-width: 180px;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid #cfe3ee;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0, #f4fafc 100%);
}

.live-vital-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.live-vital-card strong {
  color: var(--accent-strong);
  font-size: 34px;
  line-height: 1;
}

.live-vital-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.live-packets-head {
  display: none;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.live-packets-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.live-packets-list {
  display: grid;
  gap: 12px;
  max-height: 560px;
  overflow: auto;
  padding: 14px;
  background: #f8fbfd;
}

.chart-wrap.live-chart-wrap {
  height: 528px;
  padding: 10px;
  background: #050706;
}

.chart-wrap.live-chart-wrap canvas {
  border-radius: 12px;
}

.ecg-scale-controls {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  min-height: 80px;
  padding: 14px 16px;
  border-top: 1px solid #1a2420;
  background: #101413;
}

.ecg-scale-controls label {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
  min-height: 38px;
  color: #8d9894;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.ecg-scale-controls label > span {
  white-space: nowrap;
}

.ecg-scale-controls select {
  height: 38px;
  min-width: 150px;
  padding-top: 0;
  padding-bottom: 0;
  border-radius: 8px;
  border-color: #263832;
  color: #d9e3df;
  background: #151c1a;
  font-weight: 800;
}

.ecg-scale-controls .ecg-qrs-toggle,
.ecg-scale-controls .ecg-pace-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #263832;
  border-radius: 8px;
  color: #d9e3df;
  background: #151c1a;
  font-weight: 700;
}

.ecg-qrs-toggle input,
.ecg-pace-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #d33;
}

.live-packet {
  overflow: hidden;
  border: 1px solid #d9e8f1;
  border-radius: 8px;
  background: #fff;
}

.live-packet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #e6eef4;
  color: var(--accent-strong);
  background: #f7fbfe;
  font-size: 13px;
}

.live-packet-head span {
  color: var(--muted);
  font-weight: 600;
}

.live-packet pre {
  max-height: 240px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  color: #1d2b3a;
  background: #fff;
  font: 12px/1.45 Consolas, "SFMono-Regular", monospace;
  white-space: pre-wrap;
}

.live-empty {
  padding: 24px;
  border: 1px dashed #c9ddea;
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  text-align: center;
  font-weight: 700;
}

.chart-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f7fbfe;
}

.chart-wrap {
  position: relative;
  height: 220px;
  padding: 12px;
}

.chart-wrap-large {
  height: 320px;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  pointer-events: none;
}

.patient-dialog {
  width: min(760px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.patient-dialog::backdrop {
  background: rgba(12, 24, 18, 0.36);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.details-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  margin: 0;
  padding: 8px 24px 24px;
}

.details-grid dt,
.details-grid dd {
  min-width: 0;
  margin: 0;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.details-grid dt {
  color: var(--muted);
  font-weight: 700;
}

.details-grid dd {
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  body {
    background:
      linear-gradient(180deg, #ffffff 0, var(--bg) 220px),
      var(--bg);
  }

  h1 {
    font-size: 24px;
    line-height: 1.18;
  }

  h2 {
    font-size: 19px;
  }

  h3 {
    font-size: 16px;
  }

  .login-screen {
    align-items: start;
    min-height: 100svh;
    padding: 16px;
  }

  .login-panel {
    width: 100%;
    gap: 14px;
    margin-top: 6vh;
    padding: 22px 18px;
  }

  .app-screen {
    padding: 14px 10px 28px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px 0 16px;
  }

  .topbar-brand {
    font-size: 17px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-status {
    flex: 1 1 100%;
    max-width: 100%;
    justify-content: flex-start;
    white-space: normal;
  }

  .topbar-actions .secondary-button {
    flex: 1 1 128px;
  }

  #logoutButton {
    display: none;
  }

  /* Action buttons live in the bottom mobile slot on phones; hide the topbar
     copies so they aren't duplicated. */
  #statusButton,
  #usersButton,
  #clientsButton {
    display: none !important;
  }

  .topbar-back-button {
    display: none !important;
  }

  .mobile-logout-slot {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .mobile-logout-slot .secondary-button {
    flex: 1 1 0;
    min-height: 46px;
  }

  .status-bar,
  .empty-state {
    margin-bottom: 10px;
    padding: 12px;
  }

  .patient-preview-controls {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
  }

  .patient-preview-controls label {
    align-items: start;
    gap: 5px;
  }

  .record-trend-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px 12px;
  }

  .record-trend-controls > span {
    grid-column: 1 / -1;
  }

  .record-trend-controls button {
    width: 100%;
  }

  .patient-preview-controls select {
    width: 100%;
  }

  .groups-list,
  .patient-panel {
    gap: 10px;
  }

  .institution {
    border-radius: 6px;
  }

  .institution-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding: 13px 12px;
  }

  .patient-list {
    gap: 8px;
    padding: 8px;
  }

  .patient-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    border-left-width: 3px;
  }

  .patient-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    justify-self: stretch;
    padding: 3px;
  }

  .patient-row-top {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .patient-name {
    font-size: 17px;
  }

  .patient-ecg-preview {
    height: 84px;
    margin-top: 2px;
  }

  .action-button {
    width: 100%;
    min-height: 38px;
    padding: 0 10px;
    text-align: center;
  }

  .patient-page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 8px 0 0;
  }

  .chart-section,
  .live-section {
    border-radius: 6px;
  }

  #heartRateSection {
    border-radius: 12px;
  }

  #heartRateSection .chart-wrap {
    height: 210px;
    padding: 8px;
  }

  .chart-head,
  .live-packets-head {
    padding: 11px 12px;
  }

  .live-vitals {
    display: none;
  }

  .live-vital-card {
    min-width: 0;
    padding: 10px 12px;
  }

  .live-vital-card strong {
    font-size: 28px;
  }

  .live-packets-list {
    gap: 8px;
    max-height: 320px;
    padding: 8px;
  }

  .chart-wrap.live-chart-wrap {
    height: 516px;
    padding: 8px;
  }

  .ecg-scale-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 0;
    padding: 10px 12px 12px;
  }

  .ecg-scale-controls label {
    align-items: center;
    justify-content: space-between;
    gap: 5px;
  }

  .ecg-scale-controls select {
    width: 100%;
  }

  .live-packet-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .live-packet pre {
    max-height: 160px;
    padding: 10px;
    font-size: 11px;
  }

  .details-grid {
    grid-template-columns: 1fr;
    padding: 6px 16px 18px;
  }

  .details-grid dt {
    padding-bottom: 2px;
    border-bottom: 0;
  }

  .details-grid dd {
    padding-top: 0;
  }

  .chart-wrap {
    height: 190px;
    padding: 8px;
  }

  .chart-wrap-large {
    height: 240px;
  }

  .chart-wrap.live-chart-wrap {
    height: 624px;
    padding: 6px;
  }

  .patient-dialog {
    width: calc(100% - 18px);
  }

  .dialog-head {
    padding: 16px;
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .app-screen {
    padding-inline: 12px;
  }

  .chart-wrap.live-chart-wrap {
    height: 744px;
  }
}

@media (min-width: 1600px) {
  .app-screen {
    width: min(2112px, 100%);
  }

  .chart-wrap {
    height: 280px;
  }

  .chart-wrap-large {
    height: 420px;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 22px;
  }

  .app-screen {
    padding-inline: 8px;
  }

  .institution-head,
  .chart-head,
  .live-packets-head {
    padding-inline: 10px;
  }

  .patient-row {
    padding: 9px;
  }

  .patient-tab {
    font-size: 10px;
  }

  .patient-name {
    font-size: 16px;
  }

  .secondary-button {
    padding-inline: 10px;
  }
}

/* ----- Admin dialogs: users & server status ----- */
.status-dialog {
  width: min(960px, calc(100% - 32px));
}

.admin-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 24px 24px;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.account-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.account-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.account-form input[type="text"],
.account-form input:not([type]) {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--panel);
}

.account-checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
}

.account-checkbox input {
  width: 18px;
  height: 18px;
}

.account-form button[type="submit"] {
  align-self: flex-start;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  font-weight: 700;
  background: var(--accent);
  cursor: pointer;
}

.account-form button[type="submit"]:hover {
  background: var(--accent-strong);
}

.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.accounts-empty {
  margin: 0;
  padding: 12px 0;
  color: var(--muted);
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.account-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.account-info strong {
  color: var(--ink);
  font-size: 15px;
}

.account-info span {
  color: var(--muted);
  font-size: 13px;
}

.account-delete {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--danger, #d6455d);
  border-radius: 6px;
  color: var(--danger, #d6455d);
  font-weight: 700;
  background: var(--panel);
  cursor: pointer;
}

.account-delete:hover {
  color: #fff;
  background: var(--danger, #d6455d);
}

.account-protected {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* status cards + charts */
.status-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.status-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent, var(--line));
  border-radius: 8px;
  background: var(--panel-muted);
}

.status-card-bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.status-card-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent, var(--muted));
  transition: width 0.3s ease;
}

.status-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-card strong {
  color: var(--ink);
  font-size: 26px;
  line-height: 1.1;
}

.status-card small {
  color: var(--muted);
  font-size: 12px;
}

.status-charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.status-chart {
  position: relative;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-chart canvas {
  display: block;
  width: 100%;
  height: 180px;
}

.status-updated {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  .account-form-grid {
    grid-template-columns: 1fr;
  }

  .status-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
