/* cntr.ppj.lt - site styles. System fonts only (no requests to font services). */

:root {
    --brand: #0b5ca2;
    --brand-strong: #084a83;
    --brand-soft: #e8f1fa;
    --brand-light: #aecfe6;
    --accent: #e8710a;
    --text: #17202a;
    --muted: #5b6776;
    --border: #dde3ea;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --danger: #c62828;
    --danger-soft: #fdecec;
    --success: #1b7f3b;
    --radius: 12px;
    --radius-small: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.06);
    --shadow-large: 0 20px 50px rgba(16, 24, 40, 0.25);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --brand: #5aa6e8;
        --brand-strong: #86bff0;
        --brand-soft: #16283a;
        --brand-light: #2c5b85;
        --accent: #f59a48;
        --text: #e6ebf1;
        --muted: #9aa7b6;
        --border: #2a3441;
        --bg: #0f141a;
        --surface: #171e26;
        --surface-alt: #1c2530;
        --danger: #ef6b6b;
        --danger-soft: #3a1c1f;
        --success: #57c47a;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-large: 0 20px 50px rgba(0, 0, 0, 0.6);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }
:focus-visible { outline: 3px solid var(--brand-light); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }

.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Header ------------------------------------------------------------------ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    flex-wrap: wrap;
    padding-block: 8px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    margin-right: auto;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand img { width: 32px; height: 32px; }
.brand span span { color: var(--muted); font-weight: 600; }

.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a {
    padding: 8px 12px;
    border-radius: var(--radius-small);
    color: var(--muted);
    font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--surface-alt); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
.nav a.btn { color: #fff; }
.nav a.btn:hover { color: #fff; }

.lang-switch {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
}
.lang-switch:hover { text-decoration: none; border-color: var(--brand); }

/* Layout ------------------------------------------------------------------ */

.layout {
    display: grid;
    gap: 24px;
    padding-block: 28px 40px;
    grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 900px) {
    .layout.with-sidebar { grid-template-columns: minmax(0, 1fr) 280px; }
}
.content > * + * { margin-top: 20px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.card > :last-child { margin-bottom: 0; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.card-head h2 { margin: 0; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.page-head h1 { margin: 0; }

/* Buttons ------------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-small);
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--brand-strong); color: #fff; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-alt); color: var(--text); border-color: var(--muted); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn-large { padding: 12px 22px; font-size: 1.05rem; }
.btn-small { padding: 6px 10px; font-size: 0.875rem; }
.btn-icon { padding: 7px; background: transparent; color: var(--muted); border-color: var(--border); }
.btn-icon:hover { background: var(--surface-alt); color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.btn svg, .icon { width: 18px; height: 18px; flex: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Forms ------------------------------------------------------------------ */

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label, .field-label { font-weight: 600; font-size: 0.925rem; }
.field .hint { font-size: 0.85rem; color: var(--muted); margin: 0; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.field .error-text { font-size: 0.85rem; color: var(--danger); margin: 0; }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}
input:disabled { background: var(--surface-alt); color: var(--muted); }

/* Searchable list (time zone picker, public/js/main.js) */
.combobox { position: relative; }
.combobox-list {
    position: absolute;
    z-index: 2;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-large);
}
.combobox-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    overflow-wrap: anywhere;
}
.combobox-list li span { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.combobox-list li[aria-selected="true"] { font-weight: 600; }
.combobox-list li[role="option"]:hover { background: var(--surface-alt); }
.combobox-list li.active { background: var(--brand-soft); }
.combobox-list .combobox-empty { color: var(--muted); cursor: default; }

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-small);
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    font-weight: 500;
}

.alert.success {
    background: color-mix(in srgb, var(--success) 12%, var(--surface));
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 30%, transparent);
}
.narrow-card { max-width: 560px; }
.narrow-card + .narrow-card { margin-top: 20px; }

.auth-card { max-width: 420px; margin-inline: auto; }
.auth-card .btn { width: 100%; margin-top: 4px; }
.auth-switch { text-align: center; margin-top: 16px; color: var(--muted); font-size: 0.925rem; }

/* Home ------------------------------------------------------------------ */

.hero {
    display: grid;
    gap: 28px;
    align-items: center;
    padding: 36px 28px;
    background:
        radial-gradient(circle at 90% 10%, color-mix(in srgb, var(--brand-light) 55%, transparent), transparent 55%),
        linear-gradient(135deg, var(--brand-soft), var(--surface));
}
@media (min-width: 760px) { .hero { grid-template-columns: 1.3fr 1fr; padding: 48px; } }
.hero h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); }
.hero p { font-size: 1.1rem; color: var(--muted); max-width: 36em; }
.hero-counters { display: grid; gap: 12px; justify-items: center; }
.hero-counters img { width: 180px; height: 60px; }

