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

html { -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font-ui);
    font-weight: 400;
    min-height: 100vh;
    padding: 32px 16px 80px;
    background-color: var(--bg);
    background-image: var(--bg-image);
    color: var(--text);
}

.wrap    { max-width: 460px; margin: 0 auto; }
.wrap-lg { max-width: 720px; margin: 0 auto; }

/* ─────────────────────────────────────────
   Nav
───────────────────────────────────────── */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
    position: relative;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex: 1;
}

.nav-brand-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 1.15rem;
    letter-spacing: 0.08em;
    color: var(--text);
    text-decoration: none;
}

.header-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    animation: pulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}

/* Hamburger button */
.nav-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 8px 9px;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.nav-hamburger span {
    display: block;
    width: 100%;
    height: 1.5px;
    background: var(--text-3);
    border-radius: 2px;
    transition: background 0.2s;
}

.nav-hamburger:hover,
.nav-hamburger.open {
    background: var(--glass);
    border-color: var(--glass-border-hover);
}

.nav-hamburger:hover span,
.nav-hamburger.open span {
    background: var(--text);
}

/* Dropdown menu */
.nav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--bg-2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 6px;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    animation: menuOpen 0.15s ease both;
}

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

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

.nav-item {
    display: block;
    padding: 9px 12px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
    letter-spacing: 0.02em;
}

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

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

.nav-item-logout { color: var(--text-3); }

.nav-item-logout:hover {
    color: var(--debit);
    background: var(--debit-dim);
}

.nav-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 6px 0;
}

.nav-group-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 4px 12px 2px;
}

/* ─────────────────────────────────────────
   Page title
───────────────────────────────────────── */
.page-title { margin-bottom: 20px; }

/* ─────────────────────────────────────────
   Budget card
───────────────────────────────────────── */
.budget-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 32px 28px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
    animation: slideUp 0.4s ease both;
}

.budget-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

.budget-label {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 12px;
}

.budget-amount {
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 10vw, 3.4rem);
    line-height: 1;
    color: var(--text);
    letter-spacing: -0.01em;
}

.budget-amount .currency {
    font-family: var(--font-ui);
    font-size: 0.35em;
    font-weight: 300;
    color: var(--text-2);
    vertical-align: super;
    margin-right: 4px;
    letter-spacing: 0.05em;
}

.budget-amount.over { color: var(--debit); }
.budget-amount.over .currency { color: var(--debit); opacity: 0.6; }

.budget-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
}

.budget-date { font-size: 0.72rem; color: var(--text-3); font-weight: 400; }

.budget-badge {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    text-decoration: none;
}

.budget-badge.over {
    background: var(--debit-dim);
    color: var(--debit);
    border-color: var(--debit-border);
}

/* ─────────────────────────────────────────
   Cycle bar
───────────────────────────────────────── */
.cycle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    animation: slideUp 0.3s ease both;
}

/* ─────────────────────────────────────────
   Summary grid
───────────────────────────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
    animation: slideUp 0.4s 0.15s ease both;
}

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

.summary-label {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 6px;
}

.summary-amount {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 500;
}

.summary-amount.credit  { color: var(--credit); }
.summary-amount.debit   { color: var(--debit); }
.summary-amount.neutral { color: var(--text); }

/* ─────────────────────────────────────────
   Form card
───────────────────────────────────────── */
.form-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    backdrop-filter: blur(12px);
    animation: slideUp 0.4s 0.1s ease both;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row { margin-bottom: 12px; }
.form-row.full { grid-column: 1 / -1; }
.form-row:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 7px;
}

.form-remark {
    font-size: 0.72rem;
    color: var(--text-3);
    margin-top: 6px;
    line-height: 1.5;
}

input:not([type="checkbox"]), select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    font-weight: 400;
    padding: 10px 13px;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent);
    -webkit-appearance: checkbox;
    appearance: checkbox;
}

input:not([type="checkbox"]):focus, select:focus {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

input:not([type="checkbox"])::placeholder { color: var(--text-3); }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
    cursor: pointer;
}

select option { background: var(--bg-2); }

.date-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

/* ─────────────────────────────────────────
   Buttons
───────────────────────────────────────── */
.btn-today {
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-family: var(--font-ui);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    padding: 0 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-today:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.btn-submit {
    width: 100%;
    background: var(--accent);
    color: var(--btn-text);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    padding: 13px;
    cursor: pointer;
    margin-top: 14px;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-submit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-submit:active { transform: translateY(0); }

.btn-submit:disabled,
.btn-today:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
}

/* Inline button — section header action */
.btn-inline {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--accent);
    border: 1px solid var(--accent-border);
    background: var(--accent-dim);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-inline:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

/* Icon button — edit pencil / detach / attach */
.btn-icon {
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-size: 0.85rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    text-decoration: none;
}

.btn-icon:hover {
    color: var(--text);
    background: var(--glass);
}

/* ─────────────────────────────────────────
   Section header
───────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    animation: slideUp 0.4s 0.2s ease both;
}

.section-label {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
}

/* ─────────────────────────────────────────
   Transaction list
───────────────────────────────────────── */
.tx-list { display: flex; flex-direction: column; gap: 6px; }

.tx-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: background 0.2s, border-color 0.2s;
    animation: slideUp 0.35s ease both;
}

.tx-item:hover,
.tx-item-link:hover {
    background: var(--glass-hover);
    border-color: var(--glass-border-hover);
}

.tx-item-link {
    text-decoration: none;
    cursor: pointer;
}

.tx-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.tx-icon.debit    { background: var(--debit-dim);  color: var(--debit); }
.tx-icon.credit   { background: var(--credit-dim); color: var(--credit); }
.tx-icon.transfer { background: var(--glass);      color: var(--text-2); border: 1px solid var(--glass-border); }

