:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  --bg: #e8eef6;
  --surface: #fcfeff;
  --surface-strong: #fefefe;
  --border: rgba(33, 53, 85, 0.14);
  --text: #14213d;
  --muted: #556679;
  --accent: #0d8b78;
  --accent-strong: #ff7a59;
  --accent-deep: #0b5c8a;
  --danger: #a4382a;
  --shadow: 0 24px 60px rgba(40, 59, 92, 0.14);
  --soft-shadow: 0 14px 36px rgba(40, 59, 92, 0.1);
  --sidebar-width: 264px;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(13, 139, 120, 0.08), transparent 36%),
    linear-gradient(180deg, #f5f8fb 0%, var(--bg) 100%);
}

[hidden] {
  display: none !important;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand-secret-button {
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.05;
}

.brand-secret-button:hover {
  border-color: transparent;
  background: transparent;
  transform: none;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 14px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

button:hover {
  border-color: rgba(13, 139, 120, 0.38);
  background: rgba(13, 139, 120, 0.08);
}

button:active {
  transform: translateY(1px);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(13, 139, 120, 0.55);
  box-shadow: 0 0 0 3px rgba(13, 139, 120, 0.12);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 24px;
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
}

.sidebar {
  position: sticky;
  top: 20px;
  align-self: start;
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.brand-block,
.page-card,
.entity-card,
.list-item,
.empty,
.photo-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--soft-shadow);
}

.brand-block {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.session {
  display: grid;
  gap: 10px;
}

.session span {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.session button,
.toolbar button,
.auth-actions button,
.form-grid button {
  border-color: rgba(13, 139, 120, 0.34);
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  font-weight: 700;
}

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

.auth-card {
  display: grid;
  gap: 18px;
  width: min(520px, 100%);
  padding: clamp(24px, 6vw, 42px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: clamp(34px, 8vw, 58px);
}

.auth-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-actions,
.admin-auth-form {
  display: grid;
  gap: 10px;
}

.auth-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-auth-form {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.auth-actions button {
  min-width: 0;
  min-height: 48px;
  overflow-wrap: anywhere;
}

.auth-status[data-tone="error"] {
  color: var(--danger);
}

.settings-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 16px;
}

.settings-list article {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.settings-list strong,
.settings-list span {
  overflow-wrap: anywhere;
}

.admin-settings-panel {
  margin-top: 14px;
}

.mileage-chart-panel {
  margin-bottom: 14px;
}

.chart-toolbar {
  display: grid;
  gap: 12px;
}

.chart-controls {
  display: grid;
  grid-template-columns: minmax(140px, 180px) repeat(2, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.mileage-chart {
  min-height: 260px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
}

.mileage-chart svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 260px;
}

.chart-grid-line {
  stroke: rgba(33, 53, 85, 0.12);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 12px;
  text-anchor: middle;
}

.chart-axis-label--left {
  text-anchor: end;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-dot {
  fill: var(--accent-strong);
  stroke: #fff;
  stroke-width: 2;
}

.nav-list {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-group > span {
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-link {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}

.nav-link.active {
  border-color: rgba(13, 139, 120, 0.28);
  background: linear-gradient(135deg, rgba(13, 139, 120, 0.15), rgba(11, 92, 138, 0.1));
  color: var(--accent-deep);
  font-weight: 800;
}

.content {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
  padding-bottom: 20px;
}

.shell-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.shell-breadcrumbs {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.shell-breadcrumbs span,
#statusLine {
  color: var(--muted);
  font-size: 13px;
}

.shell-breadcrumbs strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
}

#statusLine {
  min-width: 160px;
  text-align: right;
}

#statusLine[data-tone="error"] {
  color: var(--danger);
}

.page-card {
  padding: 18px;
}

.inline-form,
.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-form {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.inline-form label {
  min-width: 180px;
  flex: 1;
}

.toolbar {
  justify-content: space-between;
}

.toolbar label {
  min-width: min(100%, 360px);
}

.tab-panel {
  display: none;
  min-width: 0;
}

.tab-panel.active {
  display: block;
}

.metric-grid,
.two-column,
.three-column,
.settings-grid {
  display: grid;
  gap: 14px;
}

.metric-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  margin-bottom: 14px;
}

.three-column {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.entity-card {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 16px;
}

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

.entity-card strong {
  font-size: clamp(22px, 2.2vw, 28px);
  overflow-wrap: anywhere;
}

.entity-card p,
.settings-grid p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid h2 {
  margin-bottom: 0;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.list,
.report-list,
.photo-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.compact-list {
  display: grid;
  gap: 6px;
}

.account-link-code {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.browser-telegram-auth {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.browser-telegram-auth strong {
  font-size: 28px;
  overflow-wrap: anywhere;
}

.browser-telegram-auth p {
  margin: 0;
  color: var(--muted);
}

.telegram-deep-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.list-item {
  padding: 14px 16px;
}

.list-item div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.list-item strong,
.photo-item strong {
  overflow-wrap: anywhere;
}

.list-item span,
.list-item p {
  color: var(--muted);
}

.list-item p {
  margin: 8px 0 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.empty {
  padding: 14px 16px;
  color: var(--muted);
}

.photo-item {
  overflow: hidden;
}

.photo-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: rgba(33, 53, 85, 0.08);
}

.photo-item div {
  display: grid;
  gap: 4px;
  padding: 12px;
}

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

.sidebar-backdrop,
.mobile-action-bar {
  display: none;
}

@media (max-width: 1180px) {
  .metric-grid,
  .three-column,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .shell {
    display: block;
    padding: 14px 14px 88px;
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(340px, 88vw);
    max-height: none;
    padding: 12px;
    border-right: 1px solid var(--border);
    background: #fff;
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .shell.shell--mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    width: 100%;
    min-height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(20, 33, 61, 0.34);
    box-shadow: none;
  }

  .shell.shell--mobile-nav-open .sidebar-backdrop {
    display: block;
  }

  .content {
    gap: 12px;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
  }

  .mobile-action-bar {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .mobile-action-bar button {
    min-width: 0;
    padding: 8px 10px;
    overflow: hidden;
    font-size: 14px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 720px) {
  body {
    background: var(--bg);
  }

  .shell {
    padding: 10px 10px 86px;
  }

  .shell-context-bar {
    align-items: stretch;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  #statusLine {
    grid-column: 1 / -1;
    min-width: 0;
    text-align: left;
  }

  .metric-grid,
  .two-column,
  .three-column,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .chart-controls,
  .auth-actions,
  .toolbar {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .inline-form label,
  .toolbar label {
    min-width: 0;
  }

  .list-item div {
    display: grid;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }
}