.counter-image {
    image-rendering: pixelated;
    border-radius: 4px;
    box-shadow: 0 0 0 1px var(--border);
    background:
        repeating-conic-gradient(var(--surface-alt) 0 25%, var(--surface) 0 50%) 0 0 / 12px 12px;
}

.feature-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.feature { padding: 18px; border-radius: var(--radius); background: var(--surface-alt); border: 1px solid var(--border); }
.feature h3 { display: flex; align-items: center; gap: 10px; }
.feature h3 svg { width: 22px; height: 22px; color: var(--brand); }
.feature p { color: var(--muted); margin: 0; font-size: 0.95rem; }

.type-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.type-item { display: grid; gap: 8px; justify-items: start; }
.type-item img { width: 180px; height: 60px; }
.type-item span { font-size: 0.9rem; color: var(--muted); }

/* Statistics ------------------------------------------------------------------ */

.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat-label { font-size: 0.825rem; color: var(--muted); display: block; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.sidebar h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.stat-list { margin: 0; display: grid; gap: 2px; }
.stat-list div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.stat-list div:last-child { border-bottom: 0; }
.stat-list dt { color: var(--muted); font-size: 0.9rem; }
.stat-list dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.chart-box { position: relative; height: 320px; }

.device-list { display: grid; gap: 10px; }
.device-row { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: center; font-size: 0.9rem; }
.device-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: var(--surface-alt); }
.device-bar span {
    display: flex;
    align-items: center;
    padding-inline: 8px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    min-width: 0;
}
.device-bar .desktop { background: var(--brand); }
.device-bar .mobile { background: var(--accent); justify-content: flex-end; }
.device-bar .none { color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 0.875rem; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.825rem;
    font-weight: 600;
    background: var(--brand-soft);
    color: var(--brand);
    font-variant-numeric: tabular-nums;
}
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* Sites list ------------------------------------------------------------------ */

