:root {
    --topbar-height: 56px;
    --drawer-width: 280px;
    font-family: "Segoe UI", Roboto, sans-serif;
    color: #0f172a;
    background: #f4f6fb;
}

body {
    margin: 0;
    background: #f4f6fb;
}

body.auth-page {
    min-height: 100vh;
    background: radial-gradient(circle at top, #0b5fff 0%, #0f172a 55%, #020617 100%);
    color: #e2e8f0;
}

.topbar {
    background: #0a3b8f;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 1rem;
    height: var(--topbar-height);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
    position: sticky;
    top: 0;
    z-index: 210;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.nav-logo {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.35rem 0.15rem 0;
}

.nav-logo img {
    height: 24px;
    display: block;
}

.nav-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    padding: 0.35rem 0.55rem;
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.nav-menu-toggle .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

.topbar a {
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    margin-right: 0;
    padding: 0.35rem 0.55rem;
    border-radius: 10px;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    background: transparent;
    border: none;
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
}

.nav-dropdown-toggle:focus {
    outline: none;
    text-decoration: underline;
}

.nav-active {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    margin-top: 0.5rem;
    right: 0;
    background: #0f172a;
    border-radius: 12px;
    padding: 0.75rem 0.25rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
    min-width: 220px;
    display: none;
    flex-direction: column;
    z-index: 20;
}

.nav-dropdown-menu::before {
    content: "";
    position: absolute;
    top: -0.5rem;
    left: 0;
    right: 0;
    height: 0.5rem;
}

.nav-dropdown-menu a {
    margin: 0;
    padding: 0.65rem 1.25rem;
    display: block;
    color: white;
    font-weight: 500;
}

.nav-dropdown-menu a:hover {
    background: rgba(148, 163, 184, 0.2);
}

.nav-submenu {
    padding: 0.25rem 0.25rem 0.5rem 0.25rem;
}
.nav-submenu-label {
    padding: 0.35rem 1.25rem;
    font-weight: 700;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.nav-submenu a {
    padding-left: 2.25rem;
}

.nav-divider {
    height: 1px;
    background: rgba(148, 163, 184, 0.35);
    margin: 0.5rem 0.75rem;
}

.nav-privacy-toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.6rem 0.9rem;
    color: white;
    cursor: pointer;
}

.nav-privacy-toggle input {
    margin-top: 0.2rem;
    transform: translateY(2px);
}

.nav-privacy-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nav-privacy-label {
    font-weight: 700;
}

.nav-privacy-subtext {
    color: rgba(226, 232, 240, 0.8);
    font-size: 0.85rem;
    line-height: 1.3;
}

.privacy-indicator {
    background: rgba(255, 255, 255, 0.18);
    color: #f8fafc;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.privacy-indicator.on {
    background: #22c55e;
    color: #0f172a;
}

.nav-refresh {
    background: rgba(255, 255, 255, 0.18);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
}

.nav-refresh.loading {
    opacity: 0.7;
}

.nav-refresh-status {
    color: #e2e8f0;
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: flex;
}

.app-body {
    position: relative;
    background: #f4f6fb;
}

body.drawer-open {
    overflow: hidden;
}

/* Drawer fallback when Tailwind CDN isn't active. */
.no-tailwind #side-nav {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    height: calc(100vh - var(--topbar-height));
    width: min(320px, 90vw);
    background: linear-gradient(to bottom, #0f172a, #0a3b8f);
    color: #f8fafc;
    transform: translateX(-105%);
    transition: transform 200ms ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding-bottom: 1.25rem;
    box-shadow: 0 24px 50px rgba(15, 23, 42, 0.35);
}

body.no-tailwind.drawer-open #side-nav {
    transform: translateX(0);
}

.no-tailwind [data-nav-overlay] {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 180;
}

body.no-tailwind.drawer-open [data-nav-overlay] {
    opacity: 1;
    pointer-events: auto;
}

.no-tailwind #side-nav [role="navigation"] {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.no-tailwind #side-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
    font-weight: 700;
}

