/* ============================================================
   Учёт воды — Design System · Soft Elevated B
   Tokens → Layout → Components → Animations → Utilities
   ============================================================ */

/* ── 1. Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── 2. Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: inherit; }
a { text-decoration: none; }

/* ── 3. Tokens — light (default) ─────────────────────────── */
:root,
html[data-theme='light'] {
  --page:      #e9ebef;
  --surface:   #ffffff;
  --surface-2: #f5f6f8;
  --surface-3: #eceef1;
  --border:    rgba(20,24,30,.085);
  --border-2:  rgba(20,24,30,.14);
  --text:      #14171b;
  --text-2:    #586069;
  --text-3:    #8a929c;

  --shadow-1: 0 1px 2px rgba(20,24,30,.05), 0 1px 3px rgba(20,24,30,.05);
  --shadow-2: 0 2px 6px rgba(20,24,30,.05), 0 10px 28px rgba(20,24,30,.09);
  --shadow-3: 0 16px 48px rgba(20,24,30,.18);

  --ok:        #1f9d57;
  --ok-bg:     rgba(31,157,87,.12);
  --warn:      #c97a14;
  --warn-bg:   rgba(201,122,20,.13);
  --danger:    #d6453a;
  --danger-bg: rgba(214,69,58,.10);

  --accent:     #0d8a86;
  --accent-h:   #0b7975;
  --on-accent:  #ffffff;
  --accent-ink: #0d8a86;
  --accent-mix: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --focus-ring: color-mix(in srgb, var(--accent) 16%, transparent);

  --surface-inv: #1c2027;
  --text-inv:    #e8eaed;
}

/* ── 4. Tokens — dark ────────────────────────────────────── */
html[data-theme='dark'] {
  --page:      #0b0d10;
  --surface:   #14171b;
  --surface-2: #1a1e23;
  --surface-3: #21262c;
  --border:    rgba(255,255,255,.07);
  --border-2:  rgba(255,255,255,.13);
  --text:      #e7eaee;
  --text-2:    #99a1ab;
  --text-3:    #68717c;

  --shadow-1: 0 1px 2px rgba(0,0,0,.5);
  --shadow-2: 0 2px 6px rgba(0,0,0,.35), 0 14px 36px rgba(0,0,0,.5);
  --shadow-3: 0 20px 56px rgba(0,0,0,.62);

  --ok:        #37cd82;
  --ok-bg:     rgba(55,205,130,.16);
  --warn:      #e3a94a;
  --warn-bg:   rgba(227,169,74,.16);
  --danger:    #f0655a;
  --danger-bg: rgba(240,101,90,.15);

  --accent:     #2cc6bf;
  --accent-h:   #3ed2cb;
  --on-accent:  #05201f;
  --accent-ink: #42d4cd;
  --accent-mix: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --focus-ring: color-mix(in srgb, var(--accent) 16%, transparent);

  --surface-inv: #e8eaed;
  --text-inv:    #1c2027;
}

/* ── 5. Base ─────────────────────────────────────────────── */
html, body {
  height: 100%;
  font-family: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  zoom: 0.95;
  line-height: 1.5;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11' 1;
  letter-spacing: -0.006em;
}

