:root {
  color-scheme: light;
  --bg: #f3f4ee;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #111827;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --danger: #b42318;
  --warning: #b54708;
  --info: #175cd3;
  font-family: Urbanist, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.owner-shell { min-height: 100vh; }
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(180deg, #111827 0%, #1f2937 44%, var(--bg) 44%);
}
.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(17, 24, 39, .22);
}
.product-mark {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #027a48;
  font-weight: 800;
}
.login-card h1 { margin: 18px 0 6px; font-size: clamp(2rem, 9vw, 3rem); line-height: .95; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #344054; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: #fff;
  color: var(--ink);
}
.login-card button, .selector-strip button, .owner-header button {
  border: 0;
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}
.message { min-height: 20px; margin-top: 14px !important; color: var(--danger) !important; }

.app-view {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 14px 96px;
}
.owner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 14px;
}
.owner-header span, .owner-panel > header span { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .74rem; }
.owner-header h1 { margin: 3px 0 0; font-size: clamp(1.65rem, 7vw, 2.65rem); line-height: 1; }
.owner-header button { background: #fff; color: var(--ink); border: 1px solid var(--line); }

.selector-strip {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}
.selector-strip button { background: #e7eaf0; color: var(--ink); border: 1px solid var(--line); }

.owner-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  margin: 0 -2px 12px;
  background: rgba(243, 244, 238, .92);
  backdrop-filter: blur(16px);
  overflow-x: auto;
  scrollbar-width: none;
}
.owner-tabs::-webkit-scrollbar { display: none; }
.owner-tabs button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  min-width: 0;
}
.owner-tabs button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 24px rgba(17, 24, 39, .16);
}
.owner-tab { display: none; }
.owner-tab.active { display: grid; gap: 14px; }

.status-banner {
  margin: 0 0 12px;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  font-weight: 800;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.metric-card, .owner-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, .06);
}
.metric-card {
  min-height: 112px;
  padding: 15px;
  display: grid;
  align-content: space-between;
}
.metric-card span { color: var(--muted); font-weight: 800; font-size: .78rem; }
.metric-card strong { font-size: clamp(1.45rem, 5vw, 2.2rem); line-height: 1; }
.metric-card small { color: var(--muted); font-weight: 700; }
.owner-panel { padding: 15px; }
.owner-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.owner-panel h2 { margin: 3px 0 0; font-size: 1.16rem; }
.panel-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  font-weight: 900;
}

.alert-list, .split-list, .ops-list, .branch-cards, .action-grid { display: grid; gap: 9px; }
.action-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.alert-card, .split-row, .ops-row, .branch-card, .action-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fbfcff;
}
.alert-card span {
  display: block;
  color: var(--muted);
  font-weight: 900;
  font-size: .72rem;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.alert-card strong, .branch-card strong, .ops-row strong, .action-card strong { display: block; font-size: 1rem; }
.split-row strong { display: block; }
.alert-card small, .branch-card small, .ops-row small, .split-row small { display: block; color: var(--muted); font-weight: 700; }
.alert-card.critical { border-color: #fecdca; background: #fffbfa; }
.alert-card.warning { border-color: #fedf89; background: #fffcf5; }
.alert-card.info { border-color: #b2ddff; background: #eff8ff; }
.split-row, .branch-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.split-row b, .branch-card b { white-space: nowrap; }
.branch-card {
  text-align: left;
  width: 100%;
  color: inherit;
}
button.branch-card, .action-card { cursor: pointer; }
.action-card {
  text-align: left;
  min-height: 92px;
  color: inherit;
  display: grid;
  align-content: space-between;
}
.action-card small {
  color: var(--muted);
  font-weight: 800;
}
.ops-row { display: grid; gap: 4px; }
.ops-row.ok { border-color: #abefc6; background: #f6fef9; }
.ops-row.warn { border-color: #fedf89; background: #fffcf5; }
.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}
.admin-form button {
  grid-column: 1 / -1;
  border: 0;
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}
.admin-form .full-width { grid-column: 1 / -1; }
.availability-summary {
  margin: -2px 0 2px;
  border: 1px solid #abefc6;
  border-radius: 12px;
  padding: 10px 12px;
  background: #f6fef9;
  color: #067647;
  font-weight: 900;
}
.availability-summary[data-status="warn"] {
  border-color: #fedf89;
  background: #fffcf5;
  color: #b54708;
}
.backup-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}
.backup-summary article {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
  padding: 12px;
}
.backup-summary span,
.backup-summary strong {
  display: block;
}
.backup-summary span {
  color: var(--muted);
  font-weight: 900;
  font-size: .74rem;
}
.backup-summary strong {
  margin-top: 4px;
  font-size: 1.4rem;
}
.backup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.backup-actions button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}
.backup-actions button + button {
  background: #fff;
  color: var(--ink);
}
.backup-config {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 8px;
}
.backup-config label,
.backup-verify {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 900;
}
.backup-config select,
.backup-verify input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px;
}
.backup-help {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
  margin: 0 0 12px;
}
.backup-verify { margin-top: 12px; }
.owner-module-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.owner-module-card { display: grid; align-content: start; gap: 7px; min-height: 170px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcff; }
.owner-module-card.active { border-top: 4px solid var(--green); }
.owner-module-card.locked { opacity: .72; }
.owner-module-card span { color: var(--muted); font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.owner-module-card strong { font-size: 1.02rem; }
.owner-module-card p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.owner-module-card a { align-self: end; justify-self: start; color: var(--green); font-size: .82rem; font-weight: 900; text-decoration: none; }

@media (max-width: 780px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .owner-tabs { grid-template-columns: repeat(9, 96px); }
  .backup-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .backup-config { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .selector-strip { grid-template-columns: 1fr; }
  .owner-header { align-items: flex-start; }
  .owner-header button { padding: 11px 12px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 104px; padding: 13px; }
  .split-row, .branch-card { align-items: flex-start; }
  .admin-form { grid-template-columns: 1fr; }
  .backup-actions { grid-template-columns: 1fr; }
}
