:root {
  --ink: #1c2230;
  --ink-soft: #4a5266;
  --paper: #f4f5f7;
  --panel: #ffffff;
  --line: #dcdfe6;
  --navy: #1f2f4d;
  --navy-dark: #16233b;
  --brass: #9c7a3c;
  --brass-soft: #f2ead9;
  --red: #8a3b3b;
  --red-soft: #f6e9e9;
  --green: #2f5d46;
  --green-soft: #e8f0ec;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  color: var(--navy);
  font-weight: 600;
  margin: 0 0 4px;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; margin-top: 0; }

a { color: var(--navy); }
a:hover { color: var(--brass); }

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
}

.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; }
.brand:hover { color: var(--brass-soft); }
.brand-mark {
  font-family: Georgia, serif;
  font-size: 1.4rem;
  background: var(--brass);
  color: var(--navy-dark);
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.brand-text { font-weight: 600; letter-spacing: 0.02em; font-size: 1.05rem; }

.topnav { display: flex; align-items: center; gap: 20px; font-size: 0.92rem; }
.topnav a { color: #cfd6e6; text-decoration: none; }
.topnav a:hover { color: #fff; }
.topnav-user { color: #8f9ac0; }
.logout-link { border-left: 1px solid #33456b; padding-left: 20px; }

.content { flex: 1; max-width: 980px; width: 100%; margin: 0 auto; padding: 32px 24px 64px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-intro { color: var(--ink-soft); max-width: 70ch; }

.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 0.92rem; margin-bottom: 16px; }
.alert-ok { background: var(--green-soft); color: var(--green); border: 1px solid #c8dccf; }
.alert-error { background: var(--red-soft); color: var(--red); border: 1px solid #e0c6c6; }

.stat-row { display: flex; gap: 12px; margin: 20px 0; flex-wrap: wrap; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 120px;
  border-top: 3px solid var(--brass);
}
.stat-card-muted { border-top-color: var(--line); }
.stat-num { display: block; font-size: 1.5rem; font-weight: 700; color: var(--navy); font-family: Georgia, serif; }
.stat-label { font-size: 0.8rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }

.filter-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { padding: 8px 14px; text-decoration: none; color: var(--ink-soft); font-size: 0.9rem; border-bottom: 2px solid transparent; }
.tab-active { color: var(--navy); border-bottom-color: var(--brass); font-weight: 600; }

.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.item-main { flex: 1; min-width: 240px; }
.item-type {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brass);
  font-weight: 700;
  margin-bottom: 4px;
}
.item-title { display: block; font-weight: 600; color: var(--ink); text-decoration: none; margin-bottom: 4px; }
.item-title:hover { color: var(--navy); text-decoration: underline; }
.item-meta { font-size: 0.82rem; color: var(--ink-soft); display: flex; gap: 14px; flex-wrap: wrap; }
.item-matches { color: var(--brass); }
.item-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state { color: var(--ink-soft); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center; }

.bill-summary { font-size: 0.86rem; color: var(--ink-soft); background: var(--paper); border-left: 3px solid var(--brass); padding: 8px 12px; margin: 8px 0; border-radius: 0 4px 4px 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.data-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.data-table th { background: #eef0f4; color: var(--ink-soft); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table tr:last-child td { border-bottom: none; }
.url-cell a { word-break: break-all; font-size: 0.85rem; }
.table-actions { display: flex; gap: 8px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 0.75rem; background: #eceff3; color: var(--ink-soft); }
.pill-active { background: var(--green-soft); color: var(--green); }

label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); margin: 12px 0 4px; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: #fff;
}
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); margin-top: 14px; }
.checkbox-label input { width: auto; }

.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-small { padding: 6px 12px; font-size: 0.82rem; background: #eceff3; color: var(--ink); }
.btn-small:hover { background: #dfe3ea; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: #eceff3; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #eeddda; }

.inline-form { display: flex; gap: 10px; margin: 16px 0 20px; flex-wrap: wrap; }
.inline-form input[type="text"] { width: auto; flex: 1; min-width: 220px; }
.inline-form-wide input[type="text"] { flex: 1; min-width: 180px; }
.inline-form-tight { margin: 14px 0 0; }
.inline-form-tight input[type="text"] { min-width: 160px; }

.group-list { display: flex; flex-direction: column; gap: 12px; }
.group-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brass);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.group-card-inactive { border-left-color: var(--line); opacity: 0.7; }
.group-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.group-card-head h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }

.group-empty { color: var(--ink-soft); font-size: 0.88rem; margin: 6px 0; }

.term-pills { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.term-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--brass-soft);
  color: var(--navy);
  border-radius: 99px;
  padding: 4px 6px 4px 12px;
  font-size: 0.85rem;
}
.term-pill-inactive { background: #eceff3; color: var(--ink-soft); text-decoration: line-through; }
.term-pill-actions { display: inline; }
.term-pill-actions button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 99px;
}
.term-pill-actions button:hover { background: rgba(0,0,0,0.08); }

.auth-wrap { display: flex; justify-content: center; padding-top: 40px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 30px; width: 340px; }
.auth-card button { width: 100%; margin-top: 18px; }

.code-block { background: #eef0f4; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.85rem; overflow-x: auto; word-break: break-all; white-space: pre-wrap; }

code { background: #eef0f4; padding: 1px 5px; border-radius: 3px; font-size: 0.88em; }

@media (max-width: 640px) {
  .topnav { display: none; }
  .content { padding: 20px 14px 48px; }
}
