:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --text: #172b4d;
  --muted: #6a7c91;
  --line: #dbe5ef;
  --blue: #2fc6f6;
  --blue-dark: #159bd4;
  --green: #1fa67a;
  --red: #d33f49;
  --nav: #233142;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--nav); color: #fff; padding: 20px 16px; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--blue); color: #06344a; font-weight: 800; }
.brand small { display: block; color: #b9c7d8; margin-top: 3px; }
nav a { display: block; padding: 11px 12px; border-radius: 8px; color: #d7e2ef; text-decoration: none; margin-bottom: 4px; }
nav a.active, nav a:hover { background: #31445a; color: #fff; }

.main { padding: 24px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 18px; }
h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
h2 { margin: 0 0 12px; font-size: 18px; }
p { margin: 6px 0 0; }
.muted { color: var(--muted); font-size: 13px; }
.link { display: block; margin-top: 4px; }

.panel, .toolbar, .notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(20, 43, 77, 0.04);
}
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stats { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); }
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 14px; }
.status-grid > div { border: 1px solid var(--line); border-radius: 8px; padding: 13px; background: var(--surface-2); }
.meta-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.two-col { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 420px); gap: 24px; }

.notice.success { border-color: #a9e7d3; background: #ecfff8; }
.notice.error { border-color: #f5b9bf; background: #fff1f2; color: #9f2730; }

.grid-form { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 14px; }
.stack { display: grid; gap: 14px; }
label span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #c9d7e6;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
}
textarea { resize: vertical; }
.wide, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 13px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary, button.primary { background: var(--blue); color: #06344a; font-weight: 700; }
.btn.primary:hover, button.primary:hover { background: var(--blue-dark); color: #fff; }
.btn.ghost { background: #f4f8fc; border-color: #cfe0ef; color: var(--text); }
.btn.danger, button.danger { background: #fff2f3; border-color: #f0b9be; color: var(--red); }

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.actions form { margin: 0; }

.role-switch { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.role-switch label { color: var(--muted); font-size: 13px; }
.role-switch select { min-width: 150px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e8f5fd;
  color: #126b98;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}
.badge.ok { background: #e9fbf5; color: var(--green); }
.badge.danger { background: #fff1f2; color: var(--red); }
.chips { display: grid; gap: 8px; min-width: 250px; }
.inline-reveal { display: grid; grid-template-columns: minmax(120px, 1fr) auto; gap: 8px; }
.chip { background: #eef9fe; color: #126b98; border-color: #c5eefd; padding: 8px 10px; font-weight: 700; }
.chip:disabled { opacity: 0.55; cursor: not-allowed; }
.reveal-box { border-color: #ffd1d6; background: #fff8f9; }
.reveal-box code { display: block; margin-top: 10px; padding: 12px; background: #172b4d; color: #fff; border-radius: 8px; overflow-x: auto; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .topbar, .toolbar { flex-direction: column; align-items: stretch; }
  .grid-form, .two-col, .status-grid { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
}
