/* --- Design tokens --- */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --border: #e3e6ea;
  --border-strong: #cdd2d8;
  --text: #1f2933;
  --text-muted: #6b7480;
  --text-soft: #98a0aa;
  --accent: #2f6fad;
  --accent-hover: #265c91;
  --accent-soft: #eaf1f8;
  --danger: #b3261e;
  --danger-soft: #fbecea;
  --success: #2f7d4a;
  --success-soft: #eaf4ee;
  --radius: 4px;
  --radius-lg: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 35, .05), 0 1px 1px rgba(15, 23, 35, .04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}
.nav-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  gap: 16px;
}
.nav-left { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand {
  font-weight: 600;
  color: var(--text);
  letter-spacing: .3px;
}
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 14px; }
.nav-links a {
  color: var(--text-muted);
  font-size: 13px;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
}
.nav-right .who {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.nav-right .who strong { color: var(--text); font-weight: 600; }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* --- Typography --- */
h1, h2, h3 { color: var(--text); font-weight: 600; margin: 0 0 10px; }
h1 { font-size: 18px; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-top: 0; }
h3 { font-size: 14px; }

p { margin: 6px 0; }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.small { font-size: 12px; }
code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
}
.code-big { font-size: 15px; padding: 3px 8px; letter-spacing: 1px; }

/* --- Card / section --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.card-title h2 { margin: 0; }

/* --- Forms --- */
label { font-size: 13px; color: var(--text); }
input[type=text], input[type=password], input[type=email], input:not([type]), textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 80px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 10px;
  align-items: end;
}
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 12px; color: var(--text-muted); }

.actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.radio-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0 8px; }
.radio-row label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text);
}
.radio-row input { width: auto; }

/* --- Buttons --- */
button, .btn {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover, .btn:hover { background: var(--surface-alt); border-color: var(--text-soft); }
button:active { background: #eef0f3; }

.btn-primary, button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover, button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-danger, button.danger {
  color: var(--danger);
  border-color: #e6c2bf;
  background: var(--surface);
}
.btn-danger:hover, button.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-sm, button.sm { padding: 4px 8px; font-size: 12px; }
.btn-link {
  background: none; border: none; color: var(--accent); padding: 0; cursor: pointer;
}
.btn-link:hover { background: none; text-decoration: underline; }

/* --- Messages --- */
.msg {
  border: 1px solid;
  border-radius: var(--radius);
  padding: 7px 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.msg.err { background: var(--danger-soft); border-color: #ecc3bf; color: var(--danger); }
.msg.ok  { background: var(--success-soft); border-color: #c5dfcd; color: var(--success); }
.msg.info { background: var(--accent-soft); border-color: #cfdeed; color: var(--accent-hover); }
.err { color: var(--danger); }
.ok { color: var(--success); }

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }
td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }

/* --- Badges --- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge.gray { background: #eef0f3; color: var(--text-muted); border-color: var(--border); }
.badge.red  { background: var(--danger-soft); color: var(--danger); border-color: #ecc3bf; }
.badge.green{ background: var(--success-soft); color: var(--success); border-color: #c5dfcd; }
.badge.blue { background: var(--accent-soft); color: var(--accent-hover); border-color: #cfdeed; }

form.inline { display: inline; margin: 0; }

/* --- Login screen --- */
.auth-shell {
  min-height: calc(100vh - 0px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 22px 20px;
}
.auth-card h1 {
  text-align: center;
  margin-bottom: 14px;
  font-size: 18px;
}
.auth-card .field { margin-bottom: 8px; }
.auth-card button { width: 100%; margin-top: 6px; }

/* --- Utility --- */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.stack > * + * { margin-top: 8px; }
.row-between {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}
details[open] summary { color: var(--text); }
