:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e0e3e8;
    --text: #1f2430;
    --text-muted: #6b7280;
    --primary: #2f5f8a;
    --primary-dark: #234a6d;
    --accent: #b45309;
    --yes: #1f7a3d;
    --no: #b1231c;
    --radius: 6px;
}

* { box-sizing: border-box; }

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

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

.topbar {
    background: var(--primary-dark);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 20px;
    flex-wrap: wrap;
}
.brand {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.02em;
}
.brand:hover { text-decoration: none; opacity: 0.9; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a {
    color: #dbe6f0;
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 13px;
}
.mainnav a:hover { background: rgba(255,255,255,0.12); text-decoration: none; }
.mainnav a.active { background: rgba(255,255,255,0.2); color: #fff; font-weight: 600; }

.searchbox { margin-left: auto; display: flex; gap: 6px; }
.searchbox input {
    padding: 6px 10px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    min-width: 200px;
}
.searchbox button {
    padding: 6px 12px;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}
.searchbox button:hover { background: #94420a; }

.content {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 10px; color: var(--primary-dark); }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--primary-dark); display: block; }
.stat-card .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card a { display: block; }
.stat-card a:hover { text-decoration: none; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
table.list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th {
    background: #eef1f5;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap table.list { border: none; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--text-muted); gap: 4px; }
.filters input, .filters select {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    min-width: 140px;
}
.filters button {
    padding: 7px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
}
.filters button:hover { background: var(--primary-dark); }
.filters .clear { color: var(--text-muted); font-size: 12px; align-self: center; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-yes { background: #e4f4e9; color: var(--yes); }
.badge-no { background: #fbeaea; color: var(--no); }
.badge-status { background: #eef1f5; color: var(--text); }
.badge-open { background: #fff4e5; color: var(--accent); }
.badge-closed { background: #eef1f5; color: var(--text-muted); }

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.pagination a {
    margin-left: 10px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.pagination a:hover { text-decoration: none; background: #eef1f5; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 4px 24px;
    margin-bottom: 4px;
}
.detail-grid .field { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.detail-grid .field .k { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; display: block; }
.detail-grid .field .v { font-size: 14px; }

.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumb a { color: var(--text-muted); }

.empty-state { padding: 24px; text-align: center; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.summary-block { white-space: pre-wrap; word-break: break-word; }

.footer { text-align: center; color: var(--text-muted); font-size: 12px; padding: 20px; }

.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }

.userbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #dbe6f0;
}
.userbox-name { font-weight: 600; color: #fff; }
.userbox a { color: #dbe6f0; }
.userbox a:hover { color: #fff; }

.auth-body {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.auth-wrap { width: 100%; padding: 20px; }
.auth-card {
    max-width: 380px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.06);
}
.auth-card h1 { font-size: 19px; margin-bottom: 18px; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-muted); }
.auth-form input {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}
.auth-form button {
    padding: 10px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}
.auth-form button:hover { background: var(--primary-dark); }
.auth-hint { font-size: 12px; color: var(--text-muted); margin-top: 14px; text-align: center; }

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: #fbeaea; color: var(--no); border: 1px solid #f3c9c7; }
.alert-warning { background: #fff4e5; color: var(--accent); border: 1px solid #f3dcb8; }
.alert-success { background: #e4f4e9; color: var(--yes); border: 1px solid #c3e6cf; }

.btn-danger-link {
    background: none;
    border: none;
    color: var(--no);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    text-decoration: underline;
}
.btn-danger-link:hover { color: #7d1712; }

@media (max-width: 640px) {
    .topbar-inner { flex-direction: column; align-items: stretch; }
    .searchbox { margin-left: 0; }
    .searchbox input { flex: 1; min-width: 0; }
    .userbox { justify-content: center; }
}
