@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Montserrat:wght@700;800&display=swap');

:root {
    --bg: #f8fafc;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --surface-soft: rgba(241, 245, 249, 0.78);
    --text: #0f172a;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --line: rgba(148, 163, 184, 0.26);
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --shadow: 0 24px 70px rgba(15, 23, 42, 0.10);
    --radius-xl: 28px;
    color-scheme: light;
}

.dark {
    --bg: #020617;
    --surface: rgba(15, 23, 42, 0.78);
    --surface-strong: #0f172a;
    --surface-soft: rgba(30, 41, 59, 0.58);
    --text: #f8fafc;
    --muted: #94a3b8;
    --muted-2: #64748b;
    --line: rgba(148, 163, 184, 0.18);
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, Montserrat, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.14), transparent 36rem),
        radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.14), transparent 32rem),
        var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
input,
select {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

input,
select {
    font-size: 16px;
}

[x-cloak] {
    display: none !important;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.42);
    border-radius: 999px;
}

.app-aurora {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.app-aurora::before,
.app-aurora::after {
    content: "";
    position: absolute;
    width: 34rem;
    height: 34rem;
    border-radius: 999px;
    filter: blur(96px);
    opacity: 0.36;
}

.app-aurora::before {
    top: -12rem;
    right: -10rem;
    background: #6366f1;
}

.app-aurora::after {
    bottom: -14rem;
    left: -12rem;
    background: #06b6d4;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 22px 0 80px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0 18px;
    backdrop-filter: blur(16px);
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 18px;
    color: white;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 18px 38px rgba(79, 70, 229, 0.34);
}

.brand-mark svg {
    width: 23px;
    height: 23px;
}

.brand-title {
    display: block;
    font-family: Montserrat, Inter, sans-serif;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.brand-subtitle {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    display: inline-grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button.compact {
    width: 38px;
    height: 38px;
    border-radius: 13px;
}

.icon-button:hover {
    transform: translateY(-1px);
    border-color: rgba(99, 102, 241, 0.42);
}

.icon-button svg,
.desktop-add-button svg,
.fab svg,
.submit-button svg,
.empty-button svg,
.archive-toggle svg,
.category-chip svg,
.ghost-action svg,
.detail-pill svg,
.notice svg,
.panel-heading svg,
.metric-icon svg,
.search-box svg,
.field-label svg,
.settings-icon svg,
.picker-chip svg,
.switch-row svg,
.details-box summary svg {
    width: 18px;
    height: 18px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.summary-rail {
    position: sticky;
    top: 86px;
    display: grid;
    gap: 16px;
}

.hero-card,
.panel,
.toolbar-panel,
.sub-card,
.mobile-total-card,
.mobile-mini-card,
.modal-panel {
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-card {
    position: relative;
    overflow: hidden;
    padding: 24px;
    border-radius: var(--radius-xl);
    color: white;
    background:
        linear-gradient(135deg, rgba(79, 70, 229, 0.98), rgba(124, 58, 237, 0.94)),
        radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.35), transparent 18rem);
}

.hero-card::after {
    content: "";
    position: absolute;
    right: -60px;
    bottom: -80px;
    width: 210px;
    height: 210px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
}

.hero-card__topline,
.panel-heading,
.sub-card-main,
.sub-details,
.card-actions,
.modal-header,
.confirm-actions,
.search-row {
    display: flex;
    align-items: center;
}

.hero-card__topline {
    position: relative;
    z-index: 1;
    justify-content: space-between;
    gap: 12px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rate-chip {
    padding: 5px 9px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    letter-spacing: 0;
    text-transform: none;
}

.hero-total {
    position: relative;
    z-index: 1;
    margin-top: 20px;
    font-size: clamp(2.35rem, 6vw, 3.55rem);
    font-weight: 900;
    letter-spacing: -0.08em;
    line-height: 0.96;
    font-variant-numeric: tabular-nums;
}

.hero-note {
    position: relative;
    z-index: 1;
    max-width: 28ch;
    margin: 18px 0 0;
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.86rem;
    line-height: 1.55;
}

.metric-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.metric-card {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: 0 14px 42px rgba(15, 23, 42, 0.06);
}

.metric-icon {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 13px;
    color: var(--brand);
    background: rgba(99, 102, 241, 0.11);
}

.metric-label {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.metric-card strong {
    font-size: 1.7rem;
    font-weight: 850;
    line-height: 1;
}

.panel {
    padding: 18px;
    border-radius: 24px;
}

.panel-heading {
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.next-payment-content {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    margin-top: 18px;
}

.next-payment-icon,
.sub-icon,
.empty-icon,
.confirm-icon,
.settings-icon {
    display: grid;
    place-items: center;
    flex: none;
}

.next-payment-icon {
    width: 48px;
    height: 48px;
    border-radius: 17px;
}

.next-plan,
.next-days,
.muted-text {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 650;
}

.next-days {
    margin-top: 2px;
    color: var(--brand);
}

.muted-text {
    margin: 16px 0 0;
}

.desktop-add-button,
.empty-button,
.submit-button,
.danger-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 18px;
    font-weight: 800;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.desktop-add-button,
.submit-button,
.empty-button {
    min-height: 52px;
    padding: 0 18px;
    color: white;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 18px 38px rgba(79, 70, 229, 0.28);
}

.desktop-add-button:hover,
.empty-button:hover,
.submit-button:hover,
.danger-button:hover,
.secondary-button:hover {
    transform: translateY(-1px);
}

.content-area {
    min-width: 0;
    display: grid;
    gap: 16px;
}

.mobile-summary {
    display: none;
}

.toolbar-panel {
    position: sticky;
    top: 86px;
    z-index: 30;
    padding: 18px;
    border-radius: var(--radius-xl);
}

.toolbar-copy {
    margin-bottom: 16px;
}

.toolbar-copy h1 {
    margin: 0;
    font-size: clamp(1.55rem, 3vw, 2.2rem);
    font-weight: 900;
    letter-spacing: -0.06em;
}

.toolbar-copy p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}

.search-row {
    gap: 12px;
}

.search-box {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--muted);
    background: var(--surface-soft);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-box:focus-within {
    border-color: rgba(99, 102, 241, 0.58);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.11);
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    font-weight: 650;
}

.search-box input::placeholder {
    color: var(--muted-2);
}

.archive-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 50px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
}

.archive-toggle.is-active {
    border-color: rgba(99, 102, 241, 0.40);
    color: var(--brand);
    background: rgba(99, 102, 241, 0.12);
}

.category-strip,
.picker-list {
    display: flex;
    gap: 9px;
    overflow-x: auto;
    margin-top: 14px;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.category-strip::-webkit-scrollbar,
.picker-list::-webkit-scrollbar {
    display: none;
}

.category-chip,
.picker-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 0.82rem;
    font-weight: 800;
    transition: transform 150ms ease, border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.category-chip {
    min-height: 40px;
    padding: 0 13px;
}

.category-chip:hover,
.picker-chip:hover {
    transform: translateY(-1px);
    border-color: rgba(99, 102, 241, 0.36);
}

.category-chip.is-selected,
.picker-chip.is-selected {
    border-color: transparent;
    color: white;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.26);
}

.subscription-list {
    display: grid;
    gap: 14px;
}

.sub-card {
    position: relative;
    overflow: hidden;
    padding: 18px;
    border-radius: var(--radius-xl);
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.sub-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.35);
}

.sub-card.is-urgent {
    border-color: rgba(245, 158, 11, 0.56);
    box-shadow: 0 18px 60px rgba(245, 158, 11, 0.12);
}

.sub-card.is-overdue {
    border-color: rgba(239, 68, 68, 0.48);
    box-shadow: 0 18px 60px rgba(239, 68, 68, 0.10);
}

.sub-card-main {
    align-items: flex-start;
    gap: 14px;
}

.sub-icon {
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 20px;
}

.sub-icon svg,
.next-payment-icon svg {
    width: 24px;
    height: 24px;
}

.tone-brand {
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.13);
}

.tone-danger {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.tone-warning {
    color: #d97706;
    background: rgba(245, 158, 11, 0.14);
}

.tone-purple {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.14);
}

.corner-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 13px;
    height: 13px;
    border: 3px solid var(--surface-strong);
    border-radius: 999px;
}

