:root {
  --ink: #101010;
  --paper: #f7f2df;
  --white: #fffdf5;
  --yellow: #fff200;
  --red: #ff3b30;
  --green: #20d26b;
  --line: #101010;
  --shadow: 6px 6px 0 var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(rgba(16,16,16,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,16,16,.06) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 4px solid var(--line);
  background: var(--yellow);
  min-height: 48px;
  padding: 10px 18px;
  font-weight: 950;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
}

button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
button.ghost { background: var(--white); }
button.danger { background: var(--red); color: white; }
button:disabled {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
  box-shadow: none;
}

input, select {
  width: 100%;
  min-height: 50px;
  border: 4px solid var(--line);
  background: var(--white);
  padding: 10px 12px;
  font-weight: 850;
  border-radius: 0;
}

.ops-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 14px clamp(14px, 5vw, 44px);
  background: var(--yellow);
  border-bottom: 5px solid var(--line);
}

.ops-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-size: clamp(24px, 5vw, 42px);
  font-weight: 1000;
  line-height: .95;
}

.mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: var(--white);
  border: 4px solid var(--line);
  box-shadow: 4px 4px 0 var(--ink);
}

.ops-session {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 12px;
  border: 4px solid var(--line);
  background: var(--white);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 15px;
  font-weight: 1000;
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px);
}

.login-panel, .panel, .metric, .tenant-card, .row-card {
  background: var(--white);
  border: 5px solid var(--line);
  box-shadow: var(--shadow);
}

.login-panel {
  max-width: 620px;
  margin: 9vh auto 0;
  padding: clamp(22px, 5vw, 46px);
}

.stamp {
  display: inline-block;
  border: 3px solid var(--line);
  background: var(--yellow);
  padding: 4px 9px;
  font-size: 14px;
  font-weight: 1000;
  margin-bottom: 18px;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(44px, 8vw, 92px); line-height: .95; margin-bottom: 18px; }
h2 { font-size: clamp(24px, 4vw, 38px); margin-bottom: 16px; }
p { font-size: 20px; font-weight: 800; line-height: 1.4; }

.error { color: var(--red); min-height: 24px; margin: 12px 0 0; }

.hero {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 24px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.tabs button {
  background: var(--white);
  min-width: 0;
  padding: 10px 6px;
}

.tabs button.active { background: var(--yellow); }

.tab { display: none; }
.tab.active { display: block; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.compact-metrics .metric b { font-size: clamp(28px, 4vw, 48px); }

.metric { padding: 18px; }
.metric b { display: block; font-size: clamp(32px, 6vw, 62px); line-height: 1; }
.metric span { display: block; margin-top: 8px; font-size: 15px; font-weight: 900; color: #444; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel { padding: clamp(16px, 4vw, 26px); margin-bottom: 22px; }

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title-row h2 { margin-bottom: 0; }

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 18px;
}

.toolbar select { width: auto; min-width: 150px; }
.toolbar.log-toolbar { grid-template-columns: auto auto auto 1fr auto; }

#tab-usage .toolbar.log-toolbar {
  grid-template-columns: auto 1fr auto auto;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 28px;
  font-size: 16px;
  font-weight: 950;
}

.pager button {
  min-height: 42px;
  padding: 7px 12px;
  box-shadow: 3px 3px 0 var(--ink);
}

.tenant-card, .row-card {
  padding: 16px;
  margin-bottom: 14px;
}

.tenant-head, .row-head, .tenant-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tenant-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tenant-logo {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border: 4px solid var(--line);
  background: var(--yellow);
  font-size: 26px;
  font-weight: 1000;
  overflow: hidden;
}

.tenant-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tenant-name, .row-head b {
  font-size: 24px;
  font-weight: 1000;
  word-break: keep-all;
}

.subline, .muted {
  color: #555;
  font-size: 15px;
  font-weight: 800;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.mini {
  border: 3px solid var(--line);
  background: var(--paper);
  padding: 10px;
  font-weight: 950;
}

.mini span { display: block; font-size: 13px; color: #555; }

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 120px;
  gap: 8px;
  margin-top: 12px;
}

.logo-tools {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: stretch;
  margin-top: 12px;
}

.logo-tools button {
  min-height: 50px;
  padding-inline: 12px;
}

.logo-preview {
  display: grid;
  place-items: center;
  min-height: 58px;
  border: 4px solid var(--line);
  background: var(--paper);
  overflow: hidden;
  font-size: 13px;
  font-weight: 950;
  text-align: center;
}

.logo-preview img {
  width: 100%;
  height: 58px;
  object-fit: contain;
  background: var(--white);
}

.logo-help {
  margin-top: 8px;
}

.tenant-delete-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.tenant-delete-row button {
  min-height: 42px;
  border-width: 3px;
  box-shadow: 3px 3px 0 var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 12px;
}

.manage-card input,
.manage-card select {
  min-height: 44px;
  border-width: 3px;
}

.manage-card button {
  min-height: 44px;
  border-width: 3px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 8px 12px;
}

.row-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.usage-meta {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

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

.health-card {
  border: 4px solid var(--line);
  padding: 14px;
  background: var(--white);
}

.health-card.ok { background: #e8fff1; }
.health-card.warn { background: #fff7c7; }
.health-card.bad { background: #ffe3df; }
.health-card p { font-size: 16px; margin: 10px 0 0; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--line);
  background: var(--yellow);
  padding: 5px 8px;
  font-weight: 950;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  font-weight: 950;
  opacity: 0;
  pointer-events: none;
}

#toast.show { opacity: 1; }

@media (max-width: 780px) {
  .ops-top { align-items: stretch; }
  .hero { display: block; }
  .hero button { width: 100%; margin-top: 10px; }
  .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics, .split, .mini-grid, .row-meta, .edit-grid, .logo-tools, .form-grid, .health-grid { grid-template-columns: 1fr; }
  .toolbar, .toolbar.log-toolbar { grid-template-columns: 1fr; }
  .tenant-head, .tenant-actions { align-items: stretch; flex-direction: column; }
  .tenant-actions button { width: 100%; }
  .logo-preview img { height: 84px; }
}
