/* ── SubsDay-Inspired Theme ── */
:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-hover: #fafafa;
    --border: #e8e8ed;
    --border-light: #f0f0f5;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #aeaeb2;
    --accent: #0071e3;
    --accent-light: #e8f2ff;
    --green: #34c759;
    --green-light: #eafbef;
    --orange: #ff9500;
    --orange-light: #fff5e6;
    --red: #ff3b30;
    --red-light: #ffebea;
    --purple: #af52de;
    --purple-light: #f5eafa;
    --pink: #ff2d55;
    --pink-light: #ffe8ed;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Auth Section ── */
.auth-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}

.auth-section::before {
    content: '';
    position: absolute;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0,113,227,0.06) 0%, transparent 70%);
    border-radius: 50%;
}

.auth-section::after {
    content: '';
    position: absolute;
    bottom: -200px;
    left: -100px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(175,82,222,0.05) 0%, transparent 70%);
    border-radius: 50%;
}

.auth-container {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 420px;
    width: 90%;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 18px;
    font-size: 28px;
    color: white;
    font-weight: 700;
    margin-bottom: 28px;
    box-shadow: 0 8px 24px rgba(0,113,227,0.2);
}

.auth-container h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

.auth-container > p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 36px;
    line-height: 1.5;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    margin-bottom: 32px;
}

.auth-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 28px;
}

.auth-feature {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
}

.auth-feature-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.auth-feature-icon.blue { background: var(--accent-light); }
.auth-feature-icon.pink { background: var(--pink-light); }
.auth-feature-icon.purple { background: var(--purple-light); }

