* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button,
input,
select {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
a {
  color: var(--blue);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: auto;
}
.brand {
  color: var(--ink);
  text-decoration: none;
}
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.row.wrap {
  flex-wrap: wrap;
}
.btn,
button.primary {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  border: 0;
  background: var(--blue);
  color: var(--button-ink);
  margin: 10px 0;
}
.secondary {
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}
input,
select {
  display: block;
  width: 100%;
  background: var(--card);
  color: var(--ink);
  padding: 12px;
  border: 1px solid var(--line);
  margin: 8px 0 12px;
}
label {
  font-size: 13px;
  color: var(--muted);
}
nav {
  display: flex;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
}
nav button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
}
.person {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  margin: 8px 0;
}
.person .row {
  flex-wrap: wrap;
}
.person p {
  margin: 8px 0 4px;
}
.person > small {
  display: block;
}
.link {
  display: block;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
dialog {
  width: calc(100% - 32px);
  max-height: 85dvh;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}
#notice {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  max-width: 92%;
  padding: 14px 18px;
  background: var(--ink);
  color: var(--card);
  border-radius: 10px;
  z-index: 10;
}
.secret {
  word-break: break-all;
  font-size: 13px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  user-select: all;
}
details {
  margin: 14px 0;
}
summary {
  cursor: pointer;
  padding: 10px 0;
}
.back-link {
  border: 0;
  background: none;
  color: var(--blue);
  padding: 4px 0 18px;
  font-weight: 600;
}
.person-heading h1 {
  overflow-wrap: anywhere;
}
.person-status {
  margin: 18px 0;
}
.usage-panel h2 {
  margin: 0;
}
.period-switch {
  display: flex;
}
.period-switch button {
  border: 0;
  background: none;
  color: var(--muted);
  min-height: 40px;
}
.period-switch button[aria-pressed="true"] {
  background: var(--card);
  color: var(--ink);
}
.usage-total {
  font-weight: 720;
  margin-bottom: 2px;
}
.usage-directions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  color: var(--muted);
}
.chart-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 22px;
}
.usage-chart {
  display: flex;
  align-items: stretch;
  margin-top: 8px;
  border-bottom: 1px solid var(--line);
}
.chart-column {
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  padding: 0;
  overflow: hidden;
}
.chart-column span {
  display: block;
  width: 100%;
  min-height: 1px;
}
.chart-column:hover,
.chart-column:focus-visible {
  background: var(--line);
}
.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  padding-top: 6px;
}
.chart-selection {
  color: var(--muted);
}
.route-row {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
}
.route-row > span {
  flex: 1;
  min-width: 0;
}
.route-row i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}
.route-row > small {
  width: 36px;
  text-align: right;
}
.route-row > strong {
  white-space: nowrap;
}
.route-row span small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
}
.person-controls {
  margin-top: 28px;
}
.person-controls h2 {
  font-size: 15px;
  color: var(--muted);
}

