:root {
    --bg: #0f1115;
    --surface: #171a21;
    --border: #2a2e38;
    --text: #e4e6eb;
    --muted: #8a8f9c;
    --accent: #4f8cff;
    --danger: #e5484d;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

.wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

#site-header {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 0;
}

.header-contents {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-contents .brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text);
}

main {
    padding: 2.5rem 0 4rem;
}

h1 {
    font-size: 1.8rem;
    margin: 0 0 0.25rem;
}

h2 {
    font-size: 1.2rem;
    margin: 2.5rem 0 1rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--muted);
}

.domain {
    color: var(--muted);
    margin: 0 0 1.5rem;
}

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

th, td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Long paths/domains scroll inside the table instead of widening the page.
   Cells stay on one line, and the last (count) column is pinned to the
   right edge so the number stays visible while scrolling. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-scroll th,
.table-scroll td {
    white-space: nowrap;
}

.table-scroll th:last-child,
.table-scroll td:last-child {
    position: sticky;
    right: 0;
    background: var(--bg);
    padding-left: 1rem;
    text-align: right;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

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

.add-site-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.add-site-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
    flex: 1;
    min-width: 200px;
}

input[type="text"],
input[type="password"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    color: var(--text);
    font-size: 0.95rem;
}

button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.1rem;
    font-size: 0.95rem;
    cursor: pointer;
}

button.danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.range-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.range-tabs a {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.9rem;
}

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

.range-tabs a:hover {
    text-decoration: none;
}

.range-label {
    color: var(--muted);
    margin-bottom: 0.35rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.range-label .back-link {
    color: var(--accent);
}

.chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 180px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    overflow-x: auto;
}

.chart-bar-wrap {
    flex: 1;
    min-width: 6px;
    height: 100%;
    display: flex;
    align-items: flex-end;
    position: relative;
}

.chart-bar-link {
    display: flex;
    align-items: flex-end;
    width: 100%;
    height: 100%;
}

.chart-bar {
    width: 100%;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    min-height: 1px;
}

.chart-bar-wrap:has(a) {
    cursor: pointer;
}

.chart-bar-wrap:has(a):hover .chart-bar {
    filter: brightness(1.3);
}

.chart-labels {
    position: relative;
    height: 1rem;
    margin: 0.4rem 0 1.5rem;
}

.chart-label-tick {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--muted);
    white-space: nowrap;
}

.world-map {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.world-map svg {
    display: block;
    width: 100%;
    height: auto;
}

.world-map path {
    transition: fill 0.15s ease;
}

.snippet {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.85rem;
}

.delete-form {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.block {
    text-align: center;
    padding: 4rem 0;
}

button.link-button {
    background: transparent;
    color: var(--muted);
    padding: 0;
    font-size: 0.9rem;
}

button.link-button:hover {
    color: var(--text);
}

.login-form {
    max-width: 360px;
    margin: 2rem auto 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.login-form h1 {
    font-size: 1.4rem;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

/* 16px keeps iOS Safari from zooming in when a field is focused. */
.login-form input {
    font-size: 1rem;
}

.form-error {
    color: var(--danger);
    margin: 0;
    font-size: 0.9rem;
}

.danger-link {
    color: var(--danger);
}

.delete-confirm {
    max-width: 480px;
}

.delete-confirm p {
    color: var(--muted);
}

.delete-confirm strong {
    color: var(--text);
}

.delete-confirm label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
    margin: 1.5rem 0 1rem;
}

.delete-confirm input {
    font-size: 1rem;
}

.delete-confirm .actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

button.danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 2rem;
    margin: 0.5rem 0 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.stat-change {
    color: var(--muted);
    font-size: 0.8rem;
}

.stat-change.up {
    color: #3fb950;
}

.stat-change.down {
    color: var(--danger);
}

.export-link {
    margin-left: auto;
    font-size: 0.9rem;
}

h3 {
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin: 0 0 0.25rem;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.breakdown-grid > div {
    min-width: 0;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 560px;
}

.settings-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.settings-form label.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.settings-form textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}

.hint {
    color: var(--muted);
    font-size: 0.8rem;
}

.form-success {
    color: #3fb950;
    margin: 0;
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .add-site-form {
        flex-direction: column;
        align-items: stretch;
    }
}
