:root {
  --bg: #1A1423;
  --accent: #7A00CC;
  --card: #241C31;
  --card-soft: #2C233B;
  --border: rgba(255,255,255,0.08);
  --text: #FFFFFF;
  --muted: #B8B4C2;
  --danger: #FF5C7A;
  --ok: #57D68D;
  --warn: #FFD166;
}

* { box-sizing: border-box; }

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 1px solid var(--border);
  background: var(--card-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}

button:hover { border-color: rgba(255,255,255,0.22); }
button.primary { background: var(--accent); border-color: transparent; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button:disabled { opacity: .45; cursor: not-allowed; }

input, textarea, select {
  min-width: 0;
  width: 100%;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 11px;
  outline: none;
}

textarea { min-height: 96px; resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
a { color: #D7B8FF; }

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

.login-panel {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
}

.login-panel h1, .page-title h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.login-logo {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  margin-bottom: 14px;
}

.muted { color: var(--muted); }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }

.stack { display: grid; gap: 14px; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.between > * { min-width: 0; }

.shell {
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  min-width: 0;
  max-height: 100vh;
  overflow-y: auto;
  border-color: var(--border);
  background: rgba(36,28,49,0.62);
  padding: 18px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar { border-right: 1px solid var(--border); }
.content {
  min-width: 0;
  max-width: 100%;
  max-height: 100vh;
  overflow-y: auto;
  padding: 22px 72px 22px 22px;
}

.brand {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.hamburger-menu {
  position: fixed;
  z-index: 80;
  top: 18px;
  right: 18px;
  flex: 0 0 auto;
}

.hamburger-menu summary {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  list-style: none;
}

.hamburger-menu summary::-webkit-details-marker {
  display: none;
}

.hamburger-panel {
  position: fixed;
  z-index: 30;
  top: 60px;
  right: 18px;
  width: min(420px, calc(100vw - 36px));
  max-height: calc(100vh - 78px);
  overflow: auto;
  padding: 12px;
  background: #20182B;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.32);
}

.menu-link {
  display: block;
  width: 100%;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  text-decoration: none;
}

.compact-link {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-logo {
  display: block;
  width: 330px;
  max-width: 100%;
  height: auto;
  margin-top: 2px;
}

.search-results {
  position: relative;
}

.results-popover {
  position: absolute;
  z-index: 20;
  top: 44px;
  left: 0;
  right: 0;
  background: #20182B;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.result-item, .customer-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 10px;
}

.customer-list {
  display: grid;
  gap: 4px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.sidebar-dashboard {
  margin-top: auto;
  padding-top: 16px;
}

.mobile-recent-customers,
.tab-select {
  display: none;
}

.customer-pill {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 9px;
  font-size: 13px;
}

.customer-pill.active {
  background: rgba(122,0,204,0.32);
}

.customer-item.active {
  background: rgba(122,0,204,0.22);
  border-radius: 8px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stat, .panel, .record {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat { padding: 14px; }
.stat strong { display: block; font-size: 24px; }
.panel { padding: 16px; }

.dashboard-panel {
  gap: 10px;
  padding: 12px;
}

.compact-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.compact-stats .stat {
  padding: 9px;
}

.compact-stats .stat strong {
  font-size: 18px;
}

.platform-status {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.platform-status-link,
.platform-mini-badge {
  color: var(--text);
  text-decoration: none;
}

.platform-status-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.platform-badge-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.platform-mini-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 8px;
  padding: 7px 8px;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.platform-mini-badge:hover {
  background: rgba(255,255,255,0.055);
  border-color: rgba(255,255,255,0.14);
  color: var(--text);
}

.platform-mini-badge span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-mini-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 999px;
  background: rgba(255,92,122,0.9);
  box-shadow: 0 0 0 3px rgba(255,92,122,0.11);
}

.platform-mini-dot.online {
  background: rgba(87,214,141,0.95);
  box-shadow: 0 0 0 3px rgba(87,214,141,0.12);
}

.platform-mini-dot.degraded,
.platform-mini-dot.offline {
  background: rgba(255,92,122,0.95);
  box-shadow: 0 0 0 3px rgba(255,92,122,0.11);
}

.status-badge,
.status-dot {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.status-badge.healthy,
.status-dot.online {
  color: #B7F4CF;
  background: rgba(87,214,141,0.12);
}

.status-badge.degraded,
.status-dot.degraded {
  color: #FFE3A3;
  background: rgba(255,209,102,0.13);
}

.status-badge.down,
.status-dot.offline {
  color: #FFB5C2;
  background: rgba(255,92,122,0.13);
}

.status-page {
  min-height: 100vh;
  padding: 34px;
  background: var(--bg);
}

.status-hero,
.status-summary-card,
.status-incidents {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.status-hero {
  display: grid;
  gap: 18px;
  padding: 22px 0 24px;
}

.status-logo {
  width: 280px;
  max-width: 100%;
  height: auto;
}

.status-hero h1 {
  margin: 0;
  font-size: 38px;
  letter-spacing: 0;
}

.status-hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.status-summary-card,
.status-service-card,
.status-incidents {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.status-summary-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 18px;
}

.status-summary-card strong {
  display: block;
  margin-top: 3px;
  font-size: 24px;
}

.status-summary-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.status-summary-grid > div {
  padding: 12px;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.status-summary-grid strong {
  font-size: 18px;
}

.status-service-grid {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px auto;
}

.status-service-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.status-service-card p {
  min-height: 42px;
  margin: 0;
}

.status-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.status-incidents {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.incident-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.incident-row p {
  margin: 4px 0 0;
}

.incident-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border);
  margin: 14px 0;
  padding-bottom: 6px;
}

.tab {
  padding: 7px 9px;
  font-size: 13px;
  white-space: nowrap;
  background: transparent;
}

.tab.active {
  background: var(--card);
  border-color: rgba(255,255,255,0.2);
}

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

.record {
  min-width: 0;
  padding: 14px;
}

.record-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.location-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.location-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.location-main {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 0;
  text-align: left;
  background: transparent;
  border: 0;
}

.location-actions {
  width: auto;
  gap: 4px;
  flex-wrap: nowrap;
}

.icon-button {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  opacity: 0.82;
}

.action-icons {
  width: auto;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.field b {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-weight: 500;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.62);
  padding: 20px;
  overflow-x: hidden;
}

.modal {
  width: min(760px, calc(100vw - 40px));
  max-height: 88vh;
  overflow: auto;
  background: #20182B;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

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

.form-grid label.full { grid-column: 1 / -1; }

.markdown {
  color: var(--text);
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.markdown pre {
  max-width: 100%;
  overflow: auto;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.markdown table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 7px;
  text-align: left;
}

.audit-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.audit-row {
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 8px;
}

.settings-menu {
  display: grid;
  gap: 12px;
}

.settings-menu .panel {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 16px;
}

.settings-page {
  min-height: 100vh;
  padding: 34px;
  background: var(--bg);
}

.settings-hero {
  max-width: 1040px;
  margin: 0 auto 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.settings-hero h1 {
  margin: 6px 0 4px;
}

.settings-logo {
  width: min(360px, 78vw);
  height: auto;
  display: block;
}

.settings-page .settings-menu {
  max-width: 1040px;
  margin: 0 auto;
}

@media (max-width: 1120px) {
  .shell { grid-template-columns: 300px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  body { min-width: 0; }
  button { max-width: 100%; white-space: normal; }
  .shell { display: block; width: 100vw; max-width: 100vw; height: auto; max-height: none; overflow-x: hidden; overflow-y: visible; }
  .sidebar { width: 100%; max-width: 100%; max-height: none; overflow: visible; border: 0; border-bottom: 1px solid var(--border); padding: 14px; }
  .content { width: 100%; max-width: 100%; max-height: none; padding: 14px; overflow-x: hidden; overflow-y: visible; }
  .brand, .between { align-items: flex-start; }
  .between { flex-direction: column; }
  .between .row { width: 100%; }
  .brand { align-items: flex-start; margin-bottom: 16px; }
  .brand-logo { width: 290px; max-width: calc(100% - 52px); }
  .hamburger-menu { top: 14px; right: 14px; }
  .hamburger-panel {
    top: 56px;
    right: 14px;
    width: calc(100vw - 28px);
    max-height: calc(100vh - 70px);
  }
  .settings-page { padding: 18px 14px; }
  .settings-hero {
    display: grid;
    align-items: start;
    padding-right: 52px;
  }
  .settings-logo { width: min(300px, calc(100vw - 80px)); }
  .compact-link { width: 100%; }
  .page-title h1 { font-size: 22px; overflow-wrap: anywhere; }
  .tab-select { display: block; margin-bottom: 10px; }
  .mobile-recent-customers {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 10px;
  }
  .customer-list { display: none; }
  .sidebar-dashboard { display: none; }
  .tabs { display: none; }
  .page-title {
    position: relative;
    padding-right: 76px;
  }
  .page-title .action-icons {
    position: absolute;
    top: 0;
    right: 0;
    width: auto;
    justify-content: flex-end;
  }
  .page-title .icon-button {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  .stats, .grid, .form-grid { grid-template-columns: 1fr; }
  .location-cards { grid-template-columns: 1fr; }
  .panel, .record, .stat, .login-panel { max-width: 100%; }
  .modal-backdrop { align-items: start; padding: 12px; }
  .modal { width: calc(100vw - 24px); padding: 14px; }
  .status-page { padding: 18px 14px; }
  .status-logo { width: 230px; }
  .status-hero h1 { font-size: 28px; }
  .status-summary-card,
  .status-service-grid {
    grid-template-columns: 1fr;
  }
  .status-summary-grid {
    grid-template-columns: 1fr;
  }
  .incident-row {
    display: grid;
  }
  .incident-meta {
    justify-items: start;
  }
}