.no-tailwind #side-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
}

.no-tailwind [data-nav-group-toggle] i {
    transition: transform 160ms ease;
}

.no-tailwind [data-nav-group-toggle][aria-expanded="true"] i {
    transform: rotate(180deg);
}

.app-main {
    min-height: calc(100vh - var(--topbar-height));
    padding: 1rem 0 2.5rem;
}

body.drawer-open {
    overflow: hidden;
}

.tab-header {
    display: inline-flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    border: 1px solid #cbd5e1;
    background: white;
    color: #0f172a;
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.tab-btn.active {
    background: #0a3b8f;
    color: #fff;
    border-color: #0a3b8f;
    box-shadow: 0 10px 24px rgba(10, 59, 143, 0.25);
}

.tab-panel.hidden {
    display: none;
}

.fund-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.8rem;
}

.fund-status.ignored {
    background: #fef2f2;
    color: #b91c1c;
}

.fund-status.ok {
    background: #ecfeff;
    color: #0e7490;
}

.fund-status.warning {
    background: #fff7ed;
    color: #c2410c;
}

.funds-table td:first-child,
.funds-table th:first-child {
    text-align: center;
}
.nav-dropdown .chevron {
    font-size: 0.8rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon-left {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.layout {
    max-width: 90vw;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 960px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2.5rem;
    align-items: center;
}

.auth-intro h1 {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.auth-intro p {
    color: rgba(226, 232, 240, 0.85);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 420px;
}

.auth-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 2.25rem;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.35);
    color: #0f172a;
    max-width: 420px;
    width: 100%;
}

.auth-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.auth-card-header h2 {
    margin: 0;
}

.auth-card-header p {
    margin: 0.15rem 0 0;
    color: #64748b;
    font-size: 0.9rem;
}

.logo-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: #0b5fff;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: 0 10px 25px rgba(11, 95, 255, 0.35);
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-field label {
    font-weight: 600;
    color: #0f172a;
    display: block;
    margin-bottom: 0.35rem;
}

.form-field .input {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    border: 1px solid #cbd5f5;
    background: #f8fafc;
    font-size: 1rem;
    transition: border 0.2s, box-shadow 0.2s;
}

.form-field .input:focus {
    outline: none;
    border-color: #0b5fff;
    box-shadow: 0 0 0 3px rgba(11, 95, 255, 0.15);
}

/* Generic styled inputs (shared outside auth forms) */
input.input,
.input {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    border: 1px solid #cbd5f5;
    background: #f8fafc;
    font-size: 1rem;
    transition: border 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

input.input:focus,
.input:focus {
    outline: none;
    border-color: #0b5fff;
    box-shadow: 0 0 0 3px rgba(11, 95, 255, 0.15);
}

.form-field.checkbox {
    display: flex;
    align-items: center;
    margin-top: 0.25rem;
}

.form-field.checkbox label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-weight: 500;
    color: #475569;
}

.form-field .error {
    color: #b91c1c;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.link--muted {
    color: #94a3b8;
    font-size: 0.85rem;
    text-decoration: none;
}

.link--muted:hover {
    color: #0b5fff;
}

.form-actions .button.primary {
    width: 100%;
    background: #0b5fff;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.9rem;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 12px 25px rgba(11, 95, 255, 0.35);
}

.form-actions .button.primary:hover {
    background: #0047d3;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: linear-gradient(165deg, #ffffff, #f1f5ff);
    border-radius: 16px;
    padding: 1.25rem 1rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    text-align: center;
    border: 1px solid #e2e8f0;
}

.kpi-label {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #475569;
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.kpi-subvalue {
    margin-top: 0.25rem;
    font-size: 1rem;
    font-weight: 700;
}

.kpi-subtext {
    margin-top: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #b91c1c;
}

.cell-theme-cash {
    background: #fee2e2 !important;
    color: #991b1b !important;
    font-weight: 700;
}

.card h3 {
    margin-top: 0;
    font-size: 0.95rem;
    color: #64748b;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.card .value {
    font-size: 1.8rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.flash {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.flash.success {
    background: #ecfdf3;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.flash.error {
    background: #fff5f5;
    color: #842029;
    border: 1px solid #f5c2c7;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th, td {
    padding: 0.5rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

th {
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #475569;
}

.classification-header th {
    vertical-align: bottom;
}

.table-header-control {
    text-transform: none;
    font-size: 0.85rem;
}

.table-header-control .header-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #475569;
}

.classification-sort {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #0f172a;
    padding: 0.15rem;
    border-radius: 4px;
}

.classification-sort::after {
    content: "↕";
    font-size: 0.85rem;
}

.classification-sort[data-direction="asc"]::after {
    content: "▲";
}

.classification-sort[data-direction="desc"]::after {
    content: "▼";
}

.classification-filter {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid #cbd5f5;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #0f172a;
    background: #fff;
}

.classification-filter:focus {
    outline: 2px solid #0b5fff;
    outline-offset: 1px;
}

.table-compact td {
    font-size: 0.85rem;
}

.classification-table select {
    width: 100%;
    min-width: 180px;
}

.classification-row-dirty td {
    background: #fff7ed;
}

.inline-status {
    min-height: 1.25rem;
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 0.25rem;
}

.inline-status.status-error {
    color: #b91c1c;
}

.inline-status.error {
    color: #b91c1c;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.status-badge.status-completed {
    background: #dcfce7;
    color: #166534;
}

.status-badge.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.status-unsaved {
    box-shadow: 0 0 0 1px #ea580c inset;
}

.gain-positive {
    color: #15803d;
    font-weight: 600;
}

.gain-negative {
    color: #b91c1c;
    font-weight: 600;
}

.gain-neutral {
    color: #475569;
}

form.inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

input[type="text"],
select {
    padding: 0.45rem 0.65rem;
    border: 1px solid #cbd5f5;
    border-radius: 6px;
    font-size: 0.9rem;
}

button,
.btn {
    border: none;
    border-radius: 999px;
    background: #0b5fff;
    color: white;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn.secondary {
    background: transparent;
    border: 1px solid #cbd5f5;
    color: #0f172a;
}

.chart-wide {
    margin-top: 1.5rem;
}

.breakdown-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.breakdown-pair .card {
    min-height: 320px;
}

.treemap-card {
    margin-top: 1.5rem;
    min-height: 360px;
}

#theme-treemap {
    width: 100%;
    max-height: 400px;
    min-height: 280px;
}

.sub-asset-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sub-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #475569;
}

.btn-compact {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.pie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.pie-grid .card {
    min-height: 320px;
}

.pie-grid canvas {
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
    display: block;
}

.pie-toolbar {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: #475569;
}

.pie-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
}

.pie-toolbar input[type="radio"] {
    accent-color: #0b5fff;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.column-picker {
    position: relative;
    background: #f8fafc;
    border: 1px solid #d0d7e5;
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.column-picker.hidden {
    display: none;
}

.holdings-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.holdings-toolbar .toolbar-title h3 {
    margin: 0 0 0.15rem 0;
}

.holdings-toolbar .toolbar-subtitle {
    color: #475569;
    font-size: 0.9rem;
}

.holdings-toolbar .toolbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.holdings-toolbar .toolbar-field {
    display: inline-flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #475569;
}

.holdings-toolbar .toolbar-field.inline-label {
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
}

.holdings-toolbar select {
    min-width: 180px;
}

.menu {
    position: relative;
}

.menu-toggle {
    font-size: 1.1rem;
    padding: 0.5rem 0.9rem;
    line-height: 1;
}

.menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    background: #fff;
    border: 1px solid #d0d7e5;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
    min-width: 180px;
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.menu-list.hidden {
    display: none;
}

.menu-list button {
    background: transparent;
    border: none;
    text-align: left;
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
    color: #0f172a;
    cursor: pointer;
}

.menu-list button:hover {
    background: #f1f5f9;
}

.holdings-card {
    position: relative;
}

.column-picker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.65rem;
    background: #fff;
    border: 1px solid #d0d7e5;
    border-radius: 8px;
}

.column-picker-row .column-picker-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #334155;
}

.column-picker-row input[type="checkbox"] {
    accent-color: #0b5fff;
}

.column-picker-row .column-picker-move {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.column-picker-row .column-picker-move button {
    border: 1px solid #cbd5f5;
    background: #f8fafc;
    color: #0f172a;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.column-picker-row .column-picker-move button:hover {
    background: #e2e8f0;
}

.holdings-card.fullscreen {
    position: fixed;
    inset: 1rem;
    width: auto;
    max-width: none;
    height: calc(100vh - 2rem);
    overflow: auto;
    z-index: 120;
    margin: 0;
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.28);
}

body.fullscreen-locked {
    overflow: hidden;
}

.modal-header h4 {
    margin: 0;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: min(520px, 90vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

.modal-header,
.modal-footer {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-footer {
    border-top: 1px solid #e2e8f0;
    border-bottom: none;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.modal-body {
    padding: 1rem 1.25rem;
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #475569;
}

.tabulator .tabulator-row.row-dirty {
    border-left: 3px solid #ea580c;
}

.tabulator .tabulator-row.row-dirty .tabulator-cell {
    background: #fff7ed;
}

.tabulator .tabulator-header .tabulator-col {
    text-align: center;
    white-space: normal;
    min-height: 72px;
    height: auto !important;
    padding: 0 0.25rem;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
    height: auto;
    padding: 0.35rem 0.15rem 0.45rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
    white-space: normal;
    line-height: 1.25;
    font-size: 0.85rem;
    text-overflow: clip;
    overflow: visible;
    text-align: center;
}

.tabulator .tabulator-header .tabulator-col .tabulator-header-filter {
    width: 100%;
}

.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input {
    width: 100%;
    text-align: center;
}

.tabulator.wrap-cells .tabulator-cell {
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
}

#holdings-table.tabulator .tabulator-tableHolder,
#holdings-table.tabulator .tabulator-tableholder {
    max-height: none;
    height: auto;
    overflow-y: visible;
    overflow-x: auto;
}


.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.analysis-grid.expanded {
    display: block;
}

.analysis-card {
    position: relative;
    min-height: 320px;
}

.analysis-card.expanded {
    width: 100%;
}

.analysis-card canvas {
    width: 100%;
    height: 260px;
    max-height: 320px;
}

.analysis-card.expanded canvas {
    height: clamp(380px, 60vh, 700px);
    max-height: 700px;
}

.analysis-card .card-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.4rem;
}

.card-actions button {
    background: rgba(15, 23, 42, 0.08);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1rem;
    color: #0f172a;
}

.chart-description {
    display: none;
    margin-top: 0.85rem;
    color: #475569;
    font-size: 0.9rem;
}

.analysis-card.expanded .chart-description {
    display: block;
}

.target-setup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.allocation-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
    flex-wrap: wrap;
}

#allocation-total.over-target {
    color: #b91c1c;
    font-weight: 700;
}

#allocation-remaining.remaining-negative {
    color: #b91c1c;
    font-weight: 700;
}

.row-highlight td {
    background: #eef2ff;
}

.hidden {
    display: none !important;
}

.muted {
    color: #475569;
    font-size: 0.9rem;
}

.subtitle {
    color: #475569;
    margin: 0.25rem 0 0;
}

.lookthrough-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.lookthrough-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lookthrough-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.summary-card {
    background: #f8fafc;
    border: 1px solid #d0d7e5;
    border-radius: 12px;
    padding: 0.85rem;
}

.summary-card .label {
    font-size: 0.9rem;
    color: #475569;
}

.summary-card .value {
    font-size: 1.35rem;
    font-weight: 700;
    margin-top: 0.2rem;
}

.summary-card .subtext {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 0.2rem;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.holding-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.toggle-detail {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
    cursor: pointer;
    font-weight: 700;
    min-width: 2.2rem;
}

.toggle-detail:hover {
    background: #dbeafe;
    border-color: #bfdbfe;
}

.holding-title {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.holding-symbol {
    font-weight: 700;
}

.lookthrough-row td {
    vertical-align: middle;
}

.lookthrough-detail td {
    background: #f8fafc;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.source-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px dashed #e2e8f0;
}

.source-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.source-title {
    font-weight: 600;
}

.source-value {
    font-weight: 700;
    color: #0f172a;
}

.tag-chip-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 16px;
    background: #e2e8f0;
    color: #0f172a;
    font-weight: 700;
}

.tag-chip-remove {
    border: none;
    background: transparent;
    color: #475569;
    font-size: 1rem;
}

.tag-suggestion-grid {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.tag-suggestion {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 14px;
    padding: 0.35rem 0.65rem;
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
}

.tag-suggestion:hover {
    background: #e0e7ff;
}

.tag-input-row {
    display: flex;
    gap: 0.45rem;
    align-items: center;
}

.tags-cell {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: wrap;
}

.tag-option {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    padding: 0.25rem 0.35rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.tag-modal-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#tag-modal .modal-content {
    width: 90vw;
    max-width: 1100px;
}

.tag-selected-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.35rem 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

.tag-selected-label {
    font-weight: 800;
    color: #0f172a;
}

.tag-category-section {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.5rem 0.6rem;
    background: #f8fafc;
}

.tag-category-header {
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.35rem;
}

.tag-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.35rem;
}

.categorization-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.85rem;
}

.cat-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    color: #334155;
    font-weight: 700;
}

