:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fbfd;
  --ink: #141923;
  --text: #465060;
  --muted: #707b8c;
  --line: #dce2ea;
  --line-2: #c9d2df;
  --accent: #087f73;
  --accent-dark: #045d55;
  --accent-soft: #e4f5f2;
  --blue: #246bcb;
  --blue-soft: #e7f0ff;
  --amber: #a55b00;
  --amber-soft: #fff1dc;
  --danger: #bb2f35;
  --danger-soft: #ffe7e8;
  --ok: #147042;
  --ok-soft: #e3f5eb;
  --shadow: 0 18px 48px rgba(22, 31, 46, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    linear-gradient(135deg, rgba(8, 127, 115, 0.12), transparent 40%),
    linear-gradient(315deg, rgba(36, 107, 203, 0.10), transparent 36%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
  margin: 14px 0 24px;
}

h2 {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

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

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

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

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

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

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.map-link {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  min-height: 46px;
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.map-link {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-2);
}

.secondary-button:hover,
.map-link:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.ghost-button:hover {
  background: var(--surface);
  color: var(--ink);
}

.ghost-button.danger {
  color: var(--danger);
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line);
}

.message {
  min-height: 20px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--ok);
}

.message.notice {
  color: var(--amber);
}

.app-view {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 247, 251, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-inner,
.content,
.tabs {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-row,
.account-row,
.action-row,
.filter-row,
.panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row {
  min-width: 0;
}

.account-row {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.account-name {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 18px 0 8px;
  overflow-x: auto;
}

.tab-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.tab-button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.content {
  padding: 18px 0 56px;
}

.status-layout,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(22, 31, 46, 0.05);
  padding: 20px;
  margin-bottom: 16px;
}

.panel-title {
  justify-content: space-between;
  margin-bottom: 18px;
}

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

.metric-grid div,
.office-grid div {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.metric-grid span,
.office-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-grid strong,
.office-grid strong {
  min-width: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.15;
  word-break: break-word;
}

.status-panel .action-row {
  margin-top: 18px;
  flex-wrap: wrap;
}

.office-grid {
  display: grid;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.neutral {
  background: var(--blue-soft);
  color: var(--blue);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

td strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

td span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-actions input {
  width: 160px;
  min-height: 38px;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-metrics {
  margin-bottom: 16px;
}

.dialog {
  width: min(420px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.34);
}

@media (max-width: 920px) {
  .status-layout,
  .admin-grid,
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .status-panel,
  .admin-grid .panel:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  .account-row {
    width: 100%;
    justify-content: flex-start;
  }

  .login-panel {
    padding: 24px;
  }

  .status-layout,
  .admin-grid,
  .metric-grid,
  .admin-head {
    grid-template-columns: 1fr;
  }

  .admin-head {
    display: grid;
  }

  .filter-row,
  .action-row {
    width: 100%;
  }

  .filter-row input,
  .filter-row button,
  .action-row button {
    flex: 1 1 150px;
  }
}