.filter-label { font-size: 0.825rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
}
.chip:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.chip[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip small { opacity: 0.7; font-variant-numeric: tabular-nums; }

.ranking { list-style: none; margin: 0; padding: 0; counter-reset: rank var(--start, 0); }
.ranking li {
    counter-increment: rank;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}
.ranking li:last-child { border-bottom: 0; }
.ranking li::before {
    content: counter(rank);
    flex: none;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-alt);
    color: var(--muted);
    font-weight: 700;
    font-size: 0.85rem;
}
.ranking a { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; margin: 0; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.pagination a, .pagination span {
    min-width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding-inline: 10px;
    border-radius: var(--radius-small);
    border: 1px solid var(--border);
    background: var(--surface);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.pagination a:hover { text-decoration: none; border-color: var(--brand); }
.pagination [aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .gap { border: 0; background: none; min-width: 20px; }

/* My counters ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-alt); }
.table tr:last-child td { border-bottom: 0; }
.counter-cell { display: flex; align-items: center; gap: 12px; }
.counter-cell img { width: 90px; height: 30px; flex: none; }
.counter-cell a { font-weight: 600; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Dialogs ------------------------------------------------------------------ */

dialog {
    border: 0;
    padding: 0;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-large);
    width: min(520px, 100% - 24px);
    max-height: calc(100% - 24px);
}
dialog.wide { width: min(980px, 100% - 24px); }
dialog::backdrop { background: rgba(10, 18, 28, 0.55); backdrop-filter: blur(2px); }
.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}
.dialog-head h2 { margin: 0; font-size: 1.1rem; }
.dialog-body { padding: 20px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 20px 20px; }
.code-box { width: 100%; min-height: 120px; font-family: var(--mono); font-size: 0.85rem; resize: vertical; }

/* Counter editor ------------------------------------------------------------------ */

.editor { display: grid; gap: 24px; }
@media (min-width: 820px) { .editor { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.editor fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
.editor legend { font-weight: 700; font-size: 1rem; margin-bottom: 12px; padding: 0; }
.field-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.color-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 16px; }
.color-field {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}
.color-field input[type="color"] {
    grid-row: span 2;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
    cursor: pointer;
}
.color-field label { font-weight: 600; font-size: 0.9rem; }
.color-field .range-row { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.color-field input[type="range"] { flex: 1; accent-color: var(--brand); }

.option-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin-bottom: 16px; }
.option {
    position: relative;
    display: grid;
    gap: 6px;
    justify-items: center;
    padding: 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-small);
    cursor: pointer;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    background: var(--surface);
}
.option:hover { border-color: var(--brand-light); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.option:has(input:focus-visible) { outline: 3px solid var(--brand-light); outline-offset: 2px; }
.option img { width: 90px; height: 30px; }

.preview-panel { position: sticky; top: 90px; text-align: center; }
.preview-panel img { width: 270px; height: 90px; }
.preview-panel .btn { width: 100%; margin-top: 16px; }

/* Footer ------------------------------------------------------------------ */

.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-block: 20px 32px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
}
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer img { display: block; }

/* Text pages ------------------------------------------------------------------ */

.prose { max-width: 70ch; }
.update + .update { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }

/* Fixes and small screens ----------------------------------------------------- */

.field { align-content: start; }
.sidebar { align-self: start; }
@media (min-width: 760px) { .type-grid { grid-template-columns: repeat(3, 1fr); } }

@media (max-width: 640px) {
    .brand { margin-right: 0; }
    .header-inner { justify-content: space-between; }
    .lang-switch { order: 2; }
    .nav { order: 3; width: 100%; justify-content: space-between; }
    .card { padding: 16px; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .hero { padding: 28px 20px; }
}

/* Counter table as stacked blocks on narrow screens. */
@media (max-width: 760px) {
    .table thead { display: none; }
    .table, .table tbody, .table td { display: block; }
    .table tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
        padding: 14px 0;
        border-bottom: 1px solid var(--border);
    }
    .table tr:last-child { border-bottom: 0; }
    .table tbody tr:hover { background: none; }
    .table td { border: 0; padding: 0; }
    .table td:first-child, .table td:last-child { grid-column: 1 / -1; }
    .table td.num { text-align: left; }
    .table td.num::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
    .actions { justify-content: flex-start; }
}

/* Name and URL of a counter in one cell. Both may break anywhere so the table can shrink;
   the URL is cut to one line. */
.counter-meta { display: grid; gap: 2px; min-width: 0; }
.counter-meta a { overflow-wrap: anywhere; }
.counter-url {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Legal pages (app/legal) ------------------------------------------------------------------ */

.legal { max-width: 800px; margin-inline: auto; line-height: 1.65; }
.legal h2 { margin-top: 1.8em; font-size: 1.1rem; }
.legal ul { padding-left: 1.3em; }
.legal li + li { margin-top: 6px; }
.legal td:first-child { font-weight: 600; }
@media (min-width: 761px) { .legal td:first-child { width: 38%; } }
.hint.agree { font-size: 0.85rem; color: var(--muted); margin: 0 0 12px; }

/* Admin ------------------------------------------------------------------ */

.search-form { display: flex; gap: 8px; }
.search-form input { min-width: 220px; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; }
.details dt { color: var(--muted); font-size: 0.85rem; }
.details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
