:root {
    color-scheme: light;
    --bg: #f3f5f8;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #172033;
    --muted: #667085;
    --line: #d8dee8;
    --primary: #146c63;
    --primary-dark: #0f4f49;
    --accent: #2f6fed;
    --danger: #b42318;
    --success: #087443;
    --shadow: 0 12px 34px rgba(19, 30, 46, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, #eef2f7 0, #f7f8fa 340px),
        var(--bg);
    color: var(--text);
    font-family: Tahoma, Arial, sans-serif;
}

.topbar {
    min-height: 92px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    padding: 18px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(14px);
}

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

.brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #101828;
    color: #fff;
    font-weight: 800;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
}

.topbar h1 {
    margin: 0;
    font-size: 25px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-actions a {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 13px;
    color: var(--text);
    background: #fff;
    text-decoration: none;
    font-size: 14px;
}

.nav-actions a:hover {
    border-color: #b8c2d2;
    box-shadow: 0 8px 20px rgba(23, 32, 51, 0.08);
}

main {
    width: min(1320px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.toolbar,
.table-wrap,
.summary,
.notice,
.pages,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.toolbar {
    padding: 18px;
}

.search-form {
    display: grid;
    grid-template-columns: 1.5fr 1fr 0.8fr 0.8fr 0.8fr auto auto;
    gap: 12px;
    align-items: end;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--text);
    font: inherit;
    background: #fff;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

button,
.ghost,
.download,
.pages a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 8px;
    padding: 10px 15px;
    text-decoration: none;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

button,
.download {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
}

button:hover,
.download:hover {
    background: var(--primary-dark);
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.ghost,
.pages a {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
}

.summary {
    margin: 16px 0;
    padding: 15px 18px;
    color: var(--muted);
}

.summary strong {
    color: var(--text);
    font-size: 22px;
    margin-inline-end: 4px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid #e8edf3;
    text-align: right;
    vertical-align: middle;
}

th {
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

tbody tr:hover {
    background: #fbfcfe;
}

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

.name {
    font-weight: 800;
    max-width: 300px;
}

.path {
    direction: ltr;
    text-align: left;
    color: var(--muted);
    max-width: 440px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.empty.compact {
    padding: 22px;
}

.notice {
    padding: 14px 16px;
    box-shadow: none;
}

.notice.error {
    color: var(--danger);
    border-color: #f3b3ad;
    background: #fff7f6;
}

.notice.success {
    color: var(--success);
    border-color: #a8dbc2;
    background: #f2fbf6;
}

.pages {
    margin-top: 16px;
    padding: 12px;
    display: flex;
    justify-content: center;
    gap: 12px;
    align-items: center;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    gap: 18px;
}

.panel {
    padding: 18px;
}

.panel-head {
    margin-bottom: 16px;
}

.panel-head h2 {
    margin: 0 0 6px;
    font-size: 19px;
}

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

.admin-form {
    display: grid;
    gap: 13px;
    align-self: start;
}

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

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px;
    background: var(--panel-soft);
    border: 1px solid #e8edf3;
    border-radius: 8px;
}

.user-row strong,
.user-row span {
    display: block;
}

.user-row span {
    margin-top: 5px;
    color: var(--muted);
    direction: ltr;
    text-align: right;
}

.role {
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
    background: #eaf1ff;
    color: #2252b8;
}

.role.admin {
    background: #ecfdf3;
    color: #067647;
}

.role.superadmin {
    background: #fff4e5;
    color: #9a4b00;
}

.login-shell {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
}

.login-panel {
    width: min(420px, 100%);
    display: grid;
    gap: 14px;
}

.sync-panel {
    max-width: 760px;
}

.sync-status {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
    background: var(--panel-soft);
}

.sync-status strong,
.sync-status span {
    display: block;
}

.sync-status span {
    margin-top: 6px;
    color: var(--muted);
}

.sync-status.running {
    border-color: #b8c8ef;
    background: #f3f7ff;
}

.sync-status.success {
    border-color: #a8dbc2;
    background: #f2fbf6;
    color: var(--success);
}

.sync-status.failed {
    border-color: #f3b3ad;
    background: #fff7f6;
    color: var(--danger);
}

.sync-progress {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf3;
    margin-bottom: 16px;
}

.sync-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.4s ease;
}

@media (max-width: 1080px) {
    .search-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    main {
        width: calc(100% - 20px);
    }

    .topbar {
        position: static;
        padding: 16px;
        align-items: flex-start;
        flex-direction: column;
    }

    .nav-actions {
        width: 100%;
    }

    .nav-actions a {
        flex: 1;
    }

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

    button,
    .ghost {
        width: 100%;
    }
}
