:root {
    --bg: #f4f7f6;
    --panel: #ffffff;
    --text: #17211f;
    --muted: #65716e;
    --line: #dce5e2;
    --primary: #1f7a5f;
    --primary-dark: #155d49;
    --accent: #d98c24;
    --danger: #b42318;
    --shadow: 0 10px 26px rgba(23, 33, 31, .08);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}
a { color: var(--primary-dark); text-decoration: none; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 58px;
    padding: 8px 18px;
    background: #24312e;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.16);
}
.brand { color: #fff; font-weight: 700; white-space: nowrap; }
.navlinks {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
}
.navlinks a {
    color: #fff;
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(255,255,255,.12);
    padding: 8px 10px;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 14px;
}
.navlinks a:hover { background: rgba(255,255,255,.16); }
.userbar { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.userbar a { color: #fff; font-weight: 700; }
.main {
    width: min(1500px, 100%);
    margin: 0 auto;
    padding: 22px;
}
.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: linear-gradient(135deg, #ffffff 0%, #edf7f2 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 26px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.hero h1 { margin: 0; font-size: 34px; }
.hero p { color: var(--muted); margin: 8px 0 0; }
.eyebrow { color: var(--accent) !important; font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: 0; }
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.narrow { max-width: 860px; margin-left: auto; margin-right: auto; }
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
h1, h2 { margin: 0 0 12px; }
.section-head h1 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.btn, button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn.primary, button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn.primary:hover, button.primary:hover { background: var(--primary-dark); }
.toolbar {
    display: flex;
    gap: 10px;
    margin: 14px 0;
}
input, select, textarea {
    width: 100%;
    border: 1px solid #cbd8d4;
    border-radius: 6px;
    min-height: 40px;
    padding: 9px 10px;
    font: inherit;
    background: #fff;
}
textarea { min-height: 92px; resize: vertical; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 10px;
    vertical-align: top;
    font-size: 14px;
}
th { background: #eef5f2; color: #33413e; }
.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.actions form { margin: 0; }
.actions button {
    color: var(--danger);
    border: 0;
    background: transparent;
    padding: 0;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.form-grid label span {
    display: block;
    color: #34423f;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 13px;
}
.form-grid label:has(textarea), .permissions, .form-actions { grid-column: 1 / -1; }
.permissions {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 8px;
}
.permissions label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.permissions input { width: auto; min-height: auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}
.stat span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat strong { font-size: 24px; }
.grid.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.flash {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    background: #e6f5ed;
    border: 1px solid #bfe1ce;
}
.flash.error, .login-error {
    background: #fee4e2;
    border: 1px solid #fecdca;
    color: var(--danger);
}
.empty { color: var(--muted); }
.qr-panel { text-align: center; }
.qr-panel img { width: 260px; height: 260px; display: block; margin: 14px auto; }
.status {
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
}
.public-main { padding-top: 26px; }
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        linear-gradient(rgba(20,31,28,.58), rgba(20,31,28,.58)),
        url('https://images.unsplash.com/photo-1486262715619-67b85e0b08d3?auto=format&fit=crop&w=1800&q=80') center/cover;
    padding: 18px;
}
.login-card {
    width: min(420px, 100%);
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 22px 60px rgba(0,0,0,.28);
}
.login-card h1 { text-align: center; margin-bottom: 22px; }
.login-card label { display: block; margin-bottom: 14px; }
.login-card span { display: block; font-weight: 700; margin-bottom: 6px; }
.login-card button {
    width: 100%;
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 700;
}
.login-error { margin-top: 14px; padding: 10px; border-radius: 6px; }
.user-edit-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
@media (max-width: 950px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .userbar { width: 100%; justify-content: space-between; }
    .hero, .grid.two { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: 1fr; }
    .permissions { grid-template-columns: 1fr; }
}
@media print {
    .topbar, .btn { display: none !important; }
    body { background: #fff; }
    .panel { box-shadow: none; border: 0; }
}
