:root {
    color-scheme: dark;
    --bg: #0e1014;
    --surface: #151922;
    --surface-2: #1b212c;
    --surface-3: #222a36;
    --line: #303947;
    --line-soft: rgba(255, 255, 255, 0.07);
    --text: #f6f8fb;
    --muted: #9aa6b5;
    --soft: #cbd4df;
    --accent: #38d0aa;
    --accent-2: #6ea8ff;
    --danger: #ff6b6b;
    --warning: #f7c948;
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(56, 208, 170, 0.08), transparent 360px),
        linear-gradient(135deg, #0e1014 0%, #121720 50%, #0e1014 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    appearance: none;
}

.app-header,
.shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
}

.app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: end;
    padding: 34px 0 22px;
}

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

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

h1 {
    margin-bottom: 10px;
    font-size: clamp(2.2rem, 6vw, 4.4rem);
    line-height: 0.98;
}

h2 {
    margin-bottom: 0;
    font-size: 1.25rem;
}

h3 {
    margin-bottom: 8px;
    font-size: 1rem;
}

.lead {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.6;
}

.header-stat {
    min-width: 170px;
    padding: 18px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(56, 208, 170, 0.12), rgba(110, 168, 255, 0.1)), var(--surface);
    box-shadow: var(--shadow);
}

.header-stat span,
.metric span,
.subscription-money span,
.subscription-meta,
.deadline-row span,
.bar-row span,
.empty {
    color: var(--muted);
}

.header-stat strong {
    display: block;
    margin-top: 4px;
    font-size: 2.4rem;
}

.shell {
    padding-bottom: 42px;
}

.notice {
    margin-bottom: 14px;
    padding: 13px 15px;
    border: 1px solid rgba(56, 208, 170, 0.35);
    border-radius: 8px;
    background: rgba(56, 208, 170, 0.1);
}

.notice.error {
    border-color: rgba(255, 107, 107, 0.4);
    background: rgba(255, 107, 107, 0.1);
}

.tab-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tab-nav {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    overflow: hidden;
    margin-bottom: 18px;
    padding: 6px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(14, 16, 20, 0.88);
    backdrop-filter: blur(18px);
}

.tab-nav label {
    min-height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--soft);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 800;
    text-align: center;
}

.tab-nav label:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
}

#tab-dashboard:checked ~ .tab-nav label[for="tab-dashboard"],
#tab-new:checked ~ .tab-nav label[for="tab-new"],
#tab-subscriptions:checked ~ .tab-nav label[for="tab-subscriptions"],
#tab-providers:checked ~ .tab-nav label[for="tab-providers"] {
    border-color: rgba(56, 208, 170, 0.38);
    background: linear-gradient(135deg, rgba(56, 208, 170, 0.18), rgba(110, 168, 255, 0.12));
    color: #ffffff;
}

.tab-page {
    display: none;
}

#tab-dashboard:checked ~ .tab-dashboard,
#tab-new:checked ~ .tab-new,
#tab-subscriptions:checked ~ .tab-subscriptions,
#tab-providers:checked ~ .tab-providers {
    display: grid;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric,
.panel {
    min-width: 0;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(21, 25, 34, 0.9);
    box-shadow: var(--shadow);
}

.metric {
    min-height: 118px;
    padding: 18px;
}

.metric strong {
    display: block;
    margin-top: 16px;
    font-size: clamp(1.35rem, 2.8vw, 2.1rem);
}

.metric.primary {
    border-color: rgba(56, 208, 170, 0.28);
    background: linear-gradient(135deg, rgba(56, 208, 170, 0.2), rgba(110, 168, 255, 0.13)), var(--surface);
}

.content-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
    gap: 18px;
    align-items: start;
}

.tab-new > .panel,
.tab-subscriptions > .panel {
    grid-column: 1 / -1;
}

.panel {
    padding: 20px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-soft);
}

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

.stacked-form,
.mini-section {
    display: grid;
    gap: 13px;
}

.mini-section + .mini-section {
    margin-top: 24px;
}

label {
    min-width: 0;
    display: grid;
    gap: 7px;
    color: var(--soft);
    font-size: 0.9rem;
    font-weight: 750;
}