.trial-dot {
    background: var(--warning);
}

.privilege-dot {
    background: #8b5cf6;
}

.sub-info {
    min-width: 0;
    flex: 1;
    padding-top: 2px;
}

.sub-title-row {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.sub-title-row h2 {
    min-width: 0;
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.06rem;
    font-weight: 850;
    letter-spacing: -0.035em;
}

.status-pill {
    flex: 0 0 auto;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 850;
    line-height: 1;
}

.badge-normal {
    color: var(--brand);
    background: rgba(99, 102, 241, 0.12);
}

.badge-due {
    color: #d97706;
    background: rgba(245, 158, 11, 0.13);
}

.badge-overdue {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.13);
}

.badge-privilege {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.14);
}

.sub-plan {
    overflow: hidden;
    margin: 4px 0 0;
    color: var(--brand);
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.88rem;
    font-weight: 750;
}

.sub-meta-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.sub-price-block {
    flex: 0 0 auto;
    max-width: 180px;
    text-align: right;
}

.sub-price-block strong {
    display: block;
    font-size: 1.16rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

.sub-price-block span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
}

.sub-details {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.detail-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 11px;
    border-radius: 12px;
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 0.78rem;
    font-weight: 800;
}

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

.date-warning {
    color: #d97706;
    background: rgba(245, 158, 11, 0.13);
}

