:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --color-primary: #3b82f6;
    --color-success: #10b981;
    --color-danger: #f87171;
    --color-accent: #f59e0b;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.5rem;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

header {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.sheet-manager {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sheet-manager label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    white-space: nowrap;
}

.sheet-manager select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.35rem 1.5rem 0.35rem 0.75rem;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

.btn-sm {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-secondary {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #475569;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0;
    color: #fff;
}

p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    min-width: 100%; /* Allow table to fit screen width */
}

th, td {
    padding: 0.4rem 0.3rem;
    border: 1px solid var(--border-color);
    text-align: right;
    vertical-align: middle;
}

th {
    background-color: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    font-size: 0.75rem;
    white-space: nowrap;
}

.code-badge {
    background-color: #3b82f620;
    color: #60a5fa;
    font-size: 0.65rem;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: bold;
    display: inline-block;
    margin-top: 2px;
}

th.month-col, td.month-col {
    text-align: left;
    font-weight: 600;
    background-color: rgba(15, 23, 42, 0.4);
    width: 85px;
    min-width: 85px;
    white-space: nowrap;
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-container::before {
    content: "$";
    position: absolute;
    left: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    pointer-events: none;
}

td input {
    width: 100%;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    color: #fff;
    font-family: inherit;
    font-size: 0.8rem;
    text-align: right;
    padding: 4px 6px 4px 14px;
    border-radius: 4px;
    outline: none;
    transition: all 0.15s;
}

td input:focus {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

td.editable-calc input {
    border-left: 2px solid var(--color-primary);
}

.status-favorable input {
    background-color: rgba(16, 185, 129, 0.12) !important;
    color: var(--color-success) !important;
    font-weight: 600;
}

.status-payment input {
    background-color: rgba(239, 68, 68, 0.12) !important;
    color: var(--color-danger) !important;
    font-weight: 600;
}

.calc-val {
    color: var(--text-secondary);
    font-weight: 500;
    padding-right: 6px;
    font-variant-numeric: tabular-nums;
}

.highlight-val {
    font-weight: 600;
    color: #fff;
    padding-right: 6px;
}

.totals-row {
    background-color: rgba(15, 23, 42, 0.8);
    font-weight: 700;
}

.totals-row td {
    border-top: 2px solid var(--color-primary);
    color: #fff;
    padding: 0.85rem 0.5rem;
    font-size: 0.85rem;
}

.actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
}

.btn {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn-reset {
    background-color: var(--color-danger);
}

.instructions {
    margin-top: 2rem;
    background: rgba(15, 23, 42, 0.4);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.instructions h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.instructions ul {
    list-style-type: decimal;
    padding-left: 1.25rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Color codes for positive and negative values */
.val-positive {
    color: var(--color-success) !important;
}

.val-negative {
    color: var(--color-danger) !important;
}

/* Dialog / Modal Styling */
dialog.custom-dialog {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    color: var(--text-primary);
    max-width: 400px;
    width: 90%;
    margin: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    outline: none;
}

dialog.custom-dialog::backdrop {
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

dialog.custom-dialog h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #fff;
    font-weight: 600;
}

.dialog-form-group {
    margin-bottom: 1rem;
}

.dialog-form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-align: left;
}

.dialog-form-group input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.5rem;
    border-radius: 6px;
    outline: none;
    text-align: left;
}

.dialog-form-group input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Connection Status Indicator */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 500;
    background: rgba(15, 23, 42, 0.4);
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.status-offline {
    background-color: var(--color-danger);
    box-shadow: 0 0 8px var(--color-danger);
}

.status-dot.status-online {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
    animation: pulse-green 2s infinite;
}

.status-text {
    color: var(--text-secondary);
}

.status-text strong {
    color: #fff;
    font-weight: 600;
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}