input,
select,
textarea {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #10151d;
    color: var(--text);
    padding: 11px 12px;
    outline: none;
}

input[type="color"] {
    min-height: 43px;
    padding: 5px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(56, 208, 170, 0.72);
    box-shadow: 0 0 0 3px rgba(56, 208, 170, 0.14);
}

textarea {
    resize: vertical;
}

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

.button,
.icon-button {
    min-width: 0;
    border: 0;
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.button {
    min-height: 44px;
    padding: 0 16px;
}

.button.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #071116;
}

.button:hover,
.icon-button:hover {
    filter: brightness(1.08);
}

.provider-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 20px;
}

.provider-cloud span {
    border: 1px solid color-mix(in srgb, var(--accent), transparent 35%);
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent), transparent 88%);
    color: #eef6ff;
    padding: 7px 10px;
    font-size: 0.84rem;
    font-weight: 800;
}

.provider-list,
.subscription-list {
    display: grid;
    gap: 12px;
}

.provider-card,
.subscription-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(16, 21, 29, 0.78);
}

.provider-card {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.provider-edit-form {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(150px, 1fr) 78px auto;
    gap: 10px;
    align-items: end;
    min-width: 0;
}

.subscription-card {
    display: grid;
    grid-template-columns: minmax(220px, 1.1fr) minmax(180px, 0.7fr) auto;
    gap: 14px;
    padding: 16px;
    align-items: start;
}

.subscription-main {
    display: flex;
    gap: 12px;
    min-width: 0;
}

.subscription-main > div,
.subscription-money {
    min-width: 0;
}

.dot {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    border-radius: 999px;
    margin-top: 7px;
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.05);
}

.subscription-main h3 {
    margin-bottom: 4px;
    font-size: 1.08rem;
}

.subscription-main p,
.notes {
    margin-bottom: 0;
    color: var(--muted);
}

.subscription-money {
    text-align: right;
}

.subscription-money strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1.1rem;
}

.subscription-meta {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.86rem;
}

.subscription-meta span {
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
    padding: 6px 9px;
}

.notes {
    grid-column: 1 / -1;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
    line-height: 1.5;
}

.delete-form {
    justify-self: end;
}

.icon-button {
    padding: 8px 10px;
    color: var(--danger);
}

.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.edit-box {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line-soft);
    padding-top: 10px;
}

.edit-box summary {
    width: fit-content;
    border-radius: 6px;
    cursor: pointer;
    color: var(--accent);
    font-weight: 800;
}

.compact-form {
    margin-top: 14px;
}

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

.deadline-row div {
    display: grid;
    gap: 2px;
}

.soft-pill,
.danger-pill {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 6px 9px;
    font-size: 0.78rem;
    font-weight: 800;
}

.soft-pill {
    background: rgba(110, 168, 255, 0.14);
    color: #c8d9ff;
}

.danger-pill {
    background: rgba(255, 107, 107, 0.14);
    color: #ffb5b5;
}

.danger-text {
    color: #ffb5b5;
}

.bar-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: center;
}

.bar {
    grid-column: 1 / -1;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #0f141b;
}

.bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.empty {
    margin-bottom: 0;
    line-height: 1.6;
}

.empty.compact {
    font-size: 0.92rem;
}

@media (max-width: 920px) {
    .app-header {
        grid-template-columns: 1fr;
        padding-top: 26px;
    }

    .tab-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .provider-edit-form {
        grid-template-columns: 1fr;
    }

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

    .subscription-card {
        grid-template-columns: 1fr;
    }

    .subscription-money {
        text-align: left;
    }

    .delete-form {
        justify-self: start;
    }
}

@media (max-width: 560px) {
    .app-header,
    .shell {
        width: min(100% - 20px, 1240px);
    }

    h1 {
        font-size: 2.3rem;
    }

    .tab-nav {
        position: static;
        grid-template-columns: 1fr;
    }

    .panel,
    .metric {
        padding: 15px;
    }

    .deadline-row {
        align-items: flex-start;
        flex-direction: column;
    }
}
