/* Subscription Tracker — style.css — Premium Finance Dashboard */

:root {
    --bg: #0B1120;
    --bg2: #0F1628;
    --surface: #141E35;
    --surface2: #1A2540;
    --border: #243055;
    --navy: #1E3A5F;
    --emerald: #10B981;
    --emerald2: #6EE7B7;
    --coral: #FB7185;
    --blue: #3B82F6;
    --yellow: #F59E0B;
    --text: #E2E8F0;
    --muted: #475A80;
    --radius: 12px;
}

body.light {
    --bg: #F0F4FF;
    --bg2: #E8EEF9;
    --surface: #fff;
    --surface2: #F5F8FF;
    --border: #CBD5F0;
    --text: #1E2D4B;
    --muted: #6B7FA0;
}

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

html,
body {
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui;
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ──────────────────────────────────────────── */
.app-header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

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

.logo-icon {
    font-size: 1.3rem;
}

h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.logo-badge {
    font-size: 0.58rem;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--emerald);
    border-radius: 4px;
    padding: 1px 7px;
}

.hdr-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Summary cards ───────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 16px 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.sum-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sum-icon {
    font-size: 1.6rem;
}

.sum-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.08em;
}

.sum-val {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 3px;
}

.sum-monthly .sum-val {
    color: var(--coral);
}

.sum-yearly .sum-val {
    color: var(--yellow);
}

.sum-count .sum-val {
    color: var(--blue);
}

.sum-next .sum-val {
    color: var(--emerald);
}

.sum-alert {
    font-size: 0.75rem !important;
}

/* ── Tab nav ─────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 8px 16px;
    border-radius: 8px 8px 0 0;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    color: var(--muted);
    transition: all 0.18s;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--surface);
    border-color: var(--border);
    color: var(--emerald);
}

/* ── List tab ────────────────────────────────────────── */
.list-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.search-input {
    flex: 1;
    min-width: 160px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 0.78rem;
    outline: none;
}

.search-input:focus {
    border-color: var(--emerald);
}

.list-tb-right {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}

.sub-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Subscription card */
.sub-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.18s;
    cursor: pointer;
    position: relative;
}

.sub-card:hover {
    border-color: var(--emerald);
}

.sc-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.sc-logo.streaming {
    background: rgba(251, 113, 133, 0.1);
}

.sc-logo.software {
    background: rgba(59, 130, 246, 0.1);
}

.sc-logo.cloud {
    background: rgba(245, 158, 11, 0.1);
}

.sc-logo.gaming {
    background: rgba(139, 92, 246, 0.1);
}

.sc-logo.fitness {
    background: rgba(16, 185, 129, 0.1);
}

.sc-logo.news {
    background: rgba(99, 102, 241, 0.1);
}

.sc-logo.finance {
    background: rgba(6, 182, 212, 0.1);
}

.sc-logo.other {
    background: rgba(107, 114, 128, 0.1);
}

.sc-info {
    flex: 1;
    min-width: 0;
}

.sc-name {
    font-size: 0.88rem;
    font-weight: 600;
}

.sc-meta {
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 2px;
}

.sc-cost {
    text-align: right;
    flex-shrink: 0;
}

.sc-cost-val {
    font-size: 1rem;
    font-weight: 700;
    color: var(--coral);
}

.sc-cycle {
    font-size: 0.65rem;
    color: var(--muted);
}

.sc-renewal {
    font-size: 0.68rem;
    margin-top: 3px;
}

.renewal-soon {
    color: var(--yellow);
}

.renewal-ok {
    color: var(--emerald);
}

.renewal-past {
    color: var(--coral);
}

.sc-usage-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.usage-high {
    background: var(--emerald);
}

.usage-medium {
    background: var(--yellow);
}

.usage-low {
    background: var(--coral);
}

/* ── Charts ──────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
}

.card-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
}

.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 12px;
}

.pl-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
}

.pl-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.pl-label {
    flex: 1;
    color: var(--muted);
}

.pl-val {
    color: var(--text);
    font-weight: 600;
}

.chart-hint {
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 6px;
}

/* ── Calendar ────────────────────────────────────────── */
.calendar-grid {}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.cal-day-label {
    font-size: 0.62rem;
    text-align: center;
    color: var(--muted);
    font-weight: 600;
    padding: 4px;
}

.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-day {
    min-height: 60px;
    border-radius: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 5px;
    font-size: 0.68rem;
}

.cal-day.today {
    border-color: var(--emerald);
}

.cal-day.other-month {
    opacity: 0.35;
}

.cal-day-num {
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--text);
}

.cal-sub-tag {
    background: rgba(251, 113, 133, 0.15);
    border: 1px solid rgba(251, 113, 133, 0.3);
    color: var(--coral);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 0.6rem;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Tips ────────────────────────────────────────────── */
.tips-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tip-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tip-icon {
    font-size: 1.3rem;
}

.tip-msg {
    font-size: 0.8rem;
    color: var(--text);
    line-height: 1.5;
    flex: 1;
}

.tip-cost {
    font-size: 0.72rem;
    color: var(--coral);
    font-weight: 600;
}

.no-tips {
    color: var(--muted);
    font-size: 0.8rem;
    padding: 20px 0;
    text-align: center;
}

/* ── Modal ───────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.modal-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-hdr h2 {
    font-size: 0.95rem;
    font-weight: 700;
}

.sub-form {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.fg {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fg-full {
    grid-column: span 2;
}

.field-label {
    font-size: 0.63rem;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.06em;
}

.field-input {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 0.78rem;
    outline: none;
    width: 100%;
    font-family: 'Inter', sans-serif;
}

.field-input:focus {
    border-color: var(--emerald);
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
}

/* ── Utilities ───────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.18s;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--emerald);
    color: #0B1120;
    font-weight: 700;
}

.btn-primary:hover {
    background: #059669;
}

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

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--emerald);
}

.btn-danger {
    background: rgba(251, 113, 133, 0.1);
    color: var(--coral);
    border: 1px solid rgba(251, 113, 133, 0.3);
}

.btn-danger:hover {
    background: var(--coral);
    color: #fff;
}

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

.small-select {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 7px;
    padding: 5px 8px;
    font-size: 0.75rem;
    outline: none;
}

.tl {
    font-size: 0.7rem;
    color: var(--muted);
}

.empty-state {
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
    padding: 30px;
}

.hidden {
    display: none !important;
}

#toast-wrap {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 600;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.8rem;
    animation: slide-up .2s ease;
}

.toast.ok {
    border-color: rgba(16, 185, 129, .4);
    color: var(--emerald2);
}

.toast.err {
    border-color: rgba(251, 113, 133, .4);
    color: var(--coral);
}

.toast.warn {
    border-color: rgba(245, 158, 11, .4);
    color: var(--yellow);
}

@keyframes slide-up {
    from {
        transform: translateY(8px);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 700px) {
    .summary-row {
        grid-template-columns: 1fr 1fr;
    }

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

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

    .fg-full {
        grid-column: auto;
    }
}