/* === Global Print Hide === */
.print-only { display: none !important; }
.receipt-wrapper { display: none; }

/* ============================================
   Alron Expense Management — Premium Design System
   ============================================ */

/* === CSS Variables === */
:root {
    /* Premium Color Palette (HSL) */
    --h: 245; /* Base Hue */
    --s: 75%; /* Base Saturation */
    
    --bg-primary: hsl(var(--h), 0%, 4%);
    --bg-secondary: hsl(var(--h), 12%, 8%);
    --bg-tertiary: hsl(var(--h), 12%, 12%);
    --bg-elevated: hsl(var(--h), 12%, 15%);
    --bg-hover: hsl(var(--h), 12%, 18%);

    --accent: hsl(var(--h), var(--s), 60%);
    --accent-hover: hsl(var(--h), var(--s), 50%);
    --accent-light: hsla(var(--h), var(--s), 60%, 0.12);
    --accent-glow: hsla(var(--h), var(--s), 60%, 0.25);

    --text-primary: hsl(0, 0%, 98%);
    --text-secondary: hsl(var(--h), 8%, 70%);
    --text-muted: hsl(var(--h), 8%, 50%);

    --green: hsl(142, 70%, 55%);
    --green-bg: hsla(142, 70%, 55%, 0.08);
    --red: hsl(0, 84%, 60%);
    --red-bg: hsla(0, 84%, 60%, 0.08);
    --blue: hsl(217, 91%, 60%);
    --blue-bg: hsla(217, 91%, 60%, 0.08);
    --yellow: hsl(38, 92%, 55%);

    --border: hsla(var(--h), 10%, 20%, 0.5);
    --border-light: hsla(var(--h), 10%, 30%, 0.3);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --shadow-sm: 0 4px 12px hsla(0, 0%, 0%, 0.4);
    --shadow-md: 0 8px 24px hsla(0, 0%, 0%, 0.5);
    --shadow-lg: 0 16px 48px hsla(0, 0%, 0%, 0.6);
    --shadow-glow: 0 0 30px var(--accent-glow);

    --sidebar-width: 280px;
    --header-height: 70px;

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 0% 0%, hsla(var(--h), var(--s), 60%, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, hsla(var(--h), var(--s), 60%, 0.03) 0%, transparent 50%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--accent-hover);
}

/* === Login Page === */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(79, 70, 229, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 24px;
    animation: fadeInUp 0.6s ease;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0.5;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-footer-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 24px;
}

/* === Form Elements === */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.form-group input,
.form-group select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition-fast);
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    white-space: nowrap;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    color: white;
}

.btn-danger {
    background: var(--red);
    color: white;
}
.btn-danger:hover {
    background: #DC2626;
    color: white;
}

.btn-ghost {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-accent {
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid rgba(79, 70, 229, 0.3);
}
.btn-accent:hover {
    background: var(--accent);
    color: white;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
    opacity: 0.6;
}
.icon-btn:hover {
    background: var(--bg-hover);
    opacity: 1;
}
.icon-btn-danger:hover {
    background: var(--red-bg);
}

/* === Alert === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    animation: shake 0.4s ease;
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-slow);
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    font-size: 28px;
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.logout-btn:hover {
    background: var(--red-bg) !important;
    color: var(--red) !important;
}

/* === Mobile Menu === */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px;
}

.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition-fast);
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
}

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
    animation: fadeIn 0.4s ease;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    transition: color var(--transition-fast);
}
.back-link:hover {
    color: var(--accent);
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* === Summary Bar === */
.summary-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.summary-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all var(--transition-normal);
}