.date-danger {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 800;
}

.notice-trial {
    color: #b45309;
    background: rgba(245, 158, 11, 0.12);
}

.notice-privilege {
    color: #7c3aed;
    background: rgba(139, 92, 246, 0.13);
}

.card-actions {
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.ghost-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--muted);
    background: transparent;
    font-size: 0.78rem;
    font-weight: 800;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.ghost-action:hover {
    color: var(--brand);
    background: rgba(99, 102, 241, 0.10);
}

.danger-action:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.10);
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 64px 24px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-xl);
    text-align: center;
    background: var(--surface);
}

.empty-icon,
.confirm-icon {
    width: 68px;
    height: 68px;
    border-radius: 24px;
    color: var(--brand);
    background: rgba(99, 102, 241, 0.12);
}

.empty-icon svg,
.confirm-icon svg {
    width: 32px;
    height: 32px;
}

.empty-state h2 {
    margin: 8px 0 0;
    font-size: 1.2rem;
    font-weight: 850;
    letter-spacing: -0.04em;
}

.empty-state p {
    max-width: 34ch;
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
    font-weight: 600;
}

.empty-button {
    margin-top: 10px;
    min-height: 46px;
}

.fab {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 50;
    display: none;
    width: 58px;
    height: 58px;
    place-items: center;
    border: 0;
    border-radius: 22px;
    color: white;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 18px 42px rgba(79, 70, 229, 0.36);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: end center;
    padding: 18px;
    background: rgba(2, 6, 23, 0.66);
    backdrop-filter: blur(10px);
}

.modal-panel {
    width: min(100%, 720px);
    max-height: min(88vh, 820px);
    overflow: auto;
    border-radius: 30px;
    background: var(--surface-strong);
}

.subscription-modal {
    padding: 20px;
}

.settings-modal,
.confirm-modal {
    width: min(100%, 440px);
    padding: 22px;
}

.modal-header {
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    display: block;
    color: var(--brand);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.modal-header h2,
.confirm-modal h2 {
    margin: 3px 0 0;
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -0.055em;
}

.modal-header p,
.confirm-modal p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.5;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
    padding-top: 16px;
}

.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: 1 / -1; }

.form-field {
    display: grid;
    gap: 7px;
}

.form-field span,
.field-label {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.form-field em {
    color: var(--muted-2);
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}

.form-field input,
.form-field select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 16px;
    outline: 0;
    padding: 0 14px;
    color: var(--text);
    background: var(--surface-soft);
    font-weight: 720;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.form-field input:focus,
.form-field select:focus {
    border-color: rgba(99, 102, 241, 0.62);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.category-picker {
    display: grid;
    gap: 9px;
}

.picker-list {
    margin-top: 0;
    padding-bottom: 3px;
}

.picker-chip {
    min-height: 42px;
    padding: 0 13px;
}

.toggles-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 54px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 800;
}

.switch-row span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.switch-row input {
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    appearance: none;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.38);
    cursor: pointer;
    position: relative;
    transition: background 160ms ease;
}

