* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f4f1;
    --panel: #ffffff;
    --ink: #1c2118;
    --muted: #6b7364;
    --line: #e4e7de;
    --brand: #2f6b3a;
    --brand-2: #1e4d28;
    --ok: #1f7a3a;
    --err: #b42318;
    --temp: #b54708;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

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

.layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #142018;
    color: #e8efe6;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #3d8a4c;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.brand small {
    display: block;
    color: #9aab96;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar nav a {
    color: #d5e0d2;
    padding: 10px 12px;
    border-radius: 8px;
}

.sidebar nav a.is-active,
.sidebar nav a:hover {
    background: #1e3324;
    color: #fff;
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    color: #9aab96;
}

.sidebar-foot a {
    color: #c9e0c4;
}

.content {
    padding: 32px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.page-head > div:last-child {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

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

.filters,
.sync-form {
    display: flex;
    gap: 12px;
    align-items: end;
    background: var(--panel);
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 16px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}

label.grow {
    flex: 1;
}

input, select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}

.btn {
    border: 0;
    background: #e8ece3;
    color: var(--ink);
    padding: 11px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-2);
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 8px 0 16px;
}

.chip {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
    color: var(--ink);
    font-size: 13px;
}

.chip.is-on {
    background: #e7f4ea;
    border-color: #b7d9be;
}

.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: auto;
}

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

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

th {
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    background: #fafbf8;
}

.mini {
    display: block;
    font-size: 12px;
    margin-top: 4px;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px !important;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-open { background: #e7f6ec; color: var(--ok); }
.badge-closed { background: #fdecea; color: var(--err); }
.badge-temp { background: #fff4e5; color: var(--temp); }
.badge-unknown { background: #eef0ea; color: var(--muted); }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.alert-error { background: #fdecea; color: var(--err); }
.alert-ok { background: #e7f6ec; color: var(--ok); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
}

.notes {
    color: var(--muted);
    line-height: 1.6;
}

.sync-progress {
    margin: 8px 0 18px;
}

.progress-bar {
    height: 10px;
    background: #e8ece3;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--brand);
}

.sync-log {
    max-height: 220px;
    overflow: auto;
    padding-left: 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.pager {
    display: flex;
    gap: 6px;
    margin-top: 16px;
}

.pager a {
    padding: 6px 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
}

.pager a.is-on {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 28px;
}

.login-card form {
    display: grid;
    gap: 12px;
}

.hint {
    margin-top: 16px;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .sidebar nav {
        flex-direction: row;
    }
    .sidebar-foot {
        width: 100%;
        margin-top: 0;
    }
    .filters, .sync-form {
        flex-direction: column;
        align-items: stretch;
    }
}
