:root {
    --bg: #0f1420;
    --panel: #182132;
    --border: #2b3a53;
    --text: #dde7f4;
    --muted: #9ab0cb;
    --accent: #45a6ff;
    --error: #ff7a8a;
    --success: #74e6a7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 15% 0%, #162238 0%, var(--bg) 45%);
}

.app-shell {
    max-width: 1320px;
    margin: 24px auto;
    padding: 0 16px 24px;
}

.app-header h1 {
    margin: 0;
}

.app-header p {
    margin: 6px 0 16px;
    color: var(--muted);
}

.tab-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.inline-label {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
    align-self: center;
}

.app-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0 0 10px;
}

.tab-button,
input,
select,
button {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    font: inherit;
}

.tab-button,
button {
    color: var(--text);
    background: #1d2a41;
    cursor: pointer;
}

.tab-button.is-active {
    border-color: var(--accent);
    background: #1e3859;
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.report-subtab-list {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.report-subtab-button {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #1d2a41;
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
}

.report-subtab-button.is-active {
    border-color: var(--accent);
    background: #1e3859;
}

.report-subtab-panel {
    display: none;
}

.report-subtab-panel.is-active {
    display: block;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

input,
select {
    background: #121c2c;
    color: var(--text);
}

.inline-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.meta-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-top: 8px;
}

.meta-grid > div {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: #121c2c;
}

.button-primary {
    background: #236aa3;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.94rem;
    min-width: 1320px;
}

th,
td {
    border: 1px solid var(--border);
    padding: 9px;
    text-align: left;
}

.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

th {
    color: #b8cae0;
    background: #1f2a3d;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th .sort-indicator {
    margin-left: 6px;
    color: var(--accent);
    font-size: 0.8rem;
}

th .header-filter {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 5px 6px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #121c2c;
    color: var(--text);
    font-size: 0.82rem;
}

.error {
    min-height: 20px;
    margin-top: 10px;
    color: var(--error);
}

.status {
    min-height: 20px;
    margin-bottom: 10px;
    color: var(--success);
}

.amc-chart {
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #121c2c;
    overflow-x: auto;
}

.amc-chart svg {
    width: 100%;
    min-width: 640px;
    height: 260px;
}

.chart-legend {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: 0.86rem;
}

.legend-box {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 2px;
}

.legend-box.invested {
    background: #45a6ff;
}

.legend-box.current {
    background: #8ed0ff;
}

.legend-box.returns {
    background: #4bd37b;
}

.chart-empty {
    color: var(--muted);
    font-size: 0.9rem;
}

.pie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.pie-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #121c2c;
    padding: 10px;
}

.pie-card h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: #b8cae0;
}

.pie-chart {
    min-height: 240px;
}

.pie-chart svg {
    width: 100%;
    height: 210px;
}

.pie-legend {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--muted);
}

.pie-legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.pie-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    margin-right: 6px;
}

@media (max-width: 960px) {
    .card {
        overflow-x: auto;
    }
}

/* Scheme Manager table */
.scheme-manager-table-wrap {
    overflow-x: auto;
}

.scheme-manager-table {
    min-width: 900px;
}

.scheme-code-input {
    width: 90px;
    padding: 5px 7px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #121c2c;
    color: var(--text);
    font-size: 0.88rem;
    font-family: monospace;
}

.apply-scheme-code-btn {
    padding: 5px 10px;
    font-size: 0.84rem;
    border-radius: 6px;
}

.row-status {
    font-size: 0.8rem;
    margin-left: 6px;
}

.row-status.ok    { color: var(--success); }
.row-status.error { color: var(--error);   }
.row-status.busy  { color: var(--muted);   }

/* Comparison table */
.comparison-table {
    min-width: 1000px;
}

/* Report totals summary */
.report-totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.totals-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #121c2c;
}

.totals-card-label {
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 6px;
}

.totals-card-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.delta-positive { color: #4bd37b; }
.delta-negative { color: #ff7a8a; }
.delta-zero     { color: var(--muted); }

/* ── How to Use tab ───────────────────────────────────────────────────── */
.how-to-use-card {
    max-width: 900px;
}

.how-to-steps {
    counter-reset: step-counter;
    list-style: none;
    padding: 0;
    margin: 0 0 4px;
}

.how-to-steps > li {
    counter-increment: step-counter;
    position: relative;
    padding: 16px 16px 16px 60px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #121c2c;
}

.how-to-steps > li::before {
    content: counter(step-counter);
    position: absolute;
    left: 14px;
    top: 14px;
    width: 30px;
    height: 30px;
    background: var(--accent);
    color: #0f1420;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1;
}

.step-heading {
    font-weight: 600;
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.step-body p { margin: 0 0 8px; color: var(--text); line-height: 1.6; }

.step-body ul {
    margin: 0 0 8px;
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.7;
}

.step-body ul li { margin-bottom: 3px; }

.step-tip {
    display: block;
    padding: 8px 12px;
    border-left: 3px solid var(--accent);
    background: #182132;
    border-radius: 0 6px 6px 0;
    color: var(--muted) !important;
    font-size: 0.88rem;
    margin-top: 6px !important;
}

.step-body a, .how-to-section a { color: var(--accent); text-decoration: none; }
.step-body a:hover, .how-to-section a:hover { text-decoration: underline; }

.step-body code, .how-to-section code {
    background: #182132;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.87em;
    color: #8ed0ff;
}

.how-to-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.how-to-section { margin-bottom: 20px; }
.how-to-section h3 { font-size: 1.05rem; margin: 0 0 10px; color: var(--text); }
.how-to-section h4 { font-size: 0.95rem; margin: 16px 0 8px; color: #b8cae0; }

.how-to-section p,
.how-to-section ul { color: var(--muted); line-height: 1.7; margin: 0 0 8px; }
.how-to-section ul { padding-left: 20px; }

.how-to-section ol {
    padding-left: 22px;
    color: var(--muted);
    line-height: 1.8;
}

.how-to-section ol li { margin-bottom: 4px; }

.how-to-table {
    min-width: unset;
    width: 100%;
    margin-top: 10px;
    font-size: 0.9rem;
}

.how-to-table th { background: #1f2a3d; color: #b8cae0; }
.how-to-table td { vertical-align: top; line-height: 1.5; color: var(--muted); }