.switch-row input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: white;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.20);
    transition: transform 160ms ease;
}

.switch-row input:checked {
    background: var(--brand);
}

.switch-row input:checked::after {
    transform: translateX(18px);
}

.details-box {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-soft);
}

.details-box summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 50px;
    padding: 0 14px;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 850;
    list-style: none;
}

.details-box summary::-webkit-details-marker {
    display: none;
}

.details-box summary span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.details-box[open] summary > svg:last-child {
    transform: rotate(180deg);
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 14px 14px;
}

.submit-button {
    min-height: 54px;
}

.confirm-modal {
    text-align: center;
}

.confirm-icon {
    margin: 0 auto 16px;
    color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
}

.confirm-actions {
    gap: 10px;
    margin-top: 20px;
}

.secondary-button,
.danger-button {
    flex: 1;
    min-height: 48px;
    padding: 0 16px;
}

.secondary-button {
    border: 1px solid var(--line);
    color: var(--text);
    background: var(--surface-soft);
}

.danger-button {
    color: white;
    background: var(--danger);
    box-shadow: 0 14px 30px rgba(239, 68, 68, 0.24);
}

.settings-actions {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.settings-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    width: 100%;
    min-height: 76px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 20px;
    color: inherit;
    background: var(--surface-soft);
    text-align: left;
}

.settings-icon {
    width: 42px;
    height: 42px;
    border-radius: 15px;
    color: var(--brand);
    background: rgba(99, 102, 241, 0.12);
}

.settings-card strong,
.settings-card small {
    display: block;
}

.settings-card strong {
    font-weight: 850;
}

.settings-card small {
    margin-top: 3px;
    color: var(--muted);
    font-weight: 650;
}

@media (min-width: 840px) {
    .modal-backdrop {
        place-items: center;
    }
}

@media (max-width: 1024px) {
    .app-shell {
        width: min(100% - 24px, 860px);
    }

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

    .summary-rail {
        display: none;
    }

    .mobile-summary {
        display: grid;
        grid-template-columns: 1.5fr 0.75fr 0.75fr;
        gap: 10px;
    }

    .mobile-total-card,
    .mobile-mini-card {
        display: grid;
        gap: 5px;
        min-height: 92px;
        align-content: center;
        padding: 16px;
        border-radius: 22px;
    }

    .mobile-total-card span,
    .mobile-mini-card span {
        color: var(--muted);
        font-size: 0.72rem;
        font-weight: 850;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .mobile-total-card strong,
    .mobile-mini-card strong {
        font-size: 1.35rem;
        font-weight: 900;
        letter-spacing: -0.05em;
        font-variant-numeric: tabular-nums;
    }

    .mobile-mini-card strong {
        font-size: 1.8rem;
    }

    .toolbar-panel {
        top: 80px;
    }

    .fab {
        display: grid;
    }
}

@media (max-width: 720px) {
    body {
        background:
            radial-gradient(circle at 80% -10%, rgba(99, 102, 241, 0.22), transparent 22rem),
            var(--bg);
    }

    .app-shell {
        width: 100%;
        padding: 10px 12px 92px;
    }

    .site-header {
        padding: 10px 0 12px;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
        border-radius: 16px;
    }

    .brand-title {
        font-size: 1.2rem;
    }

    .brand-subtitle {
        display: none;
    }

    .icon-button {
        width: 41px;
        height: 41px;
        border-radius: 15px;
    }

    .mobile-summary {
        grid-template-columns: 1fr 1fr;
    }

    .mobile-total-card {
        grid-column: 1 / -1;
        min-height: 112px;
        color: white;
        background: linear-gradient(135deg, var(--brand), var(--brand-2));
    }

    .mobile-total-card span {
        color: rgba(255, 255, 255, 0.72);
    }

    .mobile-total-card strong {
        font-size: 2.1rem;
    }

    .toolbar-panel {
        top: 63px;
        padding: 14px;
        border-radius: 24px;
    }

    .toolbar-copy h1 {
        font-size: 1.35rem;
    }

    .toolbar-copy p {
        font-size: 0.82rem;
    }

    .search-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .archive-toggle {
        justify-content: center;
        width: 100%;
    }

    .sub-card {
        padding: 14px;
        border-radius: 24px;
    }

    .sub-card-main {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 12px;
    }

    .sub-icon {
        width: 48px;
        height: 48px;
        border-radius: 17px;
    }

    .sub-price-block {
        grid-column: 1 / -1;
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        max-width: none;
        padding: 12px 12px 0;
        border-top: 1px solid var(--line);
        text-align: left;
    }

    .sub-title-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .sub-title-row h2 {
        width: 100%;
        font-size: 1rem;
    }

    .card-actions {
        justify-content: stretch;
    }

    .ghost-action {
        flex: 1;
        justify-content: center;
        padding: 0 8px;
    }

    .modal-backdrop {
        padding: 10px;
    }

    .modal-panel {
        width: 100%;
        max-height: 90vh;
        border-radius: 26px 26px 0 0;
    }

    .subscription-modal,
    .settings-modal,
    .confirm-modal {
        padding: 16px;
    }

    .form-grid {
        gap: 12px;
    }

    .span-4,
    .span-6 {
        grid-column: 1 / -1;
    }

    .toggles-panel,
    .details-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .app-shell {
        padding-left: 10px;
        padding-right: 10px;
    }

    .mobile-summary {
        gap: 8px;
    }

    .mobile-mini-card {
        min-height: 82px;
    }

    .category-chip {
        font-size: 0.76rem;
        min-height: 38px;
        padding: 0 11px;
    }

    .sub-details {
        display: grid;
        grid-template-columns: 1fr;
    }

    .detail-pill {
        justify-content: center;
    }
}

/* Small utility fallbacks so the page is still tidy before CDN utilities load. */
.hidden { display: none !important; }
.block { display: block; }
.min-w-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-smooth { scroll-behavior: smooth; }

/* --------------------------------------------------------------------------
   Mobile polish pass - fixes narrow viewport overflow and makes the app truly
   thumb-friendly on iOS/Android screens.
-------------------------------------------------------------------------- */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100svh;
}

