:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #6b7785;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --sidebar: #18202b;
  --sidebar-ink: #d9e2ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 10px 14px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

a {
  color: var(--accent-dark);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f7b267;
  color: #111827;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.context-form label,
.topbar p,
small,
.item span {
  color: var(--muted);
}

.context-form {
  margin-bottom: 18px;
}

.context-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.context-form select {
  background: #111827;
  border-color: #303a48;
  color: var(--sidebar-ink);
}

nav {
  display: grid;
  gap: 6px;
}

nav a {
  border-radius: 6px;
  color: var(--sidebar-ink);
  padding: 12px;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  background: #253142;
  color: #fff;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.sidebar-footer button {
  width: 100%;
  background: #303a48;
}

.main {
  margin-left: 280px;
  padding: 28px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 30px;
}

.topbar p {
  margin: 4px 0 0;
}

.user-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 8px 14px;
}

.panel,
.metric-grid article,
.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 19px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 18px;
  align-items: start;
}

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

.metric-grid article {
  padding: 18px;
}

.metric-grid strong {
  display: block;
  font-size: 34px;
}

.metric-grid span {
  color: var(--muted);
}

.item {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.item:first-of-type {
  border-top: 0;
}

.item p {
  line-height: 1.55;
}

.muted {
  opacity: 0.58;
}

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

.stack label {
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.court-canvas,
.saved-frame canvas {
  width: 100%;
  border: 1px solid #c4a484;
  border-radius: 6px;
  background: #f3c17a;
  aspect-ratio: 76 / 42;
  touch-action: none;
}

.saved-frame {
  margin-top: 10px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
}

.toolbar button {
  background: #374151;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #18202b, #243447);
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
}

.login-card h1,
.login-card p {
  margin: 0;
}

.alert {
  border-radius: 6px;
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 12px;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
    padding: 18px;
  }

  .split,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .inline-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar {
    display: grid;
  }
}