::selection {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ── 6. Keyframes ────────────────────────────────────────── */
@keyframes wpUp    { from { opacity:0; transform:translateY(12px) } to { opacity:1; transform:none } }
@keyframes wpFade  { from { opacity:0 } to { opacity:1 } }
@keyframes wpScale { from { opacity:0; transform:scale(.965) } to { opacity:1; transform:none } }
@keyframes wpDraw  { to   { stroke-dashoffset:0 } }
@keyframes wpReveal{ from { clip-path:inset(0 100% 0 0) } to { clip-path:inset(0 0 0 0) } }
@keyframes wpGrow  { from { transform:scaleY(0) } to { transform:scaleY(1) } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── 7. Shell — sidebar layout ───────────────────────────── */
#app-shell {
  display: flex;
  height: 100%;
  background: var(--page);
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 224px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100%;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 22px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.sidebar-logo .icon { color: var(--accent); }

.sidebar-menu-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 0 12px 8px;
}

#sidebar-nav {
  position: relative;
}
/* Sliding background indicator for sidebar nav */
.nav-indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  border-radius: 11px;
  background: var(--accent-mix);
  pointer-events: none;
  z-index: 0;
}
.nav-indicator--ready {
  transition: top .3s cubic-bezier(.34,1.56,.64,1), height .2s ease;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 3px;
  color: var(--text-2);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  transition: color .2s;
  position: relative;
  z-index: 1;
}
.nav-item:last-child { margin-bottom: 0; }
.nav-item:hover { background: color-mix(in srgb, var(--accent-mix) 50%, var(--surface-2)); }
.nav-item.active {
  color: var(--accent-ink);
  font-weight: 650;
  background: transparent;
}

.sidebar-spacer { flex: 1; }

.sidebar-user-block {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 8px;
}
.sidebar-user-info {
  padding: 0 12px 12px;
}
.sidebar-user-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.sidebar-user-role {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 1px;
}

/* Main area */
#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

/* Topbar */
#topbar {
  height: 62px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 30px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

#topbar-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* Body scroll area */
#main-content {
  flex: 1;
  padding: 26px 30px;
  overflow-y: auto;
}

/* ── 8. Auth pages (login / set-password) ────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--page);
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  animation: wpScale .45s cubic-bezier(.16,.84,.44,1) both;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-logo .icon { color: var(--accent); }

.auth-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 28px;
}

/* ── 9. Form elements ────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--text-2);
  text-transform: uppercase;
  margin-bottom: 7px;
}
.field-label .req { color: var(--danger); }
.field-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 5px;
}
.field-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 5px;
  display: none;
}
.field-error.visible { display: block; }

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
  -webkit-appearance: none;
}
.form-control::placeholder { color: var(--text-3); }
.form-control:focus {
  border-color: var(--accent);
  border-width: 1.5px;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-control.mono,
input.mono,
textarea.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-feature-settings: normal;
  letter-spacing: -0.02em;
}

textarea.form-control {
  height: auto;
  padding: 10px 14px;
  resize: vertical;
  min-height: 80px;
}

/* Input with icon */
.input-wrap {
  position: relative;
}
.input-wrap .form-control { padding-right: 40px; }
.input-wrap .input-icon {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

/* Select */
.form-select {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 14px;
  border-radius: 11px;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238a929c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color .16s, box-shadow .16s;
}
.form-select:focus {
  border-color: var(--accent);
  border-width: 1.5px;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
}
.toggle-label-text {
  font-size: 14px;
  color: var(--text);
  flex: 1;
}
.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background .2s;
}
.toggle input:checked ~ .toggle-track { background: var(--accent); }
.toggle-track::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 99px;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.toggle input:checked ~ .toggle-track::after { transform: translateX(18px); }

/* ── 10. Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border-radius: 11px;
  border: none;
  font-size: 14.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s, color .16s, box-shadow .16s, transform .12s;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--accent-h); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }

.btn-full { width: 100%; }

/* Icon button (36×36) */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 11px;
  border: none;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .16s, color .16s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-3); }
.btn-icon.danger { color: var(--danger); background: var(--danger-bg); }
.btn-icon.danger:hover { background: color-mix(in srgb, var(--danger) 20%, transparent); }

/* Logout nav button */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background .16s, color .16s;
}
.btn-logout:hover { background: var(--surface-2); color: var(--danger); }