.tag-field {
    grid-column: 1 / -1;
}

.summary-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.75rem;
    background: #f8fafc;
}

.summary-label {
    color: #475569;
    font-weight: 700;
}

.summary-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #0f172a;
}

.table-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
}

.table-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.table-scroll {
    max-height: 420px;
    overflow: auto;
}

@media (max-width: 960px) {
    :root {
        --drawer-width: min(320px, 90vw);
    }

    .topbar {
        padding: 0.45rem 0.85rem;
    }

    .nav-logo img {
        height: 22px;
    }

    .nav-right {
        gap: 0.5rem;
    }

    .privacy-indicator {
        font-size: 0.72rem;
        padding: 0.2rem 0.55rem;
    }

    .layout {
        max-width: 100%;
        margin: 1.5rem auto;
        padding: 0 1rem;
    }

    .kpi-grid,
    .card-grid,
    .pie-grid,
    .breakdown-pair {
        grid-template-columns: 1fr;
    }

    .card.chart-wide canvas {
        max-height: none;
    }

    .treemap-card {
        min-height: auto;
    }
}

/* =========================
   Design system overrides
   ========================= */

:root {
    --ui-bg: #f4f6fb;
    --ui-surface: #ffffff;
    --ui-surface-muted: #f8fafc;
    --ui-border: rgba(148, 163, 184, 0.35);
    --ui-border-strong: rgba(148, 163, 184, 0.55);
    --ui-text: #0f172a;
    --ui-muted: #475569;
    --ui-muted-2: #64748b;
    --ui-primary: #0b5fff;
    --ui-primary-hover: #0047d3;
    --ui-danger: #dc2626;
    --ui-danger-hover: #b91c1c;
    --ui-radius: 14px;
    --ui-radius-sm: 10px;
    --ui-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --ui-shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.08);
    --ui-ring: 0 0 0 4px rgba(11, 95, 255, 0.18);
}