.summary-item:hover {
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.summary-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.summary-sales { border-left: 3px solid var(--green); }
.summary-sales .summary-value { color: var(--green); }

.summary-expenses { border-left: 3px solid var(--red); }
.summary-expenses .summary-value { color: var(--red); }

.summary-balance { border-left: 3px solid var(--blue); }
.summary-balance .summary-value { color: var(--blue); }

/* === Sheet Totals (on sheet page) === */
.sheet-totals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.total-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.total-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.total-sales::before { background: linear-gradient(90deg, var(--green), transparent); }
.total-expenses::before { background: linear-gradient(90deg, var(--red), transparent); }
.total-balance::before { background: linear-gradient(90deg, var(--blue), transparent); }

.total-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.total-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.total-sales .total-value { color: var(--green); }
.total-expenses .total-value { color: var(--red); }
.total-balance .total-value { color: var(--blue); }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    animation: fadeInUp 0.5s ease;
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

/* === Sheets Grid === */
.sheets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    animation: fadeInUp 0.5s ease;
}

.sheet-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    animation: fadeInUp 0.5s ease backwards;
    backdrop-filter: blur(10px);
}

.sheet-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow), var(--shadow-lg);
    transform: translateY(-4px) scale(1.01);
}

.sheet-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
}

.sheet-card-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.sheet-card-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.sheet-card:hover .sheet-card-actions {
    opacity: 1;
}

.sheet-card-body {
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.stat-row-highlight {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }

.sheet-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
}

.clickable-amount {
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.clickable-amount:hover {
    background-color: var(--bg-hover);
    text-decoration: underline;
}

.sheet-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: 0.5;
}

.search-box input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px 10px 40px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-group select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* === Data Table (Excel-like) === */
.table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    overflow-y: visible;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    background: var(--bg-tertiary);
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* column widths */
.col-sn { width: 50px; text-align: center; }
.col-date { width: 160px; }
.col-desc { min-width: 200px; }
.col-type { width: 130px; }
.col-amount { width: 150px; }
.col-actions { width: 60px; text-align: center; }

/* Cell inputs for inline editing */
.cell-input {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: all var(--transition-fast);
}

.cell-input:hover {
    border-color: var(--border);
    background: var(--bg-tertiary);
}

