:root {
    --bg: #f4f7f6;
    --panel: #ffffff;
    --ink: #121826;
    --muted: #6b7280;
    --line: #d9e0dd;
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --accent: #f97316;
    --danger: #b42318;
    --success-bg: #e8f8ef;
    --success: #166534;
    --error-bg: #fff1f1;
    --error: #b42318;
    --shadow: 0 12px 32px rgba(18, 24, 38, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

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

a:hover {
    color: var(--primary-dark);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 68px;
    padding: 14px clamp(16px, 4vw, 44px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 800;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-size: 13px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.nav {
    display: flex;
    align-items: center;
    gap: 14px;
}

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

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: clamp(20px, 3vw, 30px);
}

.narrow {
    width: min(560px, 100%);
    margin: 54px auto;
}

.auth-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.7fr);
    gap: 22px;
    align-items: stretch;
}

.intro-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 420px;
    background: #10201e;
    color: #ffffff;
    border-color: #10201e;
}

.intro-panel .muted,
.intro-panel .lead {
    color: #dce8e4;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
    line-height: 1.1;
}

h1 {
    max-width: 760px;
    font-size: clamp(34px, 6vw, 58px);
}

h2 {
    margin-bottom: 18px;
    font-size: 22px;
}

.lead {
    max-width: 680px;
    color: var(--muted);
    font-size: 18px;
}

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

.center {
    text-align: center;
}

.block {
    display: block;
}

.break-word {
    overflow-wrap: anywhere;
}

.quick-metrics,
.metric-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 28px;
}

.metric {
    min-height: 86px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.intro-panel .metric {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.intro-panel .metric span {
    color: #c3d5d0;
}

.metric strong {
    display: block;
    margin-top: 6px;
    color: var(--ink);
    font-size: 24px;
}

.intro-panel .metric strong {
    color: #ffffff;
}

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

.dashboard-head h1 {
    font-size: clamp(32px, 4vw, 46px);
}

.dashboard-head .metric-row {
    width: min(520px, 100%);
    margin-top: 0;
}

.form-stack {
    display: grid;
    gap: 16px;
}

.form-grid,
.create-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.create-form {
    grid-template-columns: 1.3fr 0.7fr 0.8fr auto;
    align-items: end;
}

.span-2 {
    grid-column: span 1;
}

label span {
    display: block;
    margin-bottom: 7px;
    color: #374151;
    font-size: 13px;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid #cdd6d2;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
    outline: none;
    padding: 10px 12px;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    line-height: 1;
    padding: 12px 18px;
    white-space: nowrap;
}

.button:hover,
button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #ffffff;
}

.button-small {
    min-height: 34px;
    padding: 8px 11px;
    font-size: 14px;
}

.ghost {
    background: #ffffff;
    color: var(--primary);
}

.ghost:hover {
    background: #effaf7;
    color: var(--primary-dark);
}

.danger {
    background: #fff7f6;
    border-color: #f0b8b2;
    color: var(--danger);
}

.danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.inline-form,
.actions form {
    display: inline;
    margin: 0;
}

.link-button {
    min-height: auto;
    border: 0;
    background: transparent;
    color: var(--primary);
    padding: 0;
}

.link-button:hover {
    background: transparent;
    color: var(--primary-dark);
}

.alert {
    margin-bottom: 16px;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

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

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

.table-panel {
    margin-top: 22px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

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

table {
    width: 100%;
    min-width: 820px;
    border-collapse: collapse;
}

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

th {
    color: #4b5563;
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.short-link {
    color: var(--primary-dark);
    font-weight: 900;
}

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

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

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    background: #eef0f2;
    color: #4b5563;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 10px;
}

.badge-on {
    background: #e5f7ed;
    color: #166534;
}

.empty-state {
    border: 1px dashed #cdd6d2;
    border-radius: 8px;
    color: var(--muted);
    padding: 18px;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.bar-list {
    display: grid;
    gap: 12px;
}

.bar-row {
    display: grid;
    grid-template-columns: 100px minmax(90px, 1fr) 44px;
    gap: 10px;
    align-items: center;
}

.bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e6ebe8;
}

.bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.small-table {
    display: grid;
    gap: 9px;
}

.small-table div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 9px;
}

.small-table span {
    overflow-wrap: anywhere;
}

.code-box,
.config-output {
    display: block;
    width: 100%;
    margin: 12px 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf9;
    color: #26312f;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.55;
    overflow-x: auto;
    padding: 12px;
}

.config-output {
    min-height: 260px;
}

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

@media (max-width: 920px) {
    .auth-grid,
    .stats-grid,
    .dashboard-head {
        grid-template-columns: 1fr;
        display: grid;
    }

    .dashboard-head .metric-row {
        width: 100%;
    }

    .create-form {
        grid-template-columns: 1fr 1fr;
    }

    .create-form .button {
        grid-column: span 2;
    }
}

@media (max-width: 640px) {
    .shell {
        width: min(100% - 24px, 1180px);
        margin-top: 18px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .nav {
        width: 100%;
        justify-content: space-between;
    }

    h1 {
        font-size: 34px;
    }

    .quick-metrics,
    .metric-row,
    .form-grid,
    .create-form {
        grid-template-columns: 1fr;
    }

    .create-form .button {
        grid-column: auto;
    }

    .intro-panel {
        min-height: auto;
    }

    .actions {
        justify-content: flex-start;
    }
}