/* ── 11. Segmented pill (period / corp filter) ───────────── */
.seg-pill {
  display: inline-flex;
  padding: 4px;
  gap: 3px;
  background: var(--surface-2);
  border-radius: 12px;
  position: relative; /* anchor for indicator */
}
.seg-indicator {
  position: absolute;
  top: 4px;
  left: 0;
  border-radius: 9px;
  background: var(--accent);
  box-shadow: var(--shadow-1);
  pointer-events: none;
  z-index: 0;
}
.seg-btn {
  padding: 7px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  border: none;
  color: var(--text-2);
  background: transparent;
  box-shadow: none;
  font-family: inherit;
  transition: color .2s;
  position: relative;
  z-index: 1; /* above indicator */
}
.seg-btn.active {
  color: var(--on-accent);
  background: transparent;
  box-shadow: none;
}

/* Lang switcher (topbar) */
.lang-pill {
  display: flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 9px;
  position: relative;
}
/* lang-pill indicator sits 2px from top (pill padding = 2px) */
.lang-pill .seg-indicator { top: 2px; border-radius: 7px; }
.lang-btn {
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  color: var(--text-2);
  background: transparent;
  font-family: inherit;
  transition: color .2s;
  position: relative;
  z-index: 1;
}
.lang-btn.active {
  color: var(--on-accent);
  background: transparent;
}

/* ── 12. Panel / Card ────────────────────────────────────── */
.panel {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  border: 1px solid var(--border);
  overflow: visible;
}

.panel-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--text-3);
  text-transform: uppercase;
}

/* Stat card */
.stat-card {
  flex: 1;
  padding: 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}
.stat-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-mix);
  color: var(--accent-ink);
  flex-shrink: 0;
}
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
}
.stat-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.stat-num {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-unit {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
}
.stat-num.accent { color: var(--accent-ink); }

/* ── 13. List rows (readings list) ──────────────────────── */
.list-row {
  display: grid;
  grid-template-columns: 1fr 200px 300px 20px;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .16s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-row:first-child { border-radius: 18px 18px 0 0; }
.list-row:last-child  { border-radius: 0 0 18px 18px; }
.list-row:only-child  { border-radius: 18px; }
.list-row.anim { animation: wpUp .5s cubic-bezier(.16,.84,.44,1) both; }

.row-info { min-width: 0; }
.row-name {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: nowrap;
}

/* Mini bars (sparkline) */
.mini-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 36px;
  width: 100%;
  margin-left: -20px;
}
.mini-bar {
  flex: 1;
  border-radius: 3px;
  transform-origin: bottom;
}

/* Row stats: value · cost · date in one line */
.row-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}
.row-stat-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.row-stat-num {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.row-stat-accent { color: var(--accent-ink); }
.row-stat-unit {
  font-size: 12.5px;
  color: var(--text-3);
  font-weight: 500;
}
.row-stat-date {
  font-size: 14px;
  color: var(--text-3);
  font-weight: 500;
}
.row-stat-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  border-radius: 1px;
  flex-shrink: 0;
}

