:root {
    color-scheme: light;
    --bg: oklch(97% 0.008 250);
    --panel: oklch(99% 0.006 250);
    --panel-2: oklch(94% 0.01 250);
    --text: oklch(22% 0.018 250);
    --muted: oklch(48% 0.018 250);
    --line: oklch(86% 0.012 250);
    --accent: oklch(49% 0.13 245);
    --accent-hover: oklch(43% 0.14 245);
    --danger: oklch(52% 0.18 25);
    --focus: oklch(70% 0.13 245);
}

* {
    box-sizing: border-box;
}

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

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

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

.topbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    height: 56px;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    color: var(--text);
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 16px;
}

.shell {
    margin: 0 auto;
    max-width: 1440px;
    padding: 28px 24px 48px;
}

.page-heading {
    align-items: flex-end;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 20px;
}

h1 {
    font-size: 24px;
    line-height: 1.2;
    margin: 0 0 6px;
}

h2 {
    font-size: 13px;
    margin: 0 0 10px;
}

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

button,
.button {
    align-items: center;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: oklch(98% 0.006 250);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 650;
    min-height: 36px;
    padding: 0 14px;
}

button:hover,
.button:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: oklch(98% 0.006 250);
}

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

button.secondary:hover,
.button.secondary:hover {
    background: var(--panel-2);
    border-color: oklch(78% 0.016 250);
}

input {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 38px;
    padding: 0 11px;
}

input:focus,
button:focus,
.button:focus {
    outline: 3px solid var(--focus);
    outline-offset: 1px;
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 72px auto;
    max-width: 380px;
    padding: 28px;
}

.form-stack {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.form-stack label {
    display: grid;
    gap: 7px;
}

.form-stack span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.notice.error {
    color: var(--danger);
    margin-top: 12px;
}

.search-form {
    display: flex;
    gap: 10px;
}

.search-form input {
    min-width: 320px;
}

.activity-tree {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.tree-division,
.tree-group {
    border-bottom: 1px solid var(--line);
}

.tree-division:last-child {
    border-bottom: 0;
}

.tree-division summary,
.tree-group summary {
    align-items: center;
    cursor: pointer;
    display: grid;
    gap: 16px;
    grid-template-columns: 100px minmax(0, 1fr) 160px;
    min-height: 42px;
    padding: 0 16px;
}

.tree-division > summary {
    background: var(--panel-2);
    font-weight: 700;
}

.tree-group > summary {
    background: oklch(96% 0.009 250);
    padding-left: 34px;
}

.activity-row {
    align-items: center;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    display: grid;
    gap: 16px;
    grid-template-columns: 100px minmax(0, 1fr) 160px;
    min-height: 48px;
    padding: 0 16px 0 52px;
}

.activity-row:last-child {
    border-bottom: 0;
}

.activity-row:hover {
    background: var(--panel-2);
    color: var(--text);
}

.activity-code {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.activity-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-count {
    color: var(--muted);
    text-align: right;
}

.metric-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    position: relative;
}

.metric-count {
    color: var(--muted);
    font-size: 12px;
}

.metric-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    left: 0;
    padding: 0;
    position: absolute;
    right: 0;
    top: 46px;
    z-index: 10;
}

.metric-panel[hidden] {
    display: none;
}

.metric-panel-header {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 46px;
    padding: 0 18px;
}

.icon-button {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    font-size: 22px;
    justify-content: center;
    min-height: 32px;
    padding: 0;
    width: 32px;
}

.icon-button:hover {
    background: var(--panel-2);
    border-color: var(--line);
    color: var(--text);
}

.metric-panel-body {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    padding: 18px;
}

.metric-panel-footer {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    padding: 12px 18px;
}

.metric-group {
    max-height: 280px;
    overflow: auto;
}

.checkbox-line {
    align-items: center;
    display: flex;
    gap: 8px;
    min-height: 28px;
}

.checkbox-line input {
    min-height: auto;
}

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

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

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

th {
    background: var(--panel-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 1;
}

.sort-link {
    color: var(--muted);
    display: inline-flex;
    min-height: 24px;
}

.sort-link:hover,
.sort-link.active {
    color: var(--text);
}

tbody tr:hover {
    background: oklch(96% 0.012 250);
}

.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pager {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: flex-end;
    margin-top: 16px;
}

[aria-disabled="true"] {
    opacity: 0.45;
    pointer-events: none;
}

.empty-state,
.error-page {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}

@media (max-width: 760px) {
    .topbar {
        padding: 0 16px;
    }

    .shell {
        padding: 20px 14px 36px;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .search-form,
    .metric-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .search-form input {
        min-width: 0;
        width: 100%;
    }

    .activity-row {
        grid-template-columns: 72px minmax(0, 1fr);
        padding: 10px 12px;
    }

    .tree-division summary,
    .tree-group summary {
        grid-template-columns: 72px minmax(0, 1fr);
        padding: 10px 12px;
    }

    .activity-count {
        grid-column: 2;
        text-align: left;
    }

    .metric-panel {
        position: static;
        width: 100%;
    }

    .metric-panel-body {
        grid-template-columns: 1fr;
    }
}
