:root {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-strong: #f8fafc;
    --text: #111827;
    --muted: #64748b;
    --line: #d9e1ea;
    --line-soft: #edf1f5;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #2563eb;
    --danger: #b42318;
    --success: #16835f;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --shadow-strong: 0 28px 70px rgba(15, 23, 42, .14);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, .12), transparent 34%),
        linear-gradient(180deg, #f8fafc 0%, var(--bg) 45%, #f7f9fb 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

body::before {
    position: fixed;
    inset: -20% -10% auto;
    z-index: -1;
    height: 420px;
    content: "";
    background:
        radial-gradient(circle at 20% 20%, rgba(37, 99, 235, .16), transparent 28%),
        radial-gradient(circle at 82% 12%, rgba(15, 118, 110, .18), transparent 30%);
    filter: blur(12px);
    animation: ambientShift 14s ease-in-out infinite alternate;
}

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 72px;
    padding: 0 max(28px, calc((100vw - 1180px) / 2));
    background: rgba(255, 255, 255, .82);
    border-bottom: 1px solid rgba(217, 225, 234, .9);
    backdrop-filter: blur(18px);
    animation: slideDown .45s ease both;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    font-weight: 800;
    font-size: 18px;
}

.brand span {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 8px;
    background: #0f766e;
    color: #ffffff;
    font-size: 13px;
    letter-spacing: .08em;
}

nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

nav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 13px;
    border-radius: 8px;
    color: #334155;
    font-weight: 700;
}

nav a:hover {
    background: #ecfdf5;
    color: var(--primary-dark);
}

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

h1,
h2,
p {
    margin-top: 0;
}

h1,
h2 {
    margin-bottom: 10px;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.08;
}

h2 {
    font-size: 21px;
    line-height: 1.2;
}

.eyebrow {
    display: inline-flex;
    margin-bottom: 10px;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .12em;
}

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

.auth,
.panel,
.usage,
.stats div {
    background: rgba(255, 255, 255, .94);
    border: 1px solid rgba(217, 225, 234, .95);
    border-radius: 8px;
    box-shadow: var(--shadow);
    animation: riseIn .48s ease both;
}

.auth {
    width: min(470px, 100%);
    margin: 64px auto;
    padding: 34px;
}

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

.form,
.upload,
.compact-form {
    display: grid;
    gap: 15px;
    margin-top: 22px;
}

label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 800;
}

input,
select,
button {
    min-height: 44px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    padding: 10px 12px;
    font: inherit;
}

input,
select {
    background: #ffffff;
    color: var(--text);
}

input[type="file"] {
    padding: 9px;
    background: var(--surface-strong);
}

input:focus,
select:focus {
    outline: 3px solid rgba(15, 118, 110, .16);
    border-color: var(--primary);
}

button {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    font-weight: 850;
    cursor: pointer;
    box-shadow: 0 12px 22px rgba(15, 118, 110, .18);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(15, 118, 110, .22);
}

button.danger {
    background: var(--danger);
    border-color: var(--danger);
    box-shadow: 0 12px 22px rgba(180, 35, 24, .14);
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
}

.alert.success {
    border-color: #9fd6bf;
    background: #effaf5;
    color: #07563d;
}

.alert.error {
    border-color: #f0aaa4;
    background: #fff1f0;
    color: #8f1f14;
}

.grid.two {
    display: grid;
    grid-template-columns: 1fr minmax(280px, 380px);
    gap: 24px;
    align-items: end;
    margin-bottom: 22px;
}

.usage {
    padding: 20px;
}

.meter-label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.usage strong {
    display: block;
    font-size: 20px;
}

.bar {
    height: 10px;
    margin-top: 14px;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: 999px;
}

.bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    animation: meterPulse 2.6s ease-in-out infinite;
}

.panel {
    margin-top: 24px;
    padding: 24px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.upload {
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr) auto;
    align-items: center;
}

.compact-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    margin-top: 0;
}

.bucket-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
    gap: 16px;
    align-items: start;
    margin-bottom: 18px;
}

.bucket-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.bucket-card {
    display: grid;
    gap: 5px;
    min-height: 104px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.bucket-card:hover,
.bucket-card.active {
    border-color: rgba(15, 118, 110, .48);
    background: #f0fdfa;
    box-shadow: 0 14px 32px rgba(15, 118, 110, .1);
    transform: translateY(-2px);
}

.bucket-card span {
    font-weight: 900;
}

.bucket-card strong {
    color: var(--primary-dark);
}

.bucket-card small {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: #ffffff;
}

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

tbody tr:hover {
    background: #f8fafc;
}

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

th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.link,
.snippet {
    width: min(560px, 100%);
    margin-top: 8px;
    background: #f8fafc;
    color: #475569;
    font-size: 13px;
}

.snippet {
    width: min(360px, 100%);
    margin-top: 0;
}

.small {
    width: 116px;
}

.note-input {
    width: 180px;
    margin-left: 6px;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin: 18px 0 24px;
}

.stats div {
    padding: 20px;
}

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

.stats strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
    line-height: 1.1;
}

.badge,
.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.badge {
    background: #eff6ff;
    color: #1d4ed8;
}

.status.ok {
    background: #ecfdf5;
    color: var(--success);
}

.status.off {
    background: #f1f5f9;
    color: #64748b;
}

.credit-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    margin-top: 14px;
    padding: 0 12px;
    border-radius: 999px;
    background: #eef6ff;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 900;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ambientShift {
    from {
        transform: translate3d(-16px, 0, 0) scale(1);
    }
    to {
        transform: translate3d(16px, 18px, 0) scale(1.05);
    }
}

@keyframes meterPulse {
    0%, 100% {
        filter: saturate(1);
    }
    50% {
        filter: saturate(1.35);
    }
}

.block {
    display: block;
    margin-top: 4px;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    font-weight: 800;
}

.inline-check input {
    min-height: auto;
}

@media (max-width: 760px) {
    .topbar {
        position: static;
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
    }

    .shell {
        width: min(100% - 24px, 1180px);
        margin-top: 22px;
    }

    .grid.two,
    .upload,
    .stats,
    .compact-form,
    .bucket-grid {
        grid-template-columns: 1fr;
    }

    .auth,
    .panel {
        padding: 20px;
    }
}