/* ── 14. Table ───────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table th {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 12px 16px;
  background: var(--surface-2);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th:first-child { border-radius: 12px 0 0 0; }
.data-table th:last-child  { border-radius: 0 12px 0 0; }
.data-table th.right,
.data-table td.right { text-align: right; }

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:last-child td:first-child { border-radius: 0 0 0 17px; }
.data-table tr:last-child td:last-child  { border-radius: 0 0 17px 0; }
.data-table tr:hover td { background: var(--surface-2); }

.td-mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-feature-settings: normal;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.td-bold { font-weight: 700; }
.td-accent { color: var(--accent-ink); font-weight: 700; }
.td-muted { color: var(--text-2); }
.td-actions {
  white-space: nowrap;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* ── 15. Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-admin {
  color: oklch(0.55 0.16 300);
  background: oklch(0.95 0.04 300);
}
html[data-theme='dark'] .badge-admin {
  color: oklch(0.78 0.12 300);
  background: oklch(0.25 0.06 300);
}
.badge-user {
  color: var(--accent-ink);
  background: var(--accent-mix);
}
.badge-manager {
  color: var(--warn);
  background: var(--warn-bg);
}
.badge-ok {
  color: var(--ok);
  background: var(--ok-bg);
}
.badge-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

/* ── 16. Modals ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,24,30,.48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  transition: opacity .22s;
}
.modal-overlay.visible { opacity: 1; }
.modal-overlay.above { z-index: 1100; }

.modal {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-3);
  border: 1px solid var(--border);
  width: 100%;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  transform: scale(.965);
  opacity: 0;
  transition: transform .22s cubic-bezier(.16,.84,.44,1), opacity .22s;
}
.modal-overlay.visible .modal {
  transform: scale(1);
  opacity: 1;
}

.modal.sm  { max-width: 400px; }
.modal.md  { max-width: 520px; }
.modal.lg  { max-width: 680px; }
.modal.xl  { max-width: 860px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Confirm modal */
.confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--danger-bg);
  display: grid;
  place-items: center;
  color: var(--danger);
  margin: 0 auto 14px;
}
.confirm-text {
  text-align: center;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

/* ── 17. Toast ───────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow-3);
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .22s, transform .22s;
  pointer-events: auto;
  max-width: 320px;
}
.toast.visible { opacity: 1; transform: none; }
.toast.ok    { border-left: 3px solid var(--ok);     color: var(--ok); }
.toast.error { border-left: 3px solid var(--danger);  color: var(--danger); }

/* ── 18. Area chart container ────────────────────────────── */
.chart-wrap {
  background: var(--surface-2);
  border-radius: 16px;
  padding: 16px 18px 10px;
  margin-bottom: 18px;
}
.chart-svg { display: block; overflow: visible; }
.chart-labels {
  display: flex;
  justify-content: space-between;
  padding: 8px 2px 0;
}
.chart-label {
  font-size: 10.5px;
  color: var(--text-3);
  font-weight: 600;
}

/* ── 19. Empty state ─────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
}
.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-mix);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
}
.empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
}
.empty-sub {
  font-size: 13px;
  color: var(--text-3);
}

/* ── 20. Invite box ──────────────────────────────────────── */
.invite-box {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 11px;
  padding: 12px 14px;
  margin-top: 14px;
}
.invite-url {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-2);
  word-break: break-all;
  line-height: 1.6;
}

/* ── 21. Credentials box (set-password success) ──────────── */
.creds-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 20px;
}
.cred-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.cred-row:last-child { border-bottom: none; }
.cred-lbl {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}
.cred-val {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── 22. Settings cards ──────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

/* ── 23. Icon helper ─────────────────────────────────────── */
.icon {
  display: block;
  flex-shrink: 0;
}

/* ── 24. Theme toggle (sidebar bottom) ───────────────────── */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 36px;
  padding: 0 12px;
  border-radius: 11px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: background .16s, color .16s;
  margin-bottom: 4px;
}
.theme-toggle-btn:hover { background: var(--surface-2); color: var(--text-2); }

/* ── 25. Form layout helpers ─────────────────────────────── */
.form-row {
  display: flex;
  gap: 16px;
}
.form-row .field { flex: 1; }

.mb-0  { margin-bottom: 0; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }

.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.text-accent { color: var(--accent-ink); }
.text-muted  { color: var(--text-3); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── 26. Detail modal header ─────────────────────────────── */
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-head-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.detail-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--accent-mix);
  color: var(--accent-ink);
  flex-shrink: 0;
}
.detail-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.detail-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── 27. Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  html, body { zoom: 1; font-size: 15px; }
  #sidebar { display: none; }
  #main-content { padding: 18px; }
  #topbar { padding: 0 18px; }
  .list-row {
    grid-template-columns: 1fr auto 20px;
    gap: 12px;
    padding: 14px 16px;
  }
  .list-row .mini-bars { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .stat-cards-row { flex-direction: column; }
  .panel { border-radius: 14px; }
  .reading-table-wrap { display: none; }
  .reading-cards-wrap { display: block !important; }
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .form-control, .btn { font-size: 16px; } /* prevent iOS zoom */
}