.app-shell,
.dashboard-grid,
.content-area,
.toolbar-panel,
.subscription-list,
.mobile-summary,
.sub-card {
    max-width: 100%;
}

@media (max-width: 720px) {
    :root {
        --radius-xl: 24px;
        --shadow: 0 14px 36px rgba(15, 23, 42, 0.09);
    }

    .dark {
        --shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
    }

    body {
        background:
            radial-gradient(circle at 50% -12rem, rgba(99, 102, 241, 0.18), transparent 26rem),
            var(--bg);
    }

    .app-aurora {
        display: none;
    }

    .app-shell {
        width: 100%;
        max-width: 460px;
        margin-inline: auto;
        padding: max(12px, env(safe-area-inset-top)) 14px calc(104px + env(safe-area-inset-bottom));
    }

    .site-header {
        position: relative;
        top: auto;
        z-index: 10;
        padding: 8px 0 14px;
        backdrop-filter: none;
    }

    .brand-link {
        min-width: 0;
        gap: 10px;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
        border-radius: 15px;
        box-shadow: 0 12px 26px rgba(79, 70, 229, 0.28);
    }

    .brand-mark svg {
        width: 21px;
        height: 21px;
    }

    .brand-title {
        max-width: 45vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1.12rem;
        letter-spacing: -0.045em;
    }

    .header-actions {
        gap: 7px;
        flex: 0 0 auto;
    }

    .icon-button {
        width: 40px;
        height: 40px;
        border-radius: 15px;
        background: rgba(15, 23, 42, 0.045);
    }

    .dark .icon-button {
        background: rgba(15, 23, 42, 0.72);
    }

    .mobile-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .mobile-total-card,
    .mobile-mini-card,
    .toolbar-panel,
    .sub-card {
        box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
        backdrop-filter: none;
    }

    .dark .mobile-total-card,
    .dark .mobile-mini-card,
    .dark .toolbar-panel,
    .dark .sub-card {
        box-shadow: 0 14px 42px rgba(0, 0, 0, 0.24);
    }

    .mobile-total-card {
        grid-column: 1 / -1;
        min-height: 96px;
        padding: 18px;
        border-radius: 24px;
    }

    .mobile-total-card strong {
        max-width: 100%;
        overflow-wrap: anywhere;
        font-size: clamp(2rem, 9vw, 2.45rem);
        line-height: 0.98;
    }

    .mobile-mini-card {
        min-height: 74px;
        padding: 14px;
        border-radius: 20px;
    }

    .mobile-mini-card strong {
        font-size: 1.55rem;
    }

    .toolbar-panel {
        position: relative;
        top: auto;
        z-index: 1;
        padding: 14px;
        border-radius: 24px;
    }

    .toolbar-copy {
        margin-bottom: 12px;
    }

    .toolbar-copy h1 {
        font-size: 1.28rem;
        line-height: 1.05;
    }

    .toolbar-copy p {
        max-width: 32ch;
        font-size: 0.8rem;
        line-height: 1.45;
    }

    .search-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
    }

    .search-box {
        min-height: 46px;
        padding: 0 12px;
        border-radius: 16px;
    }

    .search-box input {
        font-size: 16px;
        font-weight: 700;
    }

    .archive-toggle {
        width: 46px;
        min-width: 46px;
        min-height: 46px;
        justify-content: center;
        padding: 0;
        border-radius: 16px;
    }

    .archive-toggle span {
        display: none;
    }

    .category-strip {
        gap: 8px;
        margin: 12px -14px 0;
        padding: 0 14px 3px;
        scroll-padding-inline: 14px;
    }

    .category-chip {
        min-height: 38px;
        padding: 0 12px;
        border-radius: 15px;
        font-size: 0.75rem;
    }

    .category-chip:first-child {
        scroll-snap-align: start;
    }

    .subscription-list {
        gap: 12px;
    }

    .sub-card {
        padding: 15px;
        border-radius: 24px;
    }

    .sub-card:hover {
        transform: none;
    }

    .sub-card-main {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        align-items: start;
        gap: 12px;
    }

    .sub-icon {
        width: 48px;
        height: 48px;
        border-radius: 17px;
    }

    .sub-icon svg,
    .next-payment-icon svg {
        width: 22px;
        height: 22px;
    }

    .sub-title-row {
        flex-direction: row;
        align-items: flex-start;
        gap: 7px;
    }

    .sub-title-row h2 {
        width: auto;
        font-size: 1rem;
        line-height: 1.18;
    }

    .status-pill {
        padding: 5px 7px;
        font-size: 0.64rem;
    }

    .sub-plan {
        margin-top: 5px;
        font-size: 0.84rem;
    }

    .sub-meta-line {
        gap: 5px;
        font-size: 0.74rem;
        line-height: 1.35;
    }

    .sub-price-block {
        grid-column: 2 / -1;
        display: block;
        max-width: 100%;
        margin-top: 10px;
        padding: 0;
        border-top: 0;
        text-align: left;
    }

    .sub-price-block strong {
        font-size: 1.22rem;
        line-height: 1.05;
    }

    .sub-price-block span {
        font-size: 0.72rem;
    }

    .sub-details {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 13px;
    }

    .detail-pill {
        justify-content: flex-start;
        min-height: 38px;
        padding: 0 12px;
        border-radius: 14px;
        font-size: 0.76rem;
    }

    .notice {
        justify-content: flex-start;
        margin-top: 12px;
        padding: 10px 12px;
        border-radius: 14px;
        font-size: 0.76rem;
        line-height: 1.35;
        text-align: left;
    }

    .card-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-top: 14px;
        padding-top: 12px;
    }

    .ghost-action {
        min-height: 42px;
        justify-content: center;
        padding: 0 6px;
        border-radius: 14px;
        background: var(--surface-soft);
        font-size: 0.72rem;
    }

    .ghost-action svg {
        width: 17px;
        height: 17px;
    }

    .fab {
        right: max(16px, env(safe-area-inset-right));
        bottom: calc(82px + env(safe-area-inset-bottom));
        width: 58px;
        height: 58px;
        border-radius: 21px;
        box-shadow: 0 16px 34px rgba(79, 70, 229, 0.36);
    }

    .modal-backdrop {
        place-items: end center;
        padding: 10px 10px max(10px, env(safe-area-inset-bottom));
    }

    .modal-panel {
        max-height: min(88svh, 780px);
        border-radius: 26px 26px 0 0;
    }
}