body {
    color: var(--ui-text);
    background: var(--ui-bg);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.layout {
    max-width: 1240px;
    margin: 1.5rem auto;
    padding: 0 1.25rem;
}

@media (max-width: 960px) {
    .layout {
        padding: 0 1rem;
        margin: 1.25rem auto;
    }
}

h1, h2, h3, h4 {
    letter-spacing: -0.01em;
}

.muted {
    color: var(--ui-muted);
}

.small {
    font-size: 0.85rem;
}

.inline-status {
    color: var(--ui-muted);
}

.card {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    padding: 1.25rem;
    box-shadow: var(--ui-shadow-sm);
}

.card h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--ui-text);
    text-transform: none;
}

.card h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--ui-text);
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar-field {
    display: inline-flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--ui-muted);
}

.toolbar-field > span {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ui-muted-2);
}

.toolbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

table {
    margin-top: 0.75rem;
}

th, td {
    padding: 0.6rem 0.75rem;
}

th {
    color: var(--ui-muted);
}

button {
    font: inherit;
    color: inherit;
    background: transparent;
    border: none;
    padding: 0;
    appearance: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    height: 38px;
    padding: 0 1rem;
    border-radius: var(--ui-radius-sm);
    border: 1px solid transparent;
    background: var(--ui-primary);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(11, 95, 255, 0.18);
    transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn.primary {
    background: var(--ui-primary);
}

.btn:hover {
    background: var(--ui-primary-hover);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--ui-ring);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn.secondary {
    background: var(--ui-surface);
    border-color: var(--ui-border-strong);
    color: var(--ui-text);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

.btn.secondary:hover {
    background: var(--ui-surface-muted);
}

.btn.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ui-text);
    box-shadow: none;
}

