:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #657282;
    --line: #d9dee7;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --danger: #b42318;
    --danger-bg: #fee4e2;
}

* {
    box-sizing: border-box;
}

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

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

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 32px auto;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.narrow {
    max-width: 460px;
    margin: 64px auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

h1, h2 {
    margin: 0 0 16px;
    line-height: 1.15;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 20px;
}

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

.stack {
    display: grid;
    gap: 14px;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}

.wide {
    grid-column: span 2;
}

label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-weight: 600;
    font-size: 14px;
}

input {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 9px 11px;
    font: inherit;
}

input:focus {
    outline: 3px solid rgba(15, 118, 110, 0.18);
    border-color: var(--accent);
}

button, .button {
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    padding: 10px 14px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover, .button:hover {
    background: var(--accent-strong);
}

.ghost {
    background: #eef4f3;
    color: var(--accent-strong);
}

.ghost:hover {
    background: #dbecea;
}

.danger-button {
    background: var(--danger-bg);
    color: var(--danger);
}

.danger-button:hover {
    background: #fecdca;
}

.alert, .notice {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.alert {
    background: var(--danger-bg);
    color: var(--danger);
}

.notice {
    background: #dcfae6;
    color: #067647;
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    color: #475467;
    font-size: 13px;
    text-transform: uppercase;
}

.truncate {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #e6f4f1;
    color: #0b5f58;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    margin-right: 4px;
}

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

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.short-url {
    max-width: 260px;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stats div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.stats span {
    display: block;
    font-weight: 800;
    font-size: 22px;
}

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

.referer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
}

.mini-dashboard {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.mini-dashboard > div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfd;
}

.mini-dashboard b,
.mini-dashboard span {
    display: block;
}

.mini-dashboard b {
    color: #475467;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.mini-dashboard span {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
}

.details-cell {
    min-width: 170px;
}

.details-cell strong,
.details-cell small {
    display: block;
}

.details-cell small {
    color: var(--muted);
    margin-top: 3px;
}

.click-extra td {
    background: #fafbfc;
    padding-top: 8px;
    padding-bottom: 14px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.detail-grid div {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    background: #ffffff;
}

.detail-grid b,
.detail-grid span {
    display: block;
}

.detail-grid b {
    color: #475467;
    font-size: 12px;
    text-transform: uppercase;
}

.detail-grid span {
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.wide-detail {
    grid-column: span 2;
}

.inference-box {
    border-color: #99d6cf !important;
    background: #f0fdfa !important;
}

.inference-box span + span {
    margin-top: 6px;
}

.risk-box {
    border-color: #fec84b !important;
    background: #fffaeb !important;
}

.risk-box span + span {
    margin-top: 6px;
}

.json-detail {
    grid-column: 1 / -1;
}

.json-detail pre {
    max-height: 260px;
    overflow: auto;
    margin: 8px 0 0;
    padding: 10px;
    border-radius: 6px;
    background: #111827;
    color: #e5e7eb;
    font-size: 12px;
    white-space: pre-wrap;
}

code {
    background: #eef2f6;
    border-radius: 4px;
    padding: 2px 5px;
}

@media (max-width: 820px) {
    .grid-form, .stats, .mini-dashboard {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .wide-detail {
        grid-column: auto;
    }

    .wide {
        grid-column: auto;
    }

    .shell {
        width: min(100% - 20px, 1120px);
        margin: 20px auto;
    }
}
