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

body {
    font-family: Calibri, 'Segoe UI', Arial, sans-serif;
    background-color: #e7e6e6;
    padding: 0;
}

.container {
    max-width: fit-content;
    margin: 0;
    background: white;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    border: 1px solid #d4d4d4;
}

.container.kpis-visible {
    max-width: fit-content;
}

.header {
    background: linear-gradient(to bottom, #217346 0%, #1e6f42 100%);
    color: white;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #0e5c33;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-container {
    overflow-x: auto;
}

table {
    width: max-content;
    border-collapse: collapse;
    background: white;
}

th {
    background: linear-gradient(to bottom, #f2f2f2 0%, #e5e5e5 100%);
    padding: 6px 8px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    border: 1px solid #d4d4d4;
    border-top: none;
    white-space: nowrap;
    color: #333;
}

th.toggle {
    cursor: pointer;
    user-select: none;
    font-weight: 700;
}

th.toggle:hover {
    background: linear-gradient(to bottom, #e5e5e5 0%, #d4d4d4 100%);
}

th.clickable {
    cursor: pointer;
}

th.clickable:hover {
    background: linear-gradient(to bottom, #e5e5e5 0%, #d4d4d4 100%);
}

.kpi-column {
    display: none;
}

.kpi-column.visible {
    display: table-cell;
}

td {
    padding: 4px 8px;
    border: 1px solid #d4d4d4;
    font-size: 11px;
    white-space: nowrap;
    background: white;
}

tr:hover td {
    background-color: #fff9e6;
}

input {
    width: 80px;
    padding: 2px 4px;
    border: none;
    border-radius: 0;
    font-size: 11px;
    font-family: Calibri, 'Segoe UI', Arial, sans-serif;
    text-align: right;
    background: transparent;
}

input:focus {
    outline: 2px solid #217346;
    border-color: #4CAF50;
}

.date-input {
    text-align: left;
}

.net-worth {
    font-weight: 700;
    color: #217346;
}

.change-positive {
    color: #217346;
    font-weight: 600;
}

.change-negative {
    color: #c00000;
    font-weight: 600;
}

.controls {
    padding: 8px;
    border-top: 1px solid #d4d4d4;
    background: linear-gradient(to bottom, #f2f2f2 0%, #e5e5e5 100%);
    display: flex;
    gap: 6px;
}

button {
    padding: 5px 12px;
    border: 1px solid #adadad;
    border-radius: 0;
    font-size: 11px;
    cursor: pointer;
    font-weight: 400;
    background: linear-gradient(to bottom, #fafafa 0%, #e5e5e5 100%);
    color: #333;
}

button:hover {
    background: linear-gradient(to bottom, #e5e5e5 0%, #d4d4d4 100%);
    border-color: #969696;
}

button:active {
    background: #d4d4d4;
}

.add-btn {
    background: linear-gradient(to bottom, #217346 0%, #1e6f42 100%);
    color: white;
    border-color: #0e5c33;
}

.add-btn:hover {
    background: linear-gradient(to bottom, #1e6f42 0%, #1a6139 100%);
}

.demo-badge {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.5);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 3px 7px;
    border-radius: 3px;
}

.share-btn {
    background: transparent;
    color: rgba(255,255,255,0.85);
    border: 1.5px solid rgba(255,255,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    cursor: pointer;
    border-radius: 3px;
}

.share-btn:hover {
    background: rgba(255,255,255,0.12);
    color: white;
    border-color: rgba(255,255,255,0.6);
}

.save-btn {
    background: linear-gradient(to bottom, #217346 0%, #1e6f42 100%);
    color: white;
    border-color: #0e5c33;
}

.save-btn:hover {
    background: linear-gradient(to bottom, #1e6f42 0%, #1a6139 100%);
}

.logout-btn {
    background: linear-gradient(to bottom, #fafafa 0%, #e5e5e5 100%);
    color: #333;
    border-color: #adadad;
}

.logout-btn:hover {
    background: linear-gradient(to bottom, #e5e5e5 0%, #d4d4d4 100%);
}

.status {
    margin-left: auto;
    padding: 4px 10px;
    color: white;
    font-size: 11px;
}

.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 0;
    border: 1px solid #217346;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    text-align: center;
    min-width: 320px;
    width: 90%;
    max-width: 420px;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .login-box {
        padding: 24px;
        min-width: unset;
    }

.login-box input,
    .login-box button {
        font-size: 16px; /* prevents iOS zoom on focus */
    }
}

.login-box h2 {
    margin-bottom: 24px;
    color: #217346;
    font-weight: 600;
    font-size: 20px;
}

.login-logo {
    display: block;
    max-height: min(405px, 40vh);
    max-width: 100%;
    width: auto;
    margin: 0 auto 24px;
    border-radius: 4px;
}

@media (min-width: 481px) {
    .login-logo {
        max-height: min(600px, 55vh);
        width: 420px;
    }
}

.login-box input {
    width: 100%;
    padding: 8px;
    margin-bottom: 16px;
    border: 1px solid #d4d4d4;
    border-radius: 0;
    font-size: 13px;
    text-align: left;
    font-family: Calibri, 'Segoe UI', Arial, sans-serif;
}

.login-box input:focus {
    outline: 2px solid #217346;
    border-color: #217346;
}

.login-box button {
    width: 100%;
    padding: 10px;
    background: linear-gradient(to bottom, #217346 0%, #1e6f42 100%);
    color: white;
    border: 1px solid #0e5c33;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
}

.login-box button:hover {
    background-color: #0b7dda;
}

.login-error {
    color: #c62828;
    margin-top: 10px;
    font-size: 13px;
}

.login-spinner {
    display: none;
    margin-top: 10px;
    font-size: 13px;
    color: #555;
}

.login-spinner::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.logout-btn {
    color: black;
}

.chart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    cursor: pointer;
}

.chart-container {
    position: absolute;
    top: 80px;
    right: 10px;
    background: white;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    max-width: 550px;
    max-height: 370px;
    overflow: auto;
    pointer-events: auto;
}

.chart-container.kpis-open {
    left: 60px;
    right: auto;
}

.chart-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.chart-header h2 {
    margin: 0;
    color: #333;
    font-size: 14px;
}

.chart-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    display: none;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.chart-tooltip.visible {
    display: block;
}

canvas {
    max-width: 520px;
    max-height: 338px;
    cursor: crosshair;
}

th.clickable {
    cursor: pointer;
}

th.clickable:hover {
    background-color: #e3f2fd;
}

td[data-tooltip] {
    position: relative;
}

td[data-tooltip]:not([data-tooltip=""]):hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

td[data-tooltip-sign="positive"]:not([data-tooltip=""]):hover::after {
    color: #00e600;
}

td[data-tooltip-sign="negative"]:not([data-tooltip=""]):hover::after {
    color: #ff073a;
}