/* ── 28. DatePicker ──────────────────────────────────── */
.datepicker-wrap {
  position: relative;
}

/* Trigger inherits .form-control look from inline JS styles;
   these rules add focus ring when calendar is open */
.datepicker-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Dropdown */
.datepicker-dropdown {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: var(--shadow-3);
  padding: 14px;
  min-width: 260px;
  position: absolute;
  z-index: 900;
  margin-top: 4px;
  animation: wpScale .2s cubic-bezier(.16,.84,.44,1) both;
}

/* ── 29. Detail modal scroll fix ─────────────────────── */
#user-readings-overlay .modal {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
#user-readings-modal-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}
.modal-top-fixed {
  flex-shrink: 0;
  padding-bottom: 16px;
}
.modal-history-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  min-height: 0;
}
.modal-history-scroll .data-table {
  border-collapse: separate;
  border-spacing: 0;
}
.modal-history-scroll .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}
.modal-history-scroll::-webkit-scrollbar { width: 4px; }
.modal-history-scroll::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 2px;
}

/* ── 30. Field-label gap fix ─────────────────────────── */
.field-label .req,
.field-label + .req {
  margin-left: 3px;
}

/* ── 31. Table in panel (no double border-radius) ────── */
.panel > div > .data-table th:first-child { border-radius: 0; }
.panel > div > .data-table th:last-child  { border-radius: 0; }
.history-panel .data-table th:first-child,
.history-panel .data-table th:last-child  { border-radius: 0; }

/* ── 32. Stat cards row ──────────────────────────────── */
.stat-cards-row {
  display: flex;
  gap: 12px;
}
@media (max-width: 600px) {
  .stat-cards-row { flex-direction: column; }
  .list-row { grid-template-columns: 1fr auto 20px; gap: 10px; padding: 12px 14px; }
  .list-row .mini-bars { display: none; }
  .row-stat-sep { display: none; }
  .row-stats { gap: 8px; flex-wrap: wrap; }
}

/* ── 33. Nav active indicator — handled by .nav-indicator JS element ── */

/* ── 34. Scrollbar inside modals ─────────────────────── */
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 2px;
}

/* ── 35. Link-2 icon button in table ─────────────────── */
.btn-icon { gap: 0; }

/* ── Field label unit ────────────────────────────────── */
.field-label-unit { color: var(--text-3); font-weight: 500; }

/* ── Mini-bar tooltip (JS-rendered, appended to body) ── */
#bar-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--surface-inv);
  color: var(--text-inv);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: pre;
  padding: 5px 9px;
  border-radius: 7px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  letter-spacing: .01em;
  opacity: 0;
  transition: opacity .1s;
}
#bar-tooltip.visible { opacity: 1; }

/* ── 36. Auth card fade-in (already via wpScale, ensure
         body has no flash on load) ───────────────────── */
body { opacity: 1; }

/* ══════════════════════════════════════════════════════
   37. MOBILE NAVIGATION BAR (removed)
   ══════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════
   38. EXPORT BUTTON & MODAL
   ══════════════════════════════════════════════════════ */

.btn-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* match seg-btn height inside seg-pill (pill 4px pad + btn 7px pad + ~18px line-height = ~40px) */
  padding: 11px 11px;
  border: none;
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: background .18s, color .18s, box-shadow .18s, transform .12s;
  flex-shrink: 0;
}
.btn-export:hover {
  background: var(--surface-3);
  color: var(--text-1);
}
.btn-export:active {
  transform: scale(.94);
}
.btn-export svg { display: block; }

/* Export modal sections */
.export-section {
  margin-bottom: 20px;
}
.export-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}
#export-building-pill {
  flex-wrap: wrap;
  height: auto !important;
  min-height: 38px;
  gap: 4px;
}
#export-period-pill { width: 100%; }
#export-period-pill .seg-btn { flex: 1; text-align: center; }

