:root {
    color-scheme: light;
    --bg: #f7f7f4;
    --panel: #ffffff;
    --panel-soft: #f1f4f1;
    --text: #202422;
    --muted: #66706b;
    --line: #d9dfd9;
    --accent: #245b47;
    --accent-strong: #163c2e;
    --danger: #9e2f2f;
    --warn: #8a6400;
    --shadow: 0 16px 45px rgba(32, 36, 34, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

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

a:hover {
    color: var(--accent-strong);
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 3;
}

.topbar-inner {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand strong {
    font-size: 19px;
    font-weight: 760;
}

.brand span {
    color: var(--muted);
    font-size: 13px;
}

.tabs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tabs a {
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    padding: 8px 11px;
    font-weight: 650;
}

.tabs a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.logout-form {
    display: inline-flex;
    margin-left: 6px;
}

main {
    width: min(1180px, calc(100vw - 32px));
    margin: 28px auto 56px;
}

.login-main {
    align-items: center;
    display: flex;
    min-height: 100vh;
    width: min(440px, calc(100vw - 32px));
}

.login-panel {
    width: 100%;
}

.notice {
    background: #eef6f0;
    border: 1px solid #c8decf;
    border-radius: 8px;
    color: #17402d;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.notice.error {
    background: #fff2f2;
    border-color: #ecc7c7;
    color: #7e2020;
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 20px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel header {
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
}

.panel h1,
.panel h2 {
    font-size: 18px;
    line-height: 1.25;
    margin: 0;
}

.panel p {
    color: var(--muted);
    margin: 5px 0 0;
}

.section-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.panel-body {
    padding: 20px;
}

.table-scroll {
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    width: 100%;
}

.user-setup-table {
    min-width: 560px;
}

.user-setup-table input,
.user-setup-table select {
    min-width: 150px;
}

.user-edit-list {
    display: grid;
    gap: 14px;
}

.user-edit-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.user-edit-card form {
    gap: 10px;
}

.user-danger-zone {
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    align-items: center;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
}

.pill.on {
    background: #e9f5ed;
    border-color: #bfdbc9;
    color: #245b47;
}

.pill.off {
    background: #f8eded;
    border-color: #e4c2c2;
    color: #8c2e2e;
}

form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

label span {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    font: inherit;
    min-height: 40px;
    padding: 9px 10px;
    width: 100%;
}

textarea {
    min-height: 104px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkline {
    align-items: center;
    display: flex;
    gap: 9px;
    font-weight: 700;
}

.checkline input {
    min-height: 0;
    width: auto;
}

button,
.button {
    align-items: center;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 7px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 760;
    min-height: 38px;
    padding: 8px 12px;
    text-decoration: none;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

button.secondary,
.button.secondary {
    background: #fff;
    border-color: var(--line);
    color: var(--text);
}

button.warn {
    background: #fff8e3;
    border-color: #e6d59f;
    color: var(--warn);
}

button.danger {
    background: #fff2f2;
    border-color: #e4c2c2;
    color: var(--danger);
}

.inline {
    display: inline;
}

.inline button {
    min-height: 34px;
    padding: 6px 9px;
}

.muted {
    color: var(--muted);
}

.empty {
    color: var(--muted);
    padding: 18px 0;
}

@media (max-width: 860px) {
    .topbar-inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 0;
    }

    .tabs {
        overflow-x: auto;
        width: 100%;
    }

    .grid,
    .form-row {
        grid-template-columns: 1fr;
    }
}