.btn.ghost:hover {
    background: rgba(15, 23, 42, 0.05);
}

.btn.danger {
    background: var(--ui-danger);
    border-color: var(--ui-danger);
    box-shadow: 0 10px 22px rgba(220, 38, 38, 0.16);
}

.btn.danger:hover {
    background: var(--ui-danger-hover);
    border-color: var(--ui-danger-hover);
}

.btn-compact {
    height: 32px;
    padding: 0 0.75rem;
    font-size: 0.85rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: auto;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--ui-border-strong);
    border-radius: var(--ui-radius-sm);
    font-size: 0.95rem;
    background: var(--ui-surface);
    color: var(--ui-text);
}

textarea {
    min-height: 110px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    box-shadow: var(--ui-ring);
    border-color: rgba(11, 95, 255, 0.6);
}

.notes-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.6rem;
    margin-top: 0.75rem;
}

.notes-table th {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ui-muted);
}

.notes-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: none;
    vertical-align: top;
}

.notes-table tbody tr {
    background: var(--ui-surface-muted);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.notes-table tbody tr td:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.notes-table tbody tr td:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Tabulator Group Header Styling */
.tabulator-row.tabulator-group {
    background: #e2e8f0 !important;
    border-bottom: 2px solid #cbd5e1 !important;
    font-weight: 600;
}

.tabulator-row.tabulator-group .tabulator-cell {
    background: #e2e8f0 !important;
}

.tabulator-row.tabulator-group .tabulator-group-toggle {
    margin-right: 8px;
}

.tabulator-row.tabulator-group .group-count {
    color: #64748b;
    font-weight: normal;
    font-size: 0.9em;
    margin-left: 8px;
}

.tabulator-row.tabulator-group .group-subtotal {
    display: inline-block;
    margin-left: 16px;
    padding: 2px 8px;
    background: #f1f5f9;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    color: #0f172a;
}

.tabulator-row.tabulator-group .group-subtotal.gain-positive {
    background: #d1fae5;
    color: #059669;
}

.tabulator-row.tabulator-group .group-subtotal.gain-negative {
    background: #fee2e2;
    color: #dc2626;
}

/* Holdings tabs */
.holdings-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 1rem;
}

.holdings-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s ease;
    position: relative;
    bottom: -2px;
}

.holdings-tab:hover {
    color: #334155;
    background: #f8fafc;
}

.holdings-tab.active {
    color: #0f172a;
    border-bottom-color: #3b82f6;
}

.holdings-tab-content {
    display: none;
}

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

/* Real-time portfolio tabs */
.rt-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 1rem;
}

.rt-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s ease;
    position: relative;
    bottom: -2px;
}

.rt-tab:hover {
    color: #334155;
    background: #f8fafc;
}

.rt-tab.active {
    color: #0f172a;
    border-bottom-color: #3b82f6;
}

.rt-tab-content {
    display: none;
}

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