:root {
    color-scheme: light;
    --ink: #152525;
    --muted: #536864;
    --line: #d4dfdc;
    --accent: #145948;
    font-family: system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #f2f6f4; }
main { width: min(1160px, calc(100% - 32px)); margin: 48px auto; }
.login { max-width: 400px; margin-top: 14vh; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
h1, h2 { margin: 0; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: 1.2rem; margin-bottom: 22px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.login .panel, .edit-panel { padding: clamp(16px, 4vw, 28px); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: .9rem; }
th { background: #e9f2ee; }
tr:last-child td { border-bottom: 0; }
.selected td { background: #f2f8f5; }
.count { font-weight: 700; font-variant-numeric: tabular-nums; }
.url { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.pixel-ids { min-width: 120px; max-width: 260px; white-space: normal; overflow-wrap: anywhere; }
.settings, .fields { display: grid; gap: 16px; }
.fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); align-items: start; }
label { display: grid; gap: 6px; min-width: 0; }
input:not([type=checkbox]), select, textarea, button {
    min-height: 42px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font: inherit;
}
input:not([type=checkbox]), select, textarea { width: 100%; color: var(--ink); background: #fff; }
textarea { resize: vertical; }
button { width: fit-content; color: white; background: var(--accent); border-color: var(--accent); cursor: pointer; }
button.secondary { color: var(--accent); background: #fff; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset { min-width: 0; padding: 16px; margin: 0; border: 1px solid var(--line); border-radius: 8px; }
legend { padding: 0 6px; font-weight: 650; }
.check, .actions { display: flex; align-items: center; gap: 10px; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: .9rem; }
.settings > .hint { margin: -4px 0 0; }
.notice { padding: 12px 14px; border-radius: 7px; }
ul.notice { padding-left: 32px; }
.error { background: #fff0ee; color: #8b2924; }
.success { background: #e5f6eb; color: #185a37; }

.visit-count { display: inline-block; min-width: 28px; color: #065c50; }
.visit-scope { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 0 0 12px; }
.visit-scope > a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    text-decoration: none;
    font-size: .9rem;
}
.visit-scope > a:hover { background: #e9f2ee; }
.visit-scope > a[aria-current] { border-color: var(--accent); color: #fff; background: var(--accent); }
.visit-scope small { color: var(--muted); }
.visit-count:focus-visible, .visit-action:focus-visible { outline: 2px solid #087c6c; outline-offset: 3px; }
.visit-dialog {
    width: min(1160px, calc(100% - 30px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 1px solid #cbdad5;
    border-radius: 16px;
    color: #20332c;
    background: #f4f8f6;
    box-shadow: 0 24px 70px rgba(12, 45, 34, .24);
    overflow: auto;
}
.visit-dialog::backdrop { background: rgba(17, 33, 27, .57); }
.visit-body { padding: clamp(13px, 3vw, 26px); }
.visit-header, .visit-records-header, .visit-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
}
.visit-header { margin-bottom: 16px; }
.visit-header h2, .visit-records-header h3 { margin: 0; }
.visit-domain { margin: .2rem 0 0; color: #526860; overflow-wrap: anywhere; }
.visit-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr));
    gap: 9px;
    margin: 0 0 16px;
}
.visit-stat-grid div {
    padding: 12px;
    border: 1px solid #d8e5e0;
    border-radius: 12px;
    background: #fff;
}
.visit-stat-grid dt { color: #4e655d; font-size: .84rem; }
.visit-stat-grid dd { margin: 3px 0 0; font-size: clamp(1.3rem, 4vw, 1.65rem); font-weight: 750; color: #075e4c; }
.visit-records { border: 1px solid #d8e5e0; border-radius: 12px; background: #fff; }
.visit-records-header, .visit-pagination { padding: 12px; }
.visit-records-header h3 { font-size: 1rem; }
.visit-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.visit-action {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 4px 10px;
    border: 1px solid #cdded7;
    border-radius: 8px;
    color: #125d4c;
    background: #fff;
    text-decoration: none;
    cursor: pointer;
    font-size: .85rem;
}
.visit-action:hover { background: #edf8f4; }
.visit-action.danger { border-color: #e6c5c5; color: #a92533; }
.visit-action.danger:hover { background: #fff2f3; }
.visit-clear { position: relative; }
.visit-clear summary { list-style: none; }
.visit-clear summary::-webkit-details-marker { display: none; }
.visit-clear-form {
    position: absolute;
    z-index: 2;
    right: 0;
    top: calc(100% + 6px);
    width: min(270px, calc(100vw - 62px));
    padding: 14px;
    border-radius: 10px;
    border: 1px solid #e7c7c7;
    background: #fff;
    box-shadow: 0 7px 28px rgba(57, 28, 31, .16);
    overflow-wrap: anywhere;
}
.visit-clear-form p { margin: 0 0 10px; font-size: .88rem; }
.visit-delete { background: #a92533; border-color: #a92533; }
.visit-table th { background: #edf5f2; }
.visit-table th, .visit-table td { padding: 9px 11px; font-size: .84rem; }
.visit-table tr:nth-child(even) td { background: #f9fbfa; }
.visit-empty { text-align: center; color: #5b6e67; }
.visit-pagination { font-size: .85rem; color: #536b61; }
.visit-badge { display: inline-block; border-radius: 99px; padding: 3px 8px; font-size: .8rem; font-weight: 650; }
.visit-new { background: #def4e9; color: #16543c; }
.visit-repeat { background: #fff0d9; color: #70421b; }
@media (max-width: 520px) {
    .visit-records-header .visit-actions { margin-left: auto; justify-content: flex-end; }
    .visit-clear-form { width: min(270px, calc(100vw - 80px)); }
}