/* Shared cabinet system: Telegram theme remains the source of the surface colors. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f3f5f4);
  --card: var(--tg-theme-bg-color, #fff);
  --ink: var(--tg-theme-text-color, #172b29);
  --muted: var(--tg-theme-hint-color, #61726e);
  --blue: #246b5b;
  --button-ink: #fff;
  --line: #74888030;
  --soft: #7393830c;
  --accent: #bde894;
  --hero: #203e36;
  --hero-ink: #f2f9ed;
  --radius: 20px;
  color-scheme: light;
}
body {
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.12px;
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
header {
  max-width: 1120px;
  background: transparent;
  border-bottom: 1px solid var(--line);
  padding: 24px 28px;
  padding-top: calc(24px + env(safe-area-inset-top));
}
.brand {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.8px;
  display: flex;
  gap: 16px;
  align-items: center;
}
.brand-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 600;
  border-left: 1px solid var(--line);
  padding-left: 16px;
}
#switch {
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 9px 15px;
  color: var(--ink);
}
#switch:hover {
  background: var(--soft);
}
[hidden] {
  display: none !important;
}
main {
  max-width: 1120px;
  padding: 36px 28px;
  margin: auto;
}
.member-mode main,
.member-mode header {
  max-width: 900px;
}
h1 {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.14;
  margin-bottom: 12px;
}
h2 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.4px;
}
h3 {
  font-size: 16px;
}
p {
  margin: 8px 0 16px;
}
small,
.muted {
  color: var(--muted);
}
small {
  font-size: 12px;
}
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
  margin: 0 0 12px;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin: 0 0 26px;
}
.page-heading p:last-child {
  margin-bottom: 0;
}
.card {
  border-radius: var(--radius);
  padding: 26px;
  margin: 20px 0;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 3px 16px #162f2403;
}
.dashboard-grid,
.member-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.dashboard-grid .card,
.member-grid > .card {
  margin: 0;
}
.member-grid {
  margin-bottom: 24px;
}
.member-grid > .card {
  height: 100%;
}
.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.btn,
button.primary {
  border-radius: 12px;
  font-size: 14px;
  min-height: 48px;
  padding: 13px 18px;
  font-weight: 650;
  transition:
    background 0.15s,
    transform 0.15s;
}
.btn:hover {
  filter: brightness(0.96);
}
.btn:active {
  transform: translateY(1px);
}
.compact {
  width: auto;
  white-space: nowrap;
}
.secondary {
  background: var(--soft) !important;
}
.danger {
  background: #b23e4c !important;
}
.text-button {
  border: 0;
  background: none;
  padding: 12px;
  font-size: 13px;
}
.badge {
  border-radius: 30px;
  font-size: 11px;
  font-weight: 650;
  padding: 5px 10px;
  border: 0;
  background: var(--soft);
  line-height: 1.5;
}
.badge.good {
  background: #27947114;
}
.badge.wait {
  background: #bc881a16;
}
.badge.bad {
  background: #d1566714;
}
.good {
  color: #26755c;
}
.bad {
  color: #b23e4c;
}
.wait {
  color: #936013;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric {
  background: var(--card);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-width: 0;
}
.metric > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.metric strong {
  display: block;
  font-size: 30px;
  letter-spacing: -1px;
  line-height: 1.2;
  margin: 12px 0 8px;
  font-variant-numeric: tabular-nums;
}
.metric small {
  font-size: 10px;
  display: block;
}
.health-banner {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  padding: 17px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  margin-bottom: 30px;
}
.health-banner small {
  display: block;
  margin-top: 7px;
}
.health-banner > span:last-child {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
}
.section-heading h2 {
  margin: 0;
}
.section-heading + .usage-panel {
  margin-top: 12px;
}
nav {
  max-width: 740px;
  bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 8px 40px #11281c16;
  padding: 7px;
  gap: 4px;
  z-index: 5;
  width: calc(100% - 32px);
}
nav button {
  font-size: 12px;
  border-radius: 13px;
  min-height: 48px;
  padding: 10px 6px;
  font-weight: 500;
}
nav button.active {
  background: var(--hero);
  color: var(--hero-ink);
}
input,
select {
  min-height: 46px;
  font-size: 14px;
  border-radius: 12px;
  border-color: var(--line);
}
input:focus,
select:focus {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid #8da859;
  outline-offset: 3px;
}
label {
  display: block;
}
.period-switch {
  border: 0;
  padding: 4px;
  background: var(--soft);
  border-radius: 12px;
}
.period-switch button {
  border-radius: 9px;
  padding: 8px 16px;
}
.period-switch button[aria-pressed="true"] {
  box-shadow: 0 1px 5px #14271e14;
}
.usage-panel {
  padding: 26px;
}
.usage-total {
  font-size: 44px;
  letter-spacing: -2px;
  margin-top: 24px;
  font-variant-numeric: tabular-nums;
}
.usage-directions {
  font-size: 12px;
  margin-bottom: 20px;
}
.usage-panel select {
  width: auto;
  min-width: 160px;
  max-width: 100%;
  margin-top: 6px;
}
.usage-chart {
  height: 180px;
  gap: 5px;
  background: repeating-linear-gradient(
    to top,
    transparent 0,
    transparent 59px,
    var(--line) 60px
  );
}
.chart-column {
  border-radius: 5px 5px 0 0;
  min-width: 5px;
}
.chart-column span {
  background: #59bbaa;
}
.chart-column:focus-visible {
  outline-offset: -3px;
}
.chart-selection {
  min-height: 24px;
  margin: 14px 0;
  font-size: 11px;
}
.route-row {
  padding: 15px 0;
  font-size: 13px;
}
.route-row > strong {
  font-variant-numeric: tabular-nums;
}
.route-row > span {
  overflow-wrap: anywhere;
}
.route-row .badge {
  flex: 0 0 auto;
}
.history-chart {
  gap: 8px;
  overflow-x: auto;
}
.ranking-row {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  text-align: left;
}
.rank {
  font-size: 11px;
  color: var(--muted);
  width: 18px;
  padding-top: 3px;
}
.ranking-content {
  flex: 1;
  min-width: 0;
}
.ranking-content strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}
.ranking-content small {
  white-space: nowrap;
  font-size: 11px;
}
.ranking-content meter {
  display: block;
  width: 100%;
  height: 8px;
  margin: 10px 0 0;
  border: 0;
  background: var(--soft);
  border-radius: 4px;
}
.ranking-content meter::-webkit-meter-bar {
  background: var(--soft);
  border: 0;
  height: 6px;
}
.ranking-content meter::-webkit-meter-optimum-value {
  background: #59bbaa;
  border-radius: 4px;
}
.ranking-content meter::-moz-meter-bar {
  background: #59bbaa;
}
.connect-card {
  background: var(--hero);
  color: var(--hero-ink);
  border: 0;
}
.connect-card .muted,
.connect-card small {
  color: #c4d8cf;
}
.connect-card .badge.good {
  background: #bde894;
  color: #23432f;
}
.connect-card .badge.wait {
  color: #ffe3a5;
  background: #634d2d;
}
.connect-card .badge.bad {
  color: #ffc7c7;
  background: #5c3139;
}
.connect-title {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.8px;
  margin: 30px 0 16px;
}
.connect-card .btn:not(.secondary) {
  background: var(--accent);
  color: #1d3727;
}
.connect-card .secondary {
  color: var(--hero-ink) !important;
  background: #ffffff09 !important;
  border-color: #ffffff25 !important;
}
.route-card > p {
  font-size: 13px;
}
.route-card > p strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.route-card details {
  border-top: 1px solid var(--line);
  margin-top: 20px;
}
.route-card summary {
  font-size: 12px;
  font-weight: 600;
}
.route-card details p {
  font-size: 12px;
}
.route-card details small {
  font-size: 11px;
}
.person {
  border-radius: 16px;
  padding: 20px;
  transition: border-color 0.15s;
}
.person:hover {
  border-color: #59bbaa;
}
.person-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: #59bbaa19;
  color: var(--blue);
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
}
.person p {
  font-size: 12px;
}
.person > small {
  font-size: 11px;
}
.person-controls {
  max-width: 640px;
}
.section-tabs {
  display: flex;
  gap: 6px;
  margin: 24px 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.section-tabs button {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
}
.section-tabs .active {
  background: var(--hero);
  color: var(--hero-ink);
}
.event {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.event:last-child {
  border: 0;
}
.event p {
  font-size: 13px;
  margin: 8px 0;
}
.empty-state {
  padding: 26px;
  color: var(--muted);
  font-size: 13px;
}
.loading-state {
  padding: 80px 20px;
  text-align: center;
  color: var(--muted);
}
dialog {
  max-width: 480px;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 24px 80px #0003;
}
dialog::backdrop {
  background: #11251dd0;
  backdrop-filter: blur(3px);
}
#notice {
  bottom: 110px;
  font-size: 13px;
  box-shadow: 0 8px 30px #0002;
}
.preview-banner {
  font-size: 11px;
  background: #e8efdc;
  color: #354b28;
  padding: 8px 20px;
  text-align: center;
}
.preview-banner a {
  color: inherit;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: var(--tg-theme-secondary-bg-color, #111a18);
    --card: var(--tg-theme-bg-color, #1a2522);
    --ink: var(--tg-theme-text-color, #ecf2ef);
    --muted: var(--tg-theme-hint-color, #a0b3aa);
    --blue: #bde894;
    --button-ink: #203527;
    --line: #a4c3af25;
    --soft: #b3c8bb09;
    --hero: #233e34;
  }
  :root:not([data-theme="light"]) .good {
    color: #89cfad;
  }
  :root:not([data-theme="light"]) .bad {
    color: #f69aa5;
  }
  :root:not([data-theme="light"]) .wait {
    color: #e4c180;
  }
  :root:not([data-theme="light"]) .badge.good {
    background: #6dbd9220;
  }
  :root:not([data-theme="light"]) .badge.bad {
    background: #f69aa515;
  }
  :root:not([data-theme="light"]) .badge.wait {
    background: #e4c18015;
  }
  :root:not([data-theme="light"]) .secondary {
    color: var(--ink) !important;
  }
  :root:not([data-theme="light"]) .danger {
    color: #fff !important;
  }
  :root:not([data-theme="light"]) .metric {
    box-shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-secondary-bg-color, #111a18);
  --card: var(--tg-theme-bg-color, #1a2522);
  --ink: var(--tg-theme-text-color, #ecf2ef);
  --muted: var(--tg-theme-hint-color, #a0b3aa);
  --blue: #bde894;
  --button-ink: #203527;
  --line: #a4c3af25;
  --soft: #b3c8bb09;
  --hero: #233e34;
}
:root[data-theme="dark"] .good {
  color: #89cfad;
}
:root[data-theme="dark"] .bad {
  color: #f69aa5;
}
:root[data-theme="dark"] .wait {
  color: #e4c180;
}
:root[data-theme="dark"] .badge.good {
  background: #6dbd9220;
}
:root[data-theme="dark"] .badge.bad {
  background: #f69aa515;
}
:root[data-theme="dark"] .badge.wait {
  background: #e4c18015;
}
:root[data-theme="dark"] .secondary {
  color: var(--ink) !important;
}
:root[data-theme="dark"] .danger {
  color: #fff !important;
}
:root[data-theme="dark"] .metric {
  box-shadow: none;
}
@media (min-width: 900px) {
  .usage-panel {
    position: relative;
  }
  .usage-panel > label {
    position: absolute;
    right: 26px;
    top: 95px;
  }
  .usage-chart {
    height: 190px;
  }
  .usage-panel .usage-directions {
    margin-bottom: 40px;
  }
  #people-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  #people-list .person {
    margin: 0;
  }
  #search {
    display: inline-block;
    width: calc(65% - 8px);
    margin-right: 12px;
  }
  #filter {
    display: inline-block;
    width: calc(35% - 8px);
  }
}
@media (max-width: 700px) {
  header {
    padding: 18px 20px;
    padding-top: calc(18px + env(safe-area-inset-top));
  }
  .brand {
    font-size: 29px;
  }
  .brand-label {
    font-size: 8px;
    letter-spacing: 1.5px;
    gap: 10px;
  }
  main {
    padding: 28px 20px;
  }
  h1 {
    font-size: 32px;
    letter-spacing: -1.1px;
  }
  .page-heading {
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 24px;
  }
  .page-heading > .compact {
    padding: 9px 12px;
    font-size: 11px;
    min-height: 40px;
    margin-top: 3px;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .metric {
    padding: 17px;
  }
  .metric strong {
    font-size: 27px;
  }
  .metric > span {
    font-size: 11px;
  }
  .metric small {
    font-size: 10px;
  }
  .dashboard-grid,
  .member-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .card {
    padding: 22px;
    border-radius: 18px;
  }
  .dashboard-grid {
    margin-top: 20px;
  }
  .section-heading {
    display: block;
  }
  .section-heading small {
    display: block;
    margin-top: 6px;
  }
  .health-banner {
    padding: 15px;
    margin-bottom: 24px;
  }
  .health-banner > span:last-child {
    font-size: 0;
  }
  .health-banner > span:last-child::after {
    content: "→";
    font-size: 18px;
  }
  .health-banner small {
    font-size: 10px;
  }
  .usage-total {
    font-size: 40px;
  }
  .usage-panel .row {
    align-items: center;
    gap: 6px;
  }
  .usage-panel h2 {
    font-size: 17px;
  }
  .period-switch button {
    padding: 7px 10px;
    font-size: 11px;
  }
  .usage-chart {
    gap: 3px;
    height: 150px;
  }
  .route-row {
    gap: 8px;
    font-size: 12px;
  }
  nav {
    bottom: 0;
    left: 0;
    transform: none;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: none;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
  nav button {
    font-size: 10px;
    padding: 10px 4px;
    min-height: 46px;
  }
  .member-mode {
    padding-bottom: 30px;
  }
  .help-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .connect-title {
    font-size: 29px;
  }
  .connect-card .btn {
    margin-top: 14px;
  }
  .person .row {
    gap: 8px;
  }
  .route-card > p strong {
    font-size: 22px;
  }
  .compact-limits .route-row {
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
.qr-code {
  text-align: center;
  margin: 20px 0;
}
.qr-code img {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: 12px;
}
.secret {
  overflow-wrap: anywhere;
}
.config-filters {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.config-filters label {
  white-space: nowrap;
}
.config-filters input[type="checkbox"] {
  display: inline;
  width: 18px;
  min-height: 18px;
  vertical-align: middle;
  margin: 0 8px 0 0;
}
.section-tabs {
  overflow-x: auto;
}
.section-tabs button {
  white-space: nowrap;
}
@media (max-width: 700px) {
  .metric strong {
    font-size: 24px;
    white-space: nowrap;
  }
  .metric {
    padding: 16px;
  }
  .metric small {
    line-height: 1.45;
  }
  .health-banner {
    min-height: 70px;
  }
  .page-heading {
    margin-bottom: 20px;
  }
  .health-banner > span:last-child {
    display: none;
  }
}

.import-mode main {
  max-width: 560px;
  margin: 48px auto;
}
.config-uri {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  resize: vertical;
  font: inherit;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .import-mode main {
    margin: 24px 16px;
  }
}