.cell-input:focus {
    border-color: var(--accent);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.cell-select {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.cell-select:hover {
    border-color: var(--border);
    background: var(--bg-tertiary);
}

.cell-select:focus {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.type-sale {
    color: var(--green);
}

.type-expense {
    color: var(--red);
}

.amount-input {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Remove number input arrows */
.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.amount-input[type=number] {
    -moz-appearance: textfield;
}

.table-empty {
    text-align: center;
    padding: 60px 24px;
}

.table-empty .empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.table-empty p {
    color: var(--text-muted);
    font-size: 14px;
}

/* === Date Input Styling === */
input[type="date"] {
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
}

/* === Modal === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 500;
    justify-content: center;
    align-items: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal-sm {
    max-width: 380px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.delete-warning {
    font-size: 15px;
    margin-bottom: 8px;
}

.delete-info {
    font-size: 13px;
    color: var(--text-muted);
}

/* === Toast Notification === */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    box-shadow: var(--shadow-md);
    z-index: 600;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.toast-icon {
    color: var(--green);
    font-weight: 600;
}

.toast-message {
    color: var(--text-primary);
}

/* Saving indicator row highlight */
.record-row.saving,
.daily-row.saving {
    opacity: 0.6;
}

.record-row.new-row,
.daily-row.new-row {
    animation: highlightNew 1s ease;
}

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes highlightNew {
    0% { background: var(--accent-light); }
    100% { background: transparent; }
}

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

/* Row deletion animation */
.record-row.deleting,
.monthly-row.deleting {
    animation: rowDelete 0.3s ease forwards;
}

@keyframes rowDelete {
    to { opacity: 0; transform: translateX(-20px); height: 0; overflow: hidden; }
}

/* === Responsive Design === */
@media (max-width: 1024px) {
    .summary-bar,
    .sheet-totals,
    .month-totals-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sheets-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 24px 16px;
        padding-top: 72px;
    }

    .page-header {
        flex-direction: column;
    }

    .page-title {
        font-size: 22px;
    }

    .summary-bar,
    .sheet-totals,
    .month-totals-grid {
        grid-template-columns: 1fr;
    }

    .sheets-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

    .summary-value,
    .total-value {
        font-size: 20px;
    }

    .data-table {
        font-size: 13px;
    }

    .cell-input, .cell-select {
        padding: 6px 8px;
        font-size: 13px;
    }

    .data-table th {
        padding: 10px 8px;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 32px 24px;
    }

    .modal {
        margin: 16px;
    }

    .sheet-card-actions {
        opacity: 1;
    }

    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

/* === Month Totals Grid (4 cards) === */
.month-totals-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.total-monthly-exp::before { background: linear-gradient(90deg, var(--yellow), transparent); }
.total-monthly-exp .total-value { color: var(--yellow); }

.text-orange { color: var(--yellow); }

/* === Section Header === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.section-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* === Daily Row Styles === */
.daily-row.saving { opacity: 0.5; }
.daily-row.weekend-row { background: rgba(79, 70, 229, 0.04); }
.daily-row.weekend-row:hover { background: var(--bg-hover); }

.col-date-lbl { width: 150px; white-space: nowrap; font-size: 13px; color: var(--text-secondary); }
.col-sale-desc { min-width: 160px; }
.col-exp-desc { min-width: 160px; }
.col-sale { width: 130px; }
.col-exp { width: 130px; }
.col-balance { width: 140px; text-align: right; padding-right: 16px !important; }
.col-amt { width: 160px; }

.day-number {
    display: inline-block;
    width: 22px;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 13px;
    text-align: right;
    margin-right: 4px;
}

.day-label {
    display: inline-block;
    width: 30px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
}

.weekend-row .day-label { color: var(--accent); }
.weekend-row .day-number { color: var(--accent); }

.net-balance {
    font-weight: 600;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* Sale/Expense input colors */
.sale-input { color: var(--green) !important; }
.exp-input { color: var(--red) !important; }

/* === Subtotal Row === */
.subtotal-row {
    background: var(--bg-tertiary);
}

.subtotal-row td {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    border-top: 2px solid var(--border-light);
}

.subtotal-label {
    text-align: right;
    color: var(--text-secondary);
}

/* === Monthly Expense Row === */
.monthly-row.new-row { animation: highlightNew 1s ease; }
.monthly-row.deleting { animation: rowDelete 0.3s ease forwards; }

/* === Grand Total Bar === */
.grand-total-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 32px;
    margin-top: 32px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.grand-total-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.grand-total-item span:first-child {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.grand-total-item span:last-child {
    font-size: 20px;
    font-weight: 700;
}

.grand-total-balance span:last-child {
    font-size: 24px;
}

/* === Form Row (side by side fields) === */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* === Toggle Label === */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.toggle-label:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.toggle-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* === Responsive: Month Totals === */
@media (max-width: 1024px) {
    .month-totals-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .grand-total-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 24px;
    }
    .grand-total-item { align-items: center; }
}

@media (max-width: 768px) {
    .month-totals-grid {
        grid-template-columns: 1fr;
    }
    .grand-total-bar {
        flex-direction: column;
        gap: 16px;
    }
    .section-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* === Utility === */
.hidden {
    display: none !important;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* === Tabs Component === */
.tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1px;
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    padding: 10px 16px;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}
.tab-btn:hover {
    color: var(--text-primary);
}
.tab-btn.active {
    color: var(--accent);
}
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
}
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active {
    display: block;
}

/* === Branch Budget === */
.branch-totals-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.total-got::before { background: linear-gradient(90deg, var(--green), transparent); }
.total-got .total-value { color: var(--green); }

.total-spend::before { background: linear-gradient(90deg, var(--red), transparent); }
.total-spend .total-value { color: var(--red); }

.total-left::before { background: linear-gradient(90deg, var(--blue), transparent); }
.total-left .total-value { color: var(--blue); }

.col-branch-date { width: 150px; }
.col-got-desc { min-width: 160px; }
.col-got { width: 130px; }
.col-spend-desc { min-width: 160px; }
.col-spend-col { width: 130px; }
.col-left { width: 140px; text-align: right; padding-right: 16px !important; }

.got-input { color: var(--green) !important; }
.spend-input { color: var(--red) !important; }

.running-left {
    font-weight: 600;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.branch-row.saving { opacity: 0.5; }
.branch-row.new-row { animation: highlightNew 1s ease; }
.branch-row.deleting { animation: rowDelete 0.3s ease forwards; }

/* === Responsive: Branch Totals === */
@media (max-width: 1024px) {
    .branch-totals-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .branch-totals-grid {
        grid-template-columns: 1fr;
    }
}

/* === Print & Receipt Optimization === */
@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    body, html {
        background: #fff !important;
        color: #000 !important;
        padding: 0 !important;
        margin: 0 !important;
        height: 297mm;
        overflow: hidden;
    }

    .sidebar, .print-hide {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    @page {
        size: auto;
        margin: 5mm; 
    }

    .print-only {
        display: block !important;
    }

    #printReceiptContainer {
        width: 100%;
        max-width: 210mm;
        margin: 0 auto;
        page-break-after: avoid;
    }

    .receipt-wrapper {
        display: flex;
        background: #fff;
        padding: 30px;
        border: 3px double #000;
        height: 280mm; /* Perfect fit for A4 (297mm) with 5mm margins */
        flex-direction: column;
        box-sizing: border-box;
        page-break-inside: avoid;
        page-break-after: avoid;
        overflow: hidden;
    }

    /* Dynamic tightening for long lists */
    .receipt-wrapper.receipt-tight {
        padding: 15px;
    }
    .receipt-wrapper.receipt-tight .comp-title { font-size: 24px; }
    .receipt-wrapper.receipt-tight .receipt-table td { font-size: 10px; height: 24px; padding: 2px 4px; }
    .receipt-wrapper.receipt-tight .receipt-table th { font-size: 10px; padding: 4px 2px; }
    .receipt-wrapper.receipt-tight .receipt-footer { margin-top: 10px; padding-top: 10px; }
    .receipt-wrapper.receipt-tight .sig-col p { margin-bottom: 8px; font-size: 11px; }
    .receipt-wrapper.receipt-tight .note-row { margin-top: 8px; }
}

/* Base styles for receipt components (shared with builder) */
#printReceiptContainer {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #000;
}

.comp-title {
    font-size: 32px;
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.receipt-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.receipt-subtitle {
    font-size: 18px;
    font-weight: 700;
}

.branch-display {
    font-size: 16px;
}

.val-line {
    border-bottom: 1px solid #000;
    display: inline-block;
    min-width: 150px;
    padding-left: 8px;
}

.receipt-table-wrapper {
    flex-grow: 1;
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
}

.receipt-table th {
    border: 1px solid #000;
    background: #f0f0f0;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.receipt-table td {
    border: 1px solid #000;
    padding: 6px 4px;
    font-size: 12px;
    height: 32px;
}

.td-name { width: 30%; }
.td-qty { width: 8%; text-align: center; }
.td-sub { width: 11.5%; text-align: center; }
.td-div { width: 1%; background: #000; }

.text-left { text-align: left; padding-left: 8px !important; }
.text-right { text-align: right; padding-right: 8px !important; }
.text-center { text-align: center; }

.grand-total-row td {
    background: #f9f9f9;
    border-top: 3px solid #000 !important;
}

.receipt-footer {
    margin-top: auto; /* Push footer to bottom of A4 page */
    padding-top: 24px;
}

.sig-row {
    display: flex;
    justify-content: space-between;
    gap: 40px;
}

.sig-col {
    flex: 1;
}

.sig-col p {
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: flex-end;
}

.sig-col p span {
    flex-grow: 1;
    margin-left: 8px;
}

.val-long {
    min-width: 120px;
}

.note-row {
    margin-top: 24px;
}

.note-row p {
    display: flex;
    align-items: flex-end;
    font-weight: 600;
}

.note-line {
    flex-grow: 1;
    margin-left: 8px;
}