.auth-feature-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.auth-feature-text span {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.auth-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-btn:hover {
    background: #005bb5;
    box-shadow: 0 4px 14px rgba(0,113,227,0.3);
}

.auth-footer {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, transform 0.25s ease;
}

/* Collapsed sidebar (desktop) */
.sidebar.collapsed {
    width: 72px;
}

.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .user-details,
.sidebar.collapsed .sidebar-header p {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    padding: 20px 0;
    justify-content: center;
}

.sidebar.collapsed .sidebar-header h2 {
    display: flex;
    justify-content: center;
    width: 100%;
}

.sidebar.collapsed .user-info {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .nav-group-title {
    padding: 12px 0 6px;
    text-align: center;
    min-height: 8px;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .nav-icon {
    margin-right: 0;
}

.sidebar.collapsed .sign-out-btn {
    margin: 16px 12px;
    width: calc(100% - 24px);
    padding: 10px 0;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .sign-out-btn .nav-icon {
    margin-right: 0;
}

/* Overlay (mobile only) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* Toggle button in top bar */
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.sidebar-toggle-icon,
.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-toggle-icon {
    position: relative;
}

.sidebar-toggle-icon::before,
.sidebar-toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
}

.sidebar-toggle-icon::before { top: -6px; }
.sidebar-toggle-icon::after  { top: 6px; }

.sidebar-header {
    padding: 28px 24px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-header p {
    display: none;
}

.user-info {
    padding: 16px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #5e5ce6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.user-details h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1px;
}

.user-details p {
    font-size: 11px;
    color: var(--text-tertiary);
}

.nav-menu {
    padding: 8px 12px;
    flex: 1;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 8px;
}

.nav-group-title {
    padding: 16px 12px 8px;
    color: var(--text-tertiary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s ease;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    width: 100%;
    background: none;
}

.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.nav-icon {
    margin-right: 10px;
    font-size: 15px;
    width: 20px;
    text-align: center;
}

.sign-out-btn {
    margin: 16px;
    padding: 10px 14px;
    background: var(--red-light);
    color: var(--red);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    width: calc(100% - 32px);
}

.sign-out-btn:hover {
    background: #ffd5d2;
}

/* ── Main content ── */
.main-content {
    margin-left: 260px;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.main-content.sidebar-collapsed {
    margin-left: 72px;
}

/* ── Top bar ── */
.top-bar {
    background: rgba(245, 245, 247, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: #005bb5;
    box-shadow: 0 2px 8px rgba(0,113,227,0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface);
    color: var(--text-primary);
}

/* ── Content area ── */
.content {
    padding: 24px 32px 48px;
}

/* ── Stats grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: box-shadow 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-title {
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.stat-icon.blue { background: var(--accent-light); }
.stat-icon.green { background: var(--green-light); }
.stat-icon.yellow { background: var(--orange-light); }
.stat-icon.purple { background: var(--purple-light); }
.stat-icon.orange { background: var(--orange-light); }

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-change {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.stat-change.positive { color: var(--green); }
.stat-change.negative { color: var(--red); }

.stat-change-link:hover {
    text-decoration: underline;
    opacity: 0.85;
}

/* ── Cards ── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-content {
    padding: 24px;
}

/* ── Grid layout ── */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    margin-top: 24px;
}

.subscriptions-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    margin-top: 24px;
}

.subscriptions-main { min-height: 100%; }
.subscriptions-sidebar { min-height: 100%; }

.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s ease;
}

.collapsible-header:hover { background: var(--surface-hover); }

.collapse-icon {
    font-size: 14px;
    transition: transform 0.2s ease;
    color: var(--text-tertiary);
}

.collapsed .collapse-icon { transform: rotate(-90deg); }

.collapsible-content {
    transition: max-height 0.3s ease;
    overflow: visible;
}

.collapsible-content.collapsed {
    max-height: 0 !important;
    padding: 0;
    border: none;
    overflow: hidden;
}

/* ── Form styles ── */
.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.15s ease;
    background: var(--surface);
    color: var(--text-primary);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}

/* ── Subscription list ── */
.subscription-list { background: var(--surface); }

.subscription-item {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s ease;
    flex-wrap: wrap;
    gap: 8px 0;
}

.subscription-item:hover { background: var(--surface-hover); }
.subscription-item:last-child { border-bottom: none; }

.service-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    margin-right: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.service-logo { width: 28px; height: 28px; }

.service-letter {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.service-favicon { width: 28px; height: 28px; border-radius: 6px; }

.service-fallback {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.subscription-details { flex: 1; min-width: 0; }

.subscription-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.subscription-price { text-align: right; flex-shrink: 0; }

.subscription-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.subscription-amount {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.subscription-frequency {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.status-badge {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.due-soon {
    background: var(--orange-light);
    color: var(--orange);
}

.status-badge.active {
    background: var(--green-light);
    color: var(--green);
}

.status-badge.overdue {
    background: var(--red-light);
    color: var(--red);
}

.status-badge.upcoming {
    background: var(--purple-light);
    color: var(--purple);
}

.delete-btn {
    background: var(--red-light);
    color: var(--red);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-left: 12px;
}

.delete-btn:hover { background: #ffd5d2; }

.edit-btn {
    background: var(--accent-light);
    color: var(--accent);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-right: 8px;
}

.edit-btn:hover { background: #d0e6ff; }

.subscription-actions {
    position: relative;
    margin-left: 12px;
}

.actions-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-tertiary);
    transition: all 0.15s;
}

.actions-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.actions-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    min-width: 120px;
    overflow: hidden;
}

.actions-menu.open { display: block; }

.actions-menu button {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.15s;
}

.actions-menu button:hover { background: var(--surface-hover); }

.actions-menu button.delete-action { color: var(--red); }
.actions-menu button.delete-action:hover { background: var(--red-light); }

.subscription-item.cancelled {
    opacity: 0.6;
    background: var(--surface-hover) !important;
    border-left: 3px solid var(--red) !important;
}

.subscription-item.cancelled .subscription-name {
    color: var(--text-tertiary) !important;
}

.subscription-item.paused {
    opacity: 0.75;
    background: var(--orange-light) !important;
    border-left: 3px solid var(--orange) !important;
}

.subscription-item.free-trial {
    background: var(--green-light) !important;
    border-left: 3px solid var(--green) !important;
}

.subscription-item.pending-cancellation {
    opacity: 0.8;
    background: var(--orange-light) !important;
    border-left: 3px solid var(--orange) !important;
}

.sub-status-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}
.sub-status-label.paused { background: var(--orange-light); color: var(--orange); }
.sub-status-label.free-trial { background: var(--green-light); color: var(--green); }
.sub-status-label.pending-cancellation { background: var(--orange-light); color: #c27800; }
.sub-status-label.cancelled { background: var(--red-light); color: var(--red); }

/* ── Service selector ── */
.service-selector-wrapper { position: relative; }

.service-selector-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    cursor: text;
    color: var(--text-primary);
}

.service-selector-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}

.service-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    display: none;
}

.service-dropdown.open { display: block; }

.service-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: background 0.15s;
    color: var(--text-primary);
}

.service-dropdown-item:hover, .service-dropdown-item.highlighted {
    background: var(--surface-hover);
}

.service-dropdown-item.add-new {
    border-top: 1px solid var(--border);
    color: var(--accent);
    font-weight: 600;
}

.service-dropdown-item .service-favicon-small {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

/* ── Per-service spending ── */
.service-spending-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.service-spending-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.service-spending-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.service-spending-info span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-spending-amount {
    font-size: 13px;
    font-weight: 600;
    color: var(--green);
    white-space: nowrap;
}

.manage-services-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    width: 100%;
    margin-top: 8px;
    transition: all 0.15s;
}

.manage-services-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.manage-service-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
}

.manage-service-item:last-child { border-bottom: none; }

.manage-service-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.manage-service-name input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.manage-service-actions { display: flex; gap: 6px; }

.manage-service-actions button {
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* ── Date filter bar ── */
.dates-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.dates-filter-btn {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.dates-filter-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.dates-filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.dates-form-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.dates-form-toggle .btn { flex: 1; }

.dates-form-toggle .btn.active {
    background: var(--accent);
    color: white;
}

.dates-form-toggle .btn:not(.active) {
    background: var(--surface-hover);
    color: var(--text-secondary);
}

.date-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.date-type-badge.birthday {
    background: var(--pink-light);
    color: var(--pink);
}

.date-type-badge.anniversary {
    background: var(--purple-light);
    color: var(--purple);
}

/* ── Quick stats ── */
.quick-stats {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
}

.quick-stats h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.quick-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.quick-stat-item:last-child { border-bottom: none; }

.quick-stats-action {
    margin-top: 16px;
    width: 100%;
    font-size: 13px;
}

.quick-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.quick-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 600;
}

.empty-state p { font-size: 14px; }

/* ── Notification ── */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.notification.show { transform: translateX(0); }
.notification.success { border-left: 3px solid var(--green); }
.notification.error { border-left: 3px solid var(--red); }
.notification.info { border-left: 3px solid var(--accent); }

/* ── Modal ── */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show { display: flex; }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.12);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 4px;
    transition: color 0.15s;
}

.close-btn:hover { color: var(--text-primary); }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    /* On mobile, "collapsed" just means hidden; ignore the narrow-rail styling */
    .sidebar.collapsed { width: 260px; }
    .sidebar.collapsed .sidebar-label,
    .sidebar.collapsed .user-details { display: revert; }
    .sidebar.collapsed .sidebar-header p { display: none; }
    .sidebar.collapsed .sidebar-header,
    .sidebar.collapsed .user-info,
    .sidebar.collapsed .nav-item,
    .sidebar.collapsed .sign-out-btn { justify-content: unset; }
    .sidebar.collapsed .sidebar-header { padding: 28px 24px 20px; }
    .sidebar.collapsed .user-info { padding: 16px 16px; }
    .sidebar.collapsed .nav-item { padding: 10px 12px; }
    .sidebar.collapsed .sign-out-btn { margin: 16px; width: calc(100% - 32px); padding: 10px 14px; }
    .sidebar.collapsed .nav-icon { margin-right: 10px; }

    .main-content,
    .main-content.sidebar-collapsed { margin-left: 0; }
    .content-grid { grid-template-columns: 1fr; }
    .subscriptions-layout { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .top-bar { padding: 16px 20px; }
    .content { padding: 16px; }
    .page-title { font-size: 20px; }

    .subscription-item {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .service-avatar {
        width: 36px;
        height: 36px;
        margin-right: 12px;
    }

    .subscription-details { flex: 1; min-width: 0; }
    .subscription-name { font-size: 13px; }
    .subscription-meta { font-size: 11px; gap: 4px 8px; }
    .subscription-price { margin-left: auto; }
    .subscription-amount { font-size: 14px; }
    .subscription-actions { margin-left: 8px; }
    .sub-status-label { font-size: 10px; padding: 1px 6px; }
    .status-badge { font-size: 10px; padding: 2px 6px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Year Navigation ── */
.year-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.year-nav-btn {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.year-nav-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

#selectedYear {
    min-width: 45px;
    text-align: center;
    font-weight: 700;
    color: var(--text-primary);
}

/* ── Yearly Archive ── */
.yearly-archive {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.yearly-archive-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.yearly-archive-item:hover {
    background: var(--surface);
    border-color: var(--accent);
}

.yearly-archive-item.selected {
    background: var(--accent-light);
    border-color: var(--accent);
}

.archive-year {
    font-weight: 600;
    color: var(--text-primary);
}

.archive-amount {
    font-weight: 600;
    color: var(--green);
}

.archive-current {
    background: var(--green-light) !important;
    border-color: var(--green) !important;
}

.archive-current .archive-year::after {
    content: ' (Current)';
    font-size: 12px;
    color: var(--green);
    font-weight: normal;
}

/* ── Previous Years View ── */
.yearly-archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.year-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.year-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.year-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.year-card-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.year-card-amount {
    font-size: 18px;
    font-weight: 600;
    color: var(--green);
}

.year-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.year-stat {
    text-align: center;
    padding: 12px;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
}

.year-stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.year-stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Important Dates list ── */
.dates-years-value {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
}

.days-highlight {
    font-weight: 600;
    color: var(--accent);
    font-size: 13px;
}

/* ── Address Book / Contacts ── */
.form-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    margin: 20px 0 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.form-label-hint {
    color: var(--text-tertiary);
    font-weight: 400;
    font-size: 12px;
    margin-left: 4px;
}

.contacts-search-bar {
    margin: 16px 0;
}

.contacts-search-bar input {
    width: 100%;
}

.card-header-count {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.contacts-list {
    display: flex;
    flex-direction: column;
}

/* Let kebab-menu dropdowns escape their card (which uses overflow:hidden for rounded corners).
   The contact-item / subscription-item rows inherit the card's rounded corners via their borders
   only; they have no solid background of their own, so letting overflow be visible on both the
   card and the inner list doesn't bleed past the rounded corners visibly. */
.card:has(> .contacts-list),
.card:has(> .subscription-list) {
    overflow: visible;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    gap: 14px;
    transition: background 0.15s ease;
}

.contact-item:last-child { border-bottom: none; }
.contact-item:hover { background: var(--surface-hover); }

.contact-item.flash-highlight {
    animation: flashHighlight 1.6s ease;
}

@keyframes flashHighlight {
    0%   { background: var(--accent-light); }
    100% { background: transparent; }
}

.subscription-item.flash-highlight {
    animation: flashHighlight 1.6s ease;
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

/* Deterministic colour variants */
.contact-avatar.color-0 { background: linear-gradient(135deg, #0071e3, #5e5ce6); }
.contact-avatar.color-1 { background: linear-gradient(135deg, #ff9500, #ff6b00); }
.contact-avatar.color-2 { background: linear-gradient(135deg, #34c759, #248a3d); }
.contact-avatar.color-3 { background: linear-gradient(135deg, #af52de, #7a36a8); }
.contact-avatar.color-4 { background: linear-gradient(135deg, #ff2d55, #c6205a); }
.contact-avatar.color-5 { background: linear-gradient(135deg, #5ac8fa, #007aff); }

.contact-details {
    flex: 1;
    min-width: 0;
}

.contact-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.contact-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.contact-nickname {
    font-size: 13px;
    color: var(--text-tertiary);
    font-style: italic;
}

.contact-badge {
    font-size: 12px;
    opacity: 0.8;
}

.contact-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 3px;
    word-break: break-word;
}

.contact-meta-muted { color: var(--text-tertiary); }

.contact-link {
    color: var(--accent);
    text-decoration: none;
}

.contact-link:hover { text-decoration: underline; }

/* Clickable birthday name that's linked to a contact */
.contact-link-name {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s ease;
    cursor: pointer;
}

.contact-link-name:hover {
    border-bottom-color: var(--accent);
}

.contact-linked-chip {
    font-size: 11px;
    opacity: 0.8;
    cursor: help;
}

.edit-contact-link-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface-hover);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.edit-contact-link-row > span { flex: 1; }

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

@media (max-width: 768px) {
    .contact-item { padding: 12px 16px; }
    .contact-avatar { width: 38px; height: 38px; font-size: 13px; }
    .contact-name { font-size: 14px; }
    .contact-meta { font-size: 11px; }
}