@media (max-width: 380px) {
    .app-shell {
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand-title {
        max-width: 38vw;
        font-size: 1.05rem;
    }

    .mobile-total-card strong {
        font-size: 1.9rem;
    }

    .category-chip {
        padding: 0 10px;
    }

    .ghost-action span {
        font-size: 0.68rem;
    }
}

/* --------------------------------------------------------------------------
   Hard mobile layout fix
   Applies compact phone layout earlier as a safety net for mobile browsers,
   Safari URL bars, cached tablet breakpoint states, and "desktop width" quirks.
-------------------------------------------------------------------------- */
img,
svg,
video,
canvas {
    max-width: 100%;
}

.app-shell * {
    min-width: 0;
}

@media (max-width: 1024px), (pointer: coarse) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
    }

    @supports not (overflow-x: clip) {
        html,
        body {
            overflow-x: hidden;
        }
    }

    body {
        min-height: 100svh;
        background:
            radial-gradient(circle at 50% -12rem, rgba(99, 102, 241, 0.18), transparent 26rem),
            var(--bg);
    }

    .app-aurora {
        display: none !important;
    }

    .app-shell {
        width: 100%;
        max-width: 480px;
        margin-inline: auto;
        padding: max(12px, env(safe-area-inset-top)) 14px calc(112px + env(safe-area-inset-bottom));
    }

    .dashboard-grid,
    .content-area,
    .subscription-list,
    .toolbar-panel,
    .mobile-summary,
    .empty-state,
    .sub-card {
        width: 100%;
        max-width: 100%;
    }

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

    .summary-rail {
        display: none !important;
    }

    .site-header {
        position: relative;
        top: auto;
        z-index: 10;
        padding: 8px 0 14px;
        backdrop-filter: none;
    }

    .brand-link {
        min-width: 0;
        gap: 10px;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
        border-radius: 15px;
        box-shadow: 0 12px 26px rgba(79, 70, 229, 0.28);
    }

    .brand-mark svg {
        width: 21px;
        height: 21px;
    }

    .brand-title {
        max-width: 46vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1.12rem;
        letter-spacing: -0.045em;
    }

    .brand-subtitle {
        display: none;
    }

    .header-actions {
        flex: 0 0 auto;
        gap: 7px;
    }

    .icon-button {
        width: 40px;
        height: 40px;
        border-radius: 15px;
        background: rgba(15, 23, 42, 0.045);
    }

    .dark .icon-button {
        background: rgba(15, 23, 42, 0.72);
    }

    .mobile-summary {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .mobile-total-card,
    .mobile-mini-card,
    .toolbar-panel,
    .sub-card,
    .empty-state {
        box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
        backdrop-filter: none;
    }

    .dark .mobile-total-card,
    .dark .mobile-mini-card,
    .dark .toolbar-panel,
    .dark .sub-card,
    .dark .empty-state {
        box-shadow: 0 14px 42px rgba(0, 0, 0, 0.24);
    }

    .mobile-total-card {
        grid-column: 1 / -1;
        min-height: 96px;
        padding: 18px;
        border-radius: 24px;
        color: white;
        background: linear-gradient(135deg, var(--brand), var(--brand-2));
    }

    .mobile-total-card span {
        color: rgba(255, 255, 255, 0.72);
    }

    .mobile-total-card strong {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: clamp(2rem, 9vw, 2.45rem);
        line-height: 0.98;
    }

    .mobile-mini-card {
        min-height: 74px;
        padding: 14px;
        border-radius: 20px;
    }

    .mobile-mini-card strong {
        font-size: 1.55rem;
    }

    .toolbar-panel {
        position: relative !important;
        top: auto !important;
        z-index: 1;
        padding: 14px;
        border-radius: 24px;
    }

    .toolbar-copy {
        margin-bottom: 12px;
    }

    .toolbar-copy h1 {
        font-size: 1.28rem;
        line-height: 1.05;
    }

    .toolbar-copy p {
        max-width: 32ch;
        font-size: 0.8rem;
        line-height: 1.45;
    }

    .search-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 46px;
        gap: 8px;
    }

    .search-box {
        min-height: 46px;
        padding: 0 12px;
        border-radius: 16px;
    }

    .search-box input {
        font-size: 16px;
        font-weight: 700;
    }

    .archive-toggle {
        width: 46px;
        min-width: 46px;
        min-height: 46px;
        justify-content: center;
        padding: 0;
        border-radius: 16px;
    }

    .archive-toggle span {
        display: none;
    }

    .category-strip {
        width: auto;
        max-width: none;
        gap: 8px;
        margin: 12px -14px 0;
        padding: 0 14px 3px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scroll-padding-inline: 14px;
    }

    .category-chip {
        flex: 0 0 auto;
        min-height: 38px;
        padding: 0 12px;
        border-radius: 15px;
        font-size: 0.75rem;
    }

    .subscription-list {
        gap: 12px;
    }

    .sub-card {
        padding: 15px;
        border-radius: 24px;
        overflow: hidden;
    }

    .sub-card:hover {
        transform: none;
    }

    .sub-card-main {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        align-items: start;
        gap: 12px;
    }

    .sub-icon {
        width: 48px;
        height: 48px;
        border-radius: 17px;
    }

    .sub-icon svg,
    .next-payment-icon svg {
        width: 22px;
        height: 22px;
    }

    .sub-title-row {
        flex-direction: row;
        align-items: flex-start;
        gap: 7px;
    }

    .sub-title-row h2 {
        width: auto;
        font-size: 1rem;
        line-height: 1.18;
    }

    .status-pill {
        padding: 5px 7px;
        font-size: 0.64rem;
    }

    .sub-plan {
        margin-top: 5px;
        font-size: 0.84rem;
    }

    .sub-meta-line {
        gap: 5px;
        font-size: 0.74rem;
        line-height: 1.35;
    }

    .sub-price-block {
        grid-column: 2 / -1;
        display: block;
        max-width: 100%;
        margin-top: 10px;
        padding: 0;
        border-top: 0;
        text-align: left;
    }

    .sub-price-block strong {
        overflow-wrap: anywhere;
        font-size: 1.22rem;
        line-height: 1.05;
    }

    .sub-price-block span {
        font-size: 0.72rem;
    }

    .sub-details {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 13px;
    }

    .detail-pill {
        justify-content: flex-start;
        min-height: 38px;
        padding: 0 12px;
        border-radius: 14px;
        font-size: 0.76rem;
    }

    .notice {
        justify-content: flex-start;
        margin-top: 12px;
        padding: 10px 12px;
        border-radius: 14px;
        font-size: 0.76rem;
        line-height: 1.35;
        text-align: left;
    }

    .card-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-top: 14px;
        padding-top: 12px;
    }

    .ghost-action {
        min-height: 42px;
        justify-content: center;
        padding: 0 6px;
        border-radius: 14px;
        background: var(--surface-soft);
        font-size: 0.72rem;
    }

    .ghost-action svg {
        width: 17px;
        height: 17px;
    }

    .empty-state {
        justify-items: center;
        padding: 42px 16px 36px;
        overflow: hidden;
    }

    .empty-state h2,
    .empty-state p {
        width: 100%;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .empty-state h2 {
        font-size: 1.1rem;
    }

    .empty-state p {
        font-size: 0.88rem;
    }

    .empty-button {
        width: 100%;
        max-width: 260px;
    }

    .fab {
        right: max(16px, env(safe-area-inset-right));
        bottom: calc(82px + env(safe-area-inset-bottom));
        width: 58px;
        height: 58px;
        border-radius: 21px;
        box-shadow: 0 16px 34px rgba(79, 70, 229, 0.36);
    }

    .modal-backdrop {
        place-items: end center;
        padding: 10px 10px max(10px, env(safe-area-inset-bottom));
    }

    .modal-panel {
        width: 100%;
        max-height: min(88svh, 780px);
        border-radius: 26px 26px 0 0;
    }
}

@media (max-width: 380px) {
    .app-shell {
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand-title {
        max-width: 38vw;
        font-size: 1.05rem;
    }

    .mobile-total-card strong {
        font-size: 1.9rem;
    }

    .category-chip {
        padding: 0 10px;
    }

    .ghost-action span {
        font-size: 0.68rem;
    }
}
