/* FinTracker — minimal stylesheet */

/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: #f5f5f5;
    color: #1a1a1a;
}

a { color: #0066cc; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────────────────── */

/* Navbar spans full width but its content is constrained to 1400px — same
   as .container — so they left-align on wide screens. */
.navbar {
    background: #1a1a2e;
    color: #fff;
    padding: 0 24px;
}
.navbar-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 48px;
}
.nav-brand { font-size: 16px; font-weight: 700; color: #fff; }
.nav-links { display: flex; gap: 16px; list-style: none; }
.nav-links a { color: #ccc; font-size: 13px; }
.nav-links a:hover, .nav-links a.active { color: #fff; text-decoration: none; }

.nav-user { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.nav-user span { color: #ccc; font-size: 13px; }
.nav-user a { color: #ccc; font-size: 13px; }
.nav-user a:hover { color: #fff; }

.container { margin: 24px 0; padding: 0 24px; }

/* ── Login page ───────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 32px;
    width: 320px;
}
.login-title { font-size: 20px; text-align: center; margin-bottom: 20px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #555; }
.login-form input { padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
.login-form .btn { margin-top: 6px; }

/* ── Page header ──────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 20px; }
.summary-bar { display: flex; gap: 24px; flex: 1; }
.summary-bar span { font-size: 13px; color: #555; }
.summary-bar strong { color: #1a1a1a; }
.hide-zero-label { font-size: 13px; color: #555; display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.last-refresh { font-size: 12px; color: #888; white-space: nowrap; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}
.btn-primary { background: #0066cc; border-color: #0066cc; color: #fff; }
.btn-primary:hover { background: #0055aa; text-decoration: none; }
.btn-link { background: none; border: none; cursor: pointer; font-size: 14px; padding: 0; }

/* ── Flash messages ───────────────────────────────────────────────────── */
.flash {
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
}
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ── Data table ───────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    border-radius: 6px;
    overflow: clip;   /* clip keeps rounded corners but doesn't break sticky */
    font-size: 12px;
}
.data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f0f0f0;
    padding: 7px 10px;
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
    border-bottom: 1px solid #ddd;
}
.data-table th:first-child { text-align: left; }
.data-table td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}
.data-table td:first-child { text-align: left; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tfoot td { font-weight: 600; background: #f9f9f9; border-top: 1px solid #ddd; }
.data-table .actions { display: flex; gap: 8px; justify-content: flex-end; }
.data-table .empty { text-align: center; color: #888; padding: 24px; }

.total-cell { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.total-cell .total-text { flex: 1; text-align: right; }
.total-cell .edit-total-icon-spacer { width: 16px; flex-shrink: 0; }

/* ── Assets table — center-align everything ──────────────────────────── */
.assets-table th,
.assets-table td,
.assets-table td:first-child,
.assets-table th:first-child {
    text-align: center;
}
.assets-table .group-header td {
    text-align: left;
}
.assets-table .cell-edit,
.assets-table .cell-edit[type="text"],
.assets-table .cell-edit[type="date"],
.assets-table select.cell-edit {
    text-align: center;
}

/* Group header rows in the asset table */
.data-table .group-header td {
    background: #e8ecf0;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    padding: 5px 10px;
    border-top: 2px solid #d0d5da;
}
.group-header-total {
    margin-left: 12px;
    font-weight: 700;
    font-size: 12px;
    color: #333;
    text-transform: none;
    letter-spacing: 0;
}

/* Rebalance row colour coding */
.action-buy  td { background: #fff8e1; }
.action-sell td { background: #fce4ec; }

/* Allocation over/under target */
.over-target  td:last-child { color: #b71c1c; }
.under-target td:last-child { color: #1b5e20; }

/* Net worth delta colouring */
.positive { color: #1b5e20; }
.negative { color: #b71c1c; }

/* Matured deposit — red maturity date */
.matured-date { color: #c00; font-weight: 600; }

.badge-excluded {
    display: inline-block;
    font-size: 10px;
    color: #888;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ── Assets table — inline "Excel-like" cell editing ─────────────────── */
.cell-edit {
    width: 100%;
    min-width: 60px;
    padding: 3px 5px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 12px;
    text-align: right;
    background: transparent;
    font-family: inherit;
    color: inherit;
}
.cell-edit[type="text"],
.cell-edit[type="date"],
select.cell-edit { text-align: left; }
.cell-edit:hover { border-color: #ddd; background: #fff; }
.cell-edit:focus { border-color: #0066cc; background: #fff; outline: none; }

/* Hide number input spinner arrows — free-form typing instead */
.cell-edit[type="number"]::-webkit-outer-spin-button,
.cell-edit[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.cell-edit[type="number"] { -moz-appearance: textfield; }
.cell-edit:disabled { opacity: .5; }

/* Allocation page — Target % input shouldn't stretch the column */
.target-edit { width: 70px; min-width: 0; }

/* RusShares rebalance — Target % input shouldn't stretch the column */
.target-pct { width: 70px; min-width: 0; }

/* ── RusShares rebalance panel ───────────────────────────────────────── */
.rebalance-panel {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
}
.rebalance-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #444;
}
.rebalance-panel input[type="number"] {
    width: 140px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    text-align: right;
}
.rebalance-status { color: #444; }
.status-ok   { color: #1b5e20; font-weight: 600; margin-left: 4px; }
.status-warn { color: #b71c1c; font-weight: 600; margin-left: 4px; }
.leftover-note { color: #b71c1c; font-size: 12px; }

/* ── RusShares inline div editor ─────────────────────────────────────── */
.div-form { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.div-input {
    width: 80px;
    padding: 3px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    text-align: right;
}
.div-input:focus { border-color: #0066cc; outline: none; }
.btn-save {
    padding: 3px 7px;
    font-size: 12px;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
}
.btn-save:hover { background: #c8e6c9; }

/* ── Calendar page ────────────────────────────────────────────────────── */
.cal-caption {
    font-size: 13px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px;
}
.cal-top-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    align-items: flex-start;
}
.cal-panel {
    flex: 1;
    min-width: 0;
}
.cal-panel-wide {
    flex: 2;
}
.cal-cash {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}
.cal-cash-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 14px;
    border-bottom: 1px solid #f0f0f0;
}
.cal-cash-cell:last-child { border-bottom: none; }
.cal-cash-name {
    font-size: 12px;
    color: #555;
}
.cal-cash-amount {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a1a;
}

.todo-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    font-size: 12px;
}
.todo-table th, .todo-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
}
.todo-caption th {
    background: #3f3f46;
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
    text-align: left;
    padding: 8px 10px;
    border-bottom: none;
}
.todo-table thead tr:nth-child(2) th {
    font-size: 11px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.todo-field {
    width: 100%;
    font-size: 12px;
    color: #333;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 3px 5px;
    background: transparent;
    font-family: inherit;
    box-sizing: border-box;
}
.todo-field:hover { border-color: #ddd; background: #f9f9f9; }
.todo-field:focus { border-color: #0066cc; background: #fff; outline: none; }
.todo-field[data-field="amount"],
.todo-field[data-field="due_date"],
.todo-field[data-field="provider"] {
    text-align: center;
}
.cal-todo-row.todo-done .todo-field[data-field="text"],
.cal-todo-row.todo-done .todo-field[data-field="provider"] {
    text-decoration: line-through;
    color: #aaa;
}
.cal-todo-row.todo-overdue .todo-field {
    color: #b71c1c;
    font-weight: 600;
}
.todo-delete {
    color: #b71c1c;
    font-size: 13px;
    padding: 0 2px;
    background: transparent;
    border: none;
    cursor: pointer;
}
.no-spinner::-webkit-outer-spin-button,
.no-spinner::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.no-spinner {
    -moz-appearance: textfield;
}
.todo-add-row input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    box-sizing: border-box;
    font-family: inherit;
}
#todo-new-amount,
#todo-new-due,
#todo-new-provider {
    text-align: center;
}

.cashflow-table th,
.cashflow-table td {
    text-align: center;
}
.cashflow-table th:first-child,
.cashflow-table td:first-child {
    text-align: center;
}
.th-filter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.multiselect {
    position: relative;
}
.multiselect-btn {
    padding: 0 4px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 11px;
    line-height: 1.4;
    font-family: inherit;
    background: transparent;
    cursor: pointer;
    color: #999;
}
.multiselect-btn:hover {
    border-color: #ccc;
    color: #555;
}
.multiselect-btn.filter-active {
    color: #0066cc;
    font-weight: 700;
}
.multiselect-panel {
    display: none;
    position: fixed;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    padding: 6px 10px;
    z-index: 100;
    min-width: 180px;
    max-height: 240px;
    overflow-y: auto;
    text-transform: none;
    font-weight: normal;
    text-align: left;
}
.multiselect-panel.open {
    display: block;
}
.multiselect-panel label {
    display: block;
    font-size: 12px;
    color: #333;
    padding: 2px 0;
    white-space: nowrap;
    font-weight: normal;
}
.multiselect-panel input[type="checkbox"] {
    margin-right: 6px;
}
.ms-search {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    margin-bottom: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
}
.ms-select-all {
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
    margin-bottom: 2px;
    color: #555;
}

.cal-months {
    display: flex;
    gap: 12px;
    margin-bottom: 4px;
}
.cal-month-cell {
    flex: 1;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px 14px;
    text-align: center;
}
.cal-month-name {
    font-size: 11px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}
.cal-month-total {
    font-size: 13px;
    font-weight: 700;
    color: #ccc;
}
.cal-month-total.has-income { color: #1b5e20; }

.event-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.event-dividend { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.event-coupon   { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.event-deposit  { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }

/* ── Type selector ────────────────────────────────────────────────────── */
.type-select-hint { color: #555; margin-bottom: 20px; font-size: 13px; }
.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    max-width: 800px;
}
.type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    color: #1a1a1a;
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s;
}
.type-card:hover { border-color: #0066cc; box-shadow: 0 2px 8px rgba(0,102,204,.15); text-decoration: none; }
.type-card .type-icon { font-size: 28px; }
.type-card strong { font-size: 13px; }
.type-card small { font-size: 11px; color: #777; }

/* ── Asset form ───────────────────────────────────────────────────────── */
.asset-form { max-width: 640px; }
.asset-form fieldset {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 16px;
    margin-bottom: 16px;
}
.asset-form legend { font-weight: 600; padding: 0 6px; }
.asset-form label {
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    color: #444;
}
.asset-form input,
.asset-form select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}
.asset-form small { display: block; margin-top: 4px; color: #888; }
.asset-form .required-mark { color: #c00; font-size: 11px; }

/* Badge shown on fields that will be auto-fetched from an API in a future version */
.auto-fetch-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #e65100;
    background: #fff3e0;
    border: 1px solid #ffcc80;
    border-radius: 3px;
    padding: 1px 5px;
    margin-left: 5px;
    vertical-align: middle;
}

/* Read-only calculated fields — grey background, no interaction */
.calc-field {
    background: #f5f5f5 !important;
    color: #666 !important;
    cursor: default;
}
.calc-note {
    font-size: 12px;
    color: #888;
    margin-top: -4px;
    margin-bottom: 4px;
}
.form-actions { display: flex; gap: 12px; }
