:root {
  --bg: #f4f1ea;
  --paper: #fffcf7;
  --ink: #1c1915;
  --muted: #6d655b;
  --line: #e4ddd2;
  --accent: #1f4d3a;
  --accent-2: #c45c26;
  --good: #2f6f4e;
  --warn: #b45309;
  --bad: #9f2d2d;
  --sidebar: #17241e;
  --sidebar-text: #e8efe9;
  --shadow: 0 10px 30px rgba(28, 25, 21, 0.06);
  --radius: 14px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex-shrink: 0;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: #d7a35a; color: #17241e;
  display: grid; place-items: center; font-weight: 700; font-size: 20px;
}
.brand-title { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; opacity: 0.7; font-family: ui-sans-serif, system-ui, sans-serif; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  color: var(--sidebar-text); padding: 9px 12px; border-radius: 8px;
  font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,0.1); text-decoration: none; }
.sidebar-foot { margin-top: auto; font-size: 11px; opacity: 0.55; font-family: ui-sans-serif, system-ui, sans-serif; }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 28px 8px; border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 28px; margin: 0; font-weight: 650; letter-spacing: -0.02em; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.content { padding: 12px 28px 40px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card .label { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 12px; color: var(--muted); }
.card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-height: 180px;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 18px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px;
}
.list-item:last-child { border-bottom: 0; }
.muted { color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; }
.empty, .error, .loading {
  padding: 28px 8px; text-align: center; color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.error { color: var(--bad); }
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.filters input, .filters select, .dialog-form input, .dialog-form select, .dialog-form textarea, .inline-form input, .inline-form select, .inline-form textarea {
  border: 1px solid var(--line); background: var(--paper); border-radius: 8px;
  padding: 8px 10px; font: inherit; color: inherit;
}
.filters input[type="search"], .filters input[type="text"] { min-width: 180px; }
.btn {
  background: var(--accent); color: white; border: 0; border-radius: 8px;
  padding: 8px 12px; cursor: pointer; font-family: ui-sans-serif, system-ui, sans-serif;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.warn { background: var(--accent-2); }
.btn.small { padding: 5px 8px; font-size: 12px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.table-wrap { overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); cursor: pointer; white-space: nowrap; }
table.data tr:hover td { background: #faf6ef; }
.star { cursor: pointer; color: #c4b49a; font-size: 16px; background: none; border: 0; }
.star.on { color: #d7a35a; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  background: #eee8dc; color: var(--ink);
}
.badge.good { background: #dceee3; color: var(--good); }
.badge.warn { background: #f8ead3; color: var(--warn); }
.badge.bad { background: #f6dede; color: var(--bad); }
.score { font-variant-numeric: tabular-nums; font-weight: 700; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-family: ui-sans-serif, system-ui, sans-serif; }
.detail-hero { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.detail-hero h2 { margin: 0 0 6px; font-size: 26px; }
.meta { color: var(--muted); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.match-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.match-col { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.match-col h3 { margin: 0 0 8px; font-size: 14px; }
.match-col ul { margin: 0; padding-left: 18px; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-family: ui-sans-serif, system-ui, sans-serif; }
.flash.error { background: #f6dede; color: var(--bad); }
.flash.ok { background: #dceee3; color: var(--good); }
.hidden { display: none !important; }
.task-section { margin-bottom: 18px; }
.task-section h2 { font-size: 18px; margin: 0 0 8px; }
.task-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px;
}
.inline-form, .dialog-form { display: flex; flex-direction: column; gap: 8px; font-family: ui-sans-serif, system-ui, sans-serif; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: min(480px, 92vw); }
.prose { white-space: pre-wrap; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 14px; line-height: 1.5; }
.link-list a { display: inline-block; margin-right: 12px; }
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); z-index: 20; transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-block; }
  .grid-2, .match-box, .kv { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

.logout-form { margin-top: auto; }
.logout-btn { width: 100%; color: var(--sidebar-text) !important; border-color: rgba(255,255,255,0.2) !important; }
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-brand { margin-bottom: 22px; }
.login-brand .brand-title { font-size: 22px; }
.login-form { display: flex; flex-direction: column; gap: 12px; font-family: ui-sans-serif, system-ui, sans-serif; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-form input {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
}
.login-form .btn { margin-top: 6px; }