#export-modal-box {
  width: max-content;
  max-width: min(90vw, 640px);
}
#export-building-pill {
  flex-wrap: nowrap;
  width: max-content;
}
#export-building-pill .seg-btn {
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════
   39. USER READINGS — MOBILE
   ══════════════════════════════════════════════════════ */

/* Reading cards (shown on mobile, hidden on desktop) */
.reading-cards-wrap { display: none; overflow: hidden; border-radius: 14px; }

/* Mobile nav: hidden by default, shown only on mobile */
#mobile-nav { display: none; }

/* Layout: left col (date + cost) | right col (value + delta) */
.reading-card {
  display: flex;
  align-items: stretch;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  min-height: 72px;
}
.reading-card:last-child { border-bottom: none; }
.reading-card { border-radius: 0; transition: background .15s; }
.reading-card:hover { background: var(--surface-2); }
.reading-card:last-child  { border-radius: 0 0 14px 14px; }
.reading-card:only-child  { border-radius: 14px; }

.reading-card-left {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  gap: 6px;
}
.reading-card-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
}
.reading-card-cost {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-ink);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.reading-card-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  gap: 6px;
}
.reading-card-val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}
.reading-card-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
}
.reading-card-delta {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.reading-card-note {
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
}
.reading-card-accent {
  color: var(--accent-ink);
  font-weight: 600;
}

@media (max-width: 640px) {
  /* lang-pill visible in topbar on mobile */

  /* User readings form: stacked, prominent value input */
  .user-form-fields {
    flex-direction: column !important;
    gap: 14px !important;
  }
  .user-form-fields .field {
    flex: none !important;
    min-width: unset !important;
    width: 100% !important;
  }
  /* Кнопка — отдельной строкой на мобильном */
  .user-form-fields { flex-wrap: wrap !important; }
  .user-form-submit {
    width: 100% !important;
    align-self: auto !important;
    justify-content: center;
    margin-top: 2px;
  }
  #rf-value {
    font-size: 28px !important;
    height: 60px !important;
    font-weight: 700;
    text-align: center;
    letter-spacing: -.02em;
  }

}
/* ══════════════════════════════════════════════════════
   40. HISTORY PANEL — collapsible header
   ══════════════════════════════════════════════════════ */

/* Desktop: plain non-interactive label */
.history-panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 18px 22px 14px;
  border: none;
  background: none;
  font-family: inherit;
  cursor: default;
  pointer-events: none;
  border-bottom: 1px solid var(--border);
}
.history-chevron { display: none; }
.history-panel-body { display: block; }

/* Mobile: tappable, animated */
@media (max-width: 768px) {
  .history-panel-hdr {
    padding: 16px 20px;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
  }
  .history-panel-hdr[aria-expanded="false"] {
    border-bottom: none;
  }
  .history-chevron {
    display: flex;
    color: var(--text-3);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1);
    flex-shrink: 0;
  }
  .history-panel-hdr[aria-expanded="true"] .history-chevron {
    transform: rotate(180deg);
  }
  .history-panel-body {
    overflow: hidden;
    transition: max-height .35s cubic-bezier(.16,.84,.44,1);
  }

  /* Mobile bottom nav */
  #mobile-nav {
    display: flex !important;
    align-items: stretch;
    background: var(--surface);
    border-top: 1px solid var(--border);
    height: 60px;
    flex-shrink: 0;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-3);
    cursor: pointer;
    border-radius: 12px;
    padding: 6px 4px;
    transition: color .18s;
    letter-spacing: .01em;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-btn svg { transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
  .mobile-nav-btn.active { color: var(--accent-ink); font-weight: 700; }
  .mobile-nav-btn.active svg { transform: scale(1.12); }
}

/* ── Mobile theme toggle button (topbar, icon only) ─────── */
.mobile-theme-btn {
  display: none; /* hidden on desktop */
}
@media (max-width: 768px) {
  .mobile-theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    margin-right: -5px;
    transition: background .18s, color .18s, transform .12s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-theme-btn:active { transform: scale(.88); }
}