/* IP Detector dashboard — hand-written, no build step required. */

:root {
    color-scheme: light dark;

    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --border: #e2e5ea;
    --text: #1a1d23;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-text: #ffffff;
    --good: #15803d;
    --good-bg: #dcfce7;
    --warn: #b45309;
    --warn-bg: #fef3c7;
    --bad: #b91c1c;
    --bad-bg: #fee2e2;
    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #171a21;
        --surface-2: #1e222b;
        --border: #2a2f3a;
        --text: #e6e8ec;
        --muted: #9099a8;
        --accent: #4f83ff;
        --good: #4ade80;
        --good-bg: #14321f;
        --warn: #fbbf24;
        --warn-bg: #35270a;
        --bad: #f87171;
        --bad-bg: #3a1616;
        --code-bg: #0b0e14;
        --code-text: #d5dae3;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

code,
pre,
.mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875em;
}

/* ---------- layout ---------- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner,
.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 28px;
    height: 60px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 650;
    color: var(--text);
    letter-spacing: -0.01em;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
}

.nav {
    display: flex;
    gap: 4px;
    margin-left: auto;
    align-items: center;
    flex-wrap: wrap;
}

.nav a,
.nav button {
    padding: 7px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 500;
    font-size: 14px;
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
}

.nav a:hover,
.nav button:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.nav a.is-active {
    background: var(--surface-2);
    color: var(--text);
}

main {
    padding: 32px 0 72px;
}

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

h1 {
    font-size: 24px;
    letter-spacing: -0.02em;
    margin: 0 0 4px;
}

h2 {
    font-size: 16px;
    margin: 0 0 14px;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 14px;
    margin: 0 0 8px;
}

.subtitle {
    color: var(--muted);
    margin: 0;
    font-size: 14px;
}

/* ---------- cards & grid ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.card + .card {
    margin-top: 20px;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid.cols-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.stat-value {
    font-size: 26px;
    font-weight: 650;
    letter-spacing: -0.02em;
    margin-top: 4px;
}

.stat-note {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

/* ---------- tables ---------- */

.table-wrap {
    overflow-x: auto;
    margin: 0 -20px -20px;
    padding: 0 20px 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding: 0 12px 8px 0;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 10px 12px 10px 0;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

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

/* ---------- form controls ---------- */

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}

.field {
    margin-bottom: 14px;
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 15px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--accent);
    color: var(--accent-text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(1.06);
    text-decoration: none;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-link {
    background: none;
    border: 0;
    color: var(--muted);
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    border-radius: 6px;
}

.btn-link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn-link.danger:hover {
    background: var(--bad-bg);
    color: var(--bad);
}

.inline-form {
    display: inline;
}

.actions {
    display: flex;
    gap: 2px;
    justify-content: flex-end;
}

/* ---------- badges & alerts ---------- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}

.badge.good {
    background: var(--good-bg);
    color: var(--good);
}

.badge.warn {
    background: var(--warn-bg);
    color: var(--warn);
}

.badge.bad {
    background: var(--bad-bg);
    color: var(--bad);
}

.alert {
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert.success {
    background: var(--good-bg);
    color: var(--good);
    border-color: currentColor;
}

.alert.error {
    background: var(--bad-bg);
    color: var(--bad);
    border-color: currentColor;
}

.alert ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.error-text {
    color: var(--bad);
    font-size: 13px;
    margin-top: 5px;
}

/* ---------- code blocks ---------- */

pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 14px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0;
    line-height: 1.5;
}

pre + pre,
pre + h3 {
    margin-top: 16px;
}

.token-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 12px 14px;
    border-radius: 8px;
    margin-top: 10px;
    word-break: break-all;
}

.token-box .btn {
    flex-shrink: 0;
}

/* ---------- bar chart ---------- */

.chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    margin-top: 6px;
}

.chart-bar {
    flex: 1;
    min-width: 2px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
    opacity: 0.85;
    min-height: 2px;
}

.chart-bar:hover {
    opacity: 1;
}

.chart-axis {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 11px;
    margin-top: 6px;
}

.meter {
    height: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 5px;
}

.meter > span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

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

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

.nowrap {
    white-space: nowrap;
}

.right {
    text-align: right;
}

/* ---------- auth ---------- */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
}

.auth-card .brand {
    justify-content: center;
    margin-bottom: 20px;
    font-size: 18px;
}

/* ---------- docs ---------- */

.hero {
    padding: 56px 0 32px;
    text-align: center;
}

.hero h1 {
    font-size: 34px;
}

.hero p {
    color: var(--muted);
    max-width: 620px;
    margin: 10px auto 0;
    font-size: 16px;
}

.endpoint {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.method {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 7px;
    border-radius: 5px;
    background: var(--accent);
    color: #fff;
}

.method.post {
    background: var(--good);
    color: #fff;
}

.field-table td:first-child {
    width: 34%;
}

@media (max-width: 720px) {
    .topbar-inner {
        height: auto;
        padding-top: 12px;
        padding-bottom: 12px;
        flex-wrap: wrap;
    }

    .nav {
        margin-left: 0;
        width: 100%;
    }
}

/* ---------- settings ---------- */

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 8px;
    cursor: pointer;
}

.checkbox input[type="checkbox"] {
    width: auto;
    margin: 3px 0 0;
    flex-shrink: 0;
}

.provider-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}

.provider-row:last-of-type {
    border-bottom: 0;
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: sticky;
    bottom: 16px;
}