.tx-body { flex: 1; min-width: 0; }

.tx-desc {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-date { font-size: 0.68rem; color: var(--text-3); margin-top: 2px; }

.tx-amount {
    font-family: var(--font-display);
    font-size: 1rem;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

.tx-amount.debit    { color: var(--debit); }
.tx-amount.credit   { color: var(--credit); }
.tx-amount.transfer { color: var(--text-2); }

.tx-empty {
    text-align: center;
    padding: 32px 0;
    font-size: 0.78rem;
    color: var(--text-3);
}

.tx-empty a {
    color: var(--accent);
    text-decoration: none;
}

/* ─────────────────────────────────────────
   Accounts list
───────────────────────────────────────── */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.account-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: background 0.2s, border-color 0.2s;
    animation: slideUp 0.3s ease both;
}

.account-item:hover {
    background: var(--glass-hover);
    border-color: var(--glass-border-hover);
}

.account-icon {
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.account-body { flex: 1; min-width: 0; }

.account-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-type {
    font-size: 0.68rem;
    color: var(--text-3);
    margin-top: 2px;
    text-transform: capitalize;
}

.account-balance {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--credit);
    white-space: nowrap;
    flex-shrink: 0;
}

.account-balance.negative { color: var(--debit); }

/* ─────────────────────────────────────────
   Obligation item
───────────────────────────────────────── */
.obligation-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 6px;
    transition: background 0.2s, border-color 0.2s;
    animation: slideUp 0.3s ease both;
}

.obligation-item:hover {
    background: var(--glass-hover);
    border-color: var(--glass-border-hover);
}

.obligation-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.obligation-bar {
    height: 3px;
    background: var(--glass-border);
    border-radius: 99px;
    overflow: hidden;
}

.obligation-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 0.4s ease;
}

.obligation-bar-fill.over { background: var(--debit); }

/* ─────────────────────────────────────────
   Auth
───────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 40px 36px;
    backdrop-filter: blur(20px);
    animation: slideUp 0.5s ease both;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

.auth-logo {
    width: 40px;
    height: 40px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    font-size: 1rem;
}

.auth-title {
    font-family: var(--font-display);
    font-size: 1.7rem;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.2;
}

.auth-sub {
    font-size: 0.78rem;
    color: var(--text-3);
    margin-bottom: 32px;
}

.auth-error {
    font-size: 0.75rem;
    color: var(--debit);
    background: var(--debit-dim);
    border: 1px solid var(--debit-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 20px;
}

/* ─────────────────────────────────────────
   Logs (migrate page)
───────────────────────────────────────── */
.logs { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }

.log {
    font-size: 0.75rem;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    font-family: monospace;
}

.log.success { color: var(--credit); background: var(--credit-dim); }
.log.error   { color: var(--debit);  background: var(--debit-dim); }
.log.info    { color: var(--text-2); background: var(--glass); }

/* ─────────────────────────────────────────
   Animations
───────────────────────────────────────── */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

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

.tx-item:nth-child(1) { animation-delay: 0.05s; }
.tx-item:nth-child(2) { animation-delay: 0.10s; }
.tx-item:nth-child(3) { animation-delay: 0.15s; }
.tx-item:nth-child(4) { animation-delay: 0.20s; }
.tx-item:nth-child(5) { animation-delay: 0.25s; }
.tx-item:nth-child(6) { animation-delay: 0.30s; }
.tx-item:nth-child(7) { animation-delay: 0.35s; }
.tx-item:nth-child(8) { animation-delay: 0.40s; }

/* ─────────────────────────────────────────
   Footer
───────────────────────────────────────── */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    font-size: 0.7rem;
    color: var(--text-3);
    letter-spacing: 0.06em;
    border-top: 1px solid var(--glass-border);
    background: var(--bg);
    z-index: 10;
}

.footer-brand {
    font-family: var(--font-display);
    font-weight: 300;
    color: var(--text-2);
}

.footer-sep { opacity: 0.4; }

.footer-tagline { opacity: 0.6; }

/* ─────────────────────────────────────────
   Back button
───────────────────────────────────────── */
.btn-back {
    position: fixed;
    bottom: 52px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: var(--bg-2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 20;
}

.btn-back:hover {
    color: var(--text);
    border-color: var(--glass-border-hover);
    background: var(--glass);
}

/* ─────────────────────────────────────────
   Cycle Read-only banner
───────────────────────────────────────── */
.cycle-readonly-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.75rem;
    color: var(--accent);
    margin-bottom: 16px;
}

.cycle-readonly-banner a {
    color: var(--accent);
    text-decoration: underline;
    font-size: 0.72rem;
    white-space: nowrap;
}

/* ─────────────────────────────────────────
   DBR 7-day chart
───────────────────────────────────────── */
.dbr-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.dbr-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dbr-bar-label {
    width: 42px;
    flex-shrink: 0;
}

.dbr-day {
    font-size: 0.62rem;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.dbr-bar-track {
    flex: 1;
    height: 5px;
    background: var(--glass-border);
    border-radius: 99px;
    overflow: hidden;
}

.dbr-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 0.4s ease;
}

.dbr-bar-fill.over { background: var(--debit); }

.dbr-bar-amount {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-2);
    width: 40px;
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
}

.dbr-bar-amount.ascent { color: var(--credit); }

.dbr-bar-amount.over { color: var(--debit); }

.dbr-total-spent-amount.over { color: var(--debit); }

.dbr-bar-fill.warn  { background: #f97316; }

.dbr-bar-amount.warn { color: #f97316; }