:root {
    --bg: #f6f8fc;
    --bg-alt: #eef3ff;
    --panel: #ffffff;
    --text: #1a2340;
    --muted: #6a7390;
    --line: #dbe3f2;
    --primary: #af503e;
    --primary-strong: #8e3f2f;
    --danger: #d0374f;
    --danger-strong: #aa243a;
    --success: #10b981;
    --radius: clamp(0.75rem, 2vw, 1rem);
    --shadow: 0 clamp(0.375rem, 1vw, 0.75rem) clamp(1rem, 3vw, 1.5rem) rgba(28, 46, 94, 0.08);
    --shadow-login: 0 25px 50px -12px rgba(175, 80, 62, 0.25);
    --spacing-xs: clamp(0.375rem, 1vw, 0.75rem);
    --spacing-sm: clamp(0.75rem, 2vw, 1rem);
    --spacing-md: clamp(1rem, 3vw, 1.5rem);
--spacing-lg: clamp(1.5rem, 4vw, 2rem);
}

 /* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1e;
    --bg-alt: #0f172a;
    --panel: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --line: #334155;
    --sidebar-primary: #8b3e2e;
  }
}

.dark {
  --bg: #0a0f1e;
  --bg-alt: #0f172a;
  --panel: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: #334155;
  --sidebar-primary: #8b3e2e;
}

.dark body {
  background: var(--bg);
  color: var(--text);
}

.dark *,
.dark *::before,
.dark *::after {
  color: var(--text);
}

.dark input,
.dark textarea,
.dark select {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--line);
}

.dark input::placeholder,
.dark textarea::placeholder {
  color: var(--muted) !important;
}

.dark label {
  color: var(--muted);
}

.dark th,
.dark h1, .dark h2, .dark h3, .dark h4 {
  color: var(--text);
}

.dark .nav-btn {
  color: #f1f5f9;
}

.dark .muted {
  color: var(--muted) !important;
}

.dark .sidebar {
  background: linear-gradient(135deg, var(--sidebar-primary), var(--primary));
}

.dark thead {
  background: var(--bg-alt);
}

.dark table {
  background: var(--panel);
}

.dark th {
  color: #e2e8f0;
}

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

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Sora", "Poppins", "Trebuchet MS", sans-serif;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    line-height: 1.6;
    color: var(--text);
    background:
        radial-gradient(clamp(600px, 50vw, 900px) clamp(300px, 30vh, 400px) at -10% -20%, #dce8ff 0%, transparent 55%),
        radial-gradient(clamp(500px, 40vw, 700px) clamp(200px, 25vh, 300px) at 120% 0%, #e4f0ff 0%, transparent 50%),
        var(--bg);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 264px 1fr;
}

.sidebar {
    background: #af503e;
    color: #edf2ff;
    padding: clamp(1rem, 4vw, 1.5rem) clamp(0.875rem, 3vw, 1.25rem);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    border-right: 1px solid rgba(203, 219, 255, 0.2);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.sidebar h2 {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    letter-spacing: 0.4px;
    font-size: 17px;
    font-weight: 700;
}

.sidebar .muted {
    color: #c8d3f8;
    margin: 0 2px 10px;
    font-size: 12px;
}

#main-nav {
    display: grid;
    gap: var(--spacing-xs);
}

.nav-btn {
    border: 1px solid transparent;
    color: #d9e4ff;
    background: transparent;
    border-radius: var(--radius);
    padding: clamp(0.875rem, 3vw, 1rem) clamp(1.25rem, 4vw, 1.5rem);
    min-height: 44px;
    text-align: left;
    font-weight: 500;
    letter-spacing: 0.025em;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-btn i {
    width: 20px;
    flex-shrink: 0;
}

.nav-btn.active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.09);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(203, 219, 255, 0.25);
}

#logout-btn {
    width: 100%;
}

.content {
    padding: clamp(0.875rem, 3vw, 1.5rem);
    min-width: 0;
}

.topbar {
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(20px);
    border-radius: var(--radius);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    display: grid;
    gap: var(--spacing-xs);
    border: 1px solid rgba(255,255,255,0.3);
}

.dark .topbar {
    background: rgba(30,41,59,0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: rgba(51,65,85,0.6);
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.5rem, 5vw, 1.75rem);
    font-weight: 700;
    letter-spacing: 0.025em;
}

#global-message {
    min-height: var(--spacing-sm);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.stats-grid .card {
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(248,250,252,0.7));
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.stats-grid .card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-strong));
}

.dark .stats-grid .card {
    background: linear-gradient(135deg, rgba(30,41,59,0.9), rgba(15,23,42,0.7));
}

.stats-grid .card p {
    margin: var(--spacing-xs) 0 0;
    font-size: clamp(1.5rem, 6vw, 2rem);
    font-weight: 700;
    color: var(--primary-strong);
}

.dark .stats-grid .card p {
    color: #f8fafc;
}

.stat-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    opacity: 0.15;
    color: var(--primary);
}

.dashboard-panels {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 14px;
    align-items: start;
}

.chart-card {
    min-height: 440px;
}

.chart-shell {
    position: relative;
    min-height: 360px;
}

.chart-shell canvas {
    width: 100% !important;
    height: 100% !important;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    padding: clamp(0.875rem, 2.5vw, 1.25rem);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow);
    min-width: 0;
    transition: all 0.3s ease;
}

.dark .card {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(51, 65, 85, 0.5);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
}

.dark .card:hover {
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.sub-card {
    margin-top: 12px;
    background: var(--bg-alt);
}

.card h3,
.card h4 {
    margin: 0 0 var(--spacing-sm);
    font-size: clamp(1.125rem, 3vw, 1.25rem);
    font-weight: 650;
    letter-spacing: 0.025em;
}

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

.table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e2e8f5;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

thead {
    background: #f6f9ff;
}

th,
td {
    border-bottom: 1px solid #e8edf8;
    padding: clamp(0.625rem, 3vw, 0.875rem) clamp(0.5rem, 2.5vw, 0.75rem);
    text-align: left;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    vertical-align: middle;
}

th {
    font-size: clamp(0.6875rem, 1.75vw, 0.75rem);
    font-weight: 700;
    color: #475381;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    background: #f6f9ff;
    z-index: 2;
}

tr:hover td {
    background: #f9fbff;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-sm);
}

.invoice-form-grid {
    gap: var(--spacing-md);
}

.invoice-filter-grid {
    margin-bottom: var(--spacing-md);
}

.form-field {
    display: grid;
    gap: var(--spacing-xs);
}

.form-field.full-row {
    grid-column: 1 / -1;
}

.grid-form textarea {
    min-height: clamp(5rem, 20vh, 8rem);
}

.grid-form .actions-row,
.grid-form .card,
.grid-form button[type="submit"] {
    grid-column: 1 / -1;
}

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

label {
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    color: var(--muted);
    font-weight: 500;
}

input,
textarea,
select,
button {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(0.625rem, 3vw, 0.875rem) clamp(0.75rem, 3.5vw, 1rem);
    font: inherit;
    min-height: 44px;
}

input,
textarea,
select {
    background: #fff;
    color: var(--text);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(175, 80, 62, 0.15);
}

button {
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.025em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(175, 80, 62, 0.3);
}

button:active {
    transform: translateY(0);
}

button:hover {
    filter: brightness(1.04);
}

button:active {
    transform: translateY(1px);
}

button.secondary {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

button.loading {
    pointer-events: none;
    opacity: 0.9;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 0.5rem;
}

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

/* Hero Section */
.login-hero {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.login-hero h1 {
    font-size: clamp(2rem, 6vw, 2.5rem);
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 var(--spacing-xs);
    animation: gradientShift 3s ease-in-out infinite;
}

.login-hero p {
    margin: 0;
    color: var(--muted);
    font-size: 1.1rem;
}

/* Password Toggle */
.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    cursor: pointer;
    color: #334155;
    padding: 0.25rem;
    line-height: 1;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.password-toggle:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

/* Forgot Password */
.forgot-password {
    text-align: right;
    margin-top: var(--spacing-sm);
}

.forgot-password a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.forgot-password a:hover {
    text-decoration: underline;
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes gradientShift {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(10deg); }
}

/* Input Validation States */
.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    width: 20px;
    height: 20px;
}

.input-success .input-icon {
    color: var(--success);
}

.input-error .input-icon {
    color: var(--danger);
}

.has-icon input {
    padding-right: 3rem;
}

button.danger {
    background: linear-gradient(180deg, var(--danger), var(--danger-strong));
}

.invoice-item-row {
    display: grid;
    grid-template-columns: minmax(160px, 2fr) minmax(110px, 0.8fr) minmax(120px, 0.9fr) minmax(110px, 0.8fr) auto;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    align-items: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: var(--panel);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    max-width: 90vw;
    max-height: 90vh;
    width: 500px;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content h4 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.modal-close {
    border: none;
    background: transparent;
    color: #5b688c;
    font-size: 1.75rem;
    line-height: 1;
    padding: 0;
    min-width: auto;
    box-shadow: none;
}

.modal-close:hover {
    background: transparent;
    color: #16388f;
    transform: none;
    box-shadow: none;
}

.modal-content .grid-form {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
}

.modal.hidden {
    display: none;
}

@media (max-width: 600px) {
    .modal-content {
        width: 95vw;
        padding: var(--spacing-md);
    }
}

.invoice-item-row > * {
    min-width: 0;
}

.invoice-item-row input,
.invoice-item-row select {
    background: #ffffff;
}

#add-item-btn {
    min-width: 110px;
    white-space: nowrap;
}

.invoice-item-row select#item-product-unit {
    min-width: 140px;
}

#invoice-items-body td:nth-child(3) {
    font-weight: 600;
    color: #26408b;
}

.hidden {
    display: none !important;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(1200px 520px at -20% -20%, rgba(175, 80, 62, 0.15) 0%, transparent 56%),
        radial-gradient(900px 420px at 120% 100%, rgba(175, 80, 62, 0.08) 0%, transparent 52%),
        var(--bg);
}

    color: inherit;
    cursor: pointer;
.login-wrap {
    width: min(450px, 95vw);
    animation: slideUp 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-login);
    animation: cardFloat 4s ease-in-out infinite;
}

.login-card h1 {
    margin: 0 0 var(--spacing-xs);
}

#login-form,
#register-form {
    display: grid;
    gap: var(--spacing-sm);
}

.error-text {
    color: var(--danger);
    min-height: 22px;
    font-size: 0.875rem;
    margin: var(--spacing-xs) 0;
}

/* Floating Labels */
.form-floating {
    position: relative;
}

.form-floating input,
.form-floating input::placeholder {
    color: var(--text) !important;
    width: 100%;
    opacity: 1 !important;
    padding: 1.25rem 1rem 0.75rem 1rem !important;
    height: auto;
}

.form-floating {
    margin-bottom: var(--spacing-sm);
}

.no-icon .form-floating input,
.has-icon input {
    padding-right: 1rem !important;
}

.has-icon input {
    padding-right: 4rem !important;
}

.form-floating label {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #64748b;
    font-weight: 500;
    font-size: 1rem;
    background: transparent;
}

.form-floating input:focus ~ label,
.form-floating input:not(:placeholder-shown) ~ label {
    top: -0.5rem;
    left: 0.75rem;
    font-size: 0.75rem;
    color: var(--primary);
    background: rgba(255, 255, 255, 0.95);
    padding: 0 0.5rem;
    border-radius: var(--radius);
}

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

@media (max-width: 1160px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1280px) {
    .invoice-item-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .invoice-item-row button {
        grid-column: 1 / -1;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 4;
        border-right: none;
        border-bottom: 1px solid rgba(203, 219, 255, 0.26);
        overflow-x: auto;
    }

    .sidebar h2 {
        min-width: 160px;
        white-space: nowrap;
    }

    .content {
        padding: clamp(0.75rem, 2.5vw, 1rem);
    }

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

    .invoice-item-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
    }

    .invoice-item-row input,
    .invoice-item-row select,
    .invoice-item-row button {
        width: 100%;
    }

    .form-field.full-row {
        grid-column: auto;
    }
}

/* Image Preview Styles */
.image-preview {
    margin-top: 8px;
    padding: 8px;
    background: #f6f9ff;
    border-radius: 8px;
    min-height: 40px;
}

.image-preview img {
    max-width: 150px;
    max-height: 100px;
    border-radius: 6px;
    border: 1px solid #e2e8f5;
}

.form-field input[type="file"] {
    padding: 6px 8px;
    font-size: 13px;
}

/* Company Settings Grid Layout */
.company-settings-grid {
    display: grid;
    grid-template-columns: 70% 30%;
    gap: clamp(1.5rem, 5vw, 2rem);
    align-items: start;
}

.company-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(0.75rem, 2vw, 1rem);
}

.company-form-grid .full-width {
    grid-column: 1 / span 2;
}

.company-left {
    display: flex;
    flex-direction: column;
    gap: clamp(0.75rem, 2vw, 1rem);
}

.company-left .form-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.company-left input,
.company-left textarea {
    width: 100%;
}

.company-left button[type="submit"] {
    margin-top: clamp(0.5rem, 2vw, 1rem);
    width: 100%;
}

.company-right {
    background: #f8fafc;
    padding: clamp(1rem, 3vw, 1.25rem);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: clamp(1rem, 3vw, 1.25rem);
}

.company-right .form-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.company-right input[type="file"] {
    margin-bottom: 0.25rem;
}

.upload-preview {
    background: #f1f5f9;
    border-radius: 6px;
    padding: clamp(0.5rem, 2vw, 0.75rem);
    text-align: center;
    min-height: clamp(3rem, 8vw, 4rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-preview img {
    max-width: 100%;
    border-radius: 4px;
}

@media (max-width: 900px) {
    .company-settings-grid {
        grid-template-columns: 1fr;
        gap: clamp(1rem, 4vw, 1.5rem);
    }
    
    .company-form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }

    th {
        display: none;
    }

    .table-wrap table {
        border: 0;
    }

    tbody tr {
        border-bottom: 3px solid var(--line);
        margin-bottom: var(--spacing-xs);
        display: block;
        padding: var(--spacing-sm);
        border-radius: var(--radius);
        background: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }

    tbody td {
        border-bottom: 1px solid #f0f4f8;
        display: block;
        text-align: right;
        position: relative;
        padding: var(--spacing-xs) var(--spacing-sm) var(--spacing-xs) 40%;
        font-size: 0.875rem;
    }

    tbody td:before {
        content: attr(data-label);
        position: absolute;
        left: var(--spacing-sm);
        width: 35%;
        font-weight: 600;
        color: var(--muted);
        text-transform: uppercase;
        font-size: 0.75rem;
        padding-right: var(--spacing-sm);
        white-space: nowrap;
    }

    .actions-row {
        justify-content: center;
        flex-direction: column;
        gap: var(--spacing-xs);
    }
}

@media (max-width: 480px) {
    body {
        padding: 0 var(--spacing-xs);
    }

    .sidebar {
        padding: var(--spacing-sm) var(--spacing-xs);
    }

    .nav-btn {
        padding: var(--spacing-sm);
        font-size: 0.875rem;
    }

    .login-wrap {
        width: 100%;
        padding: 0 var(--spacing-sm);
    }

    .invoice-item-row {
        gap: var(--spacing-sm);
    }

    .actions-row {
        flex-direction: column;
    }

    button {
        width: 100%;
        padding: var(--spacing-md);
        font-size: 1rem;
    }

    .upload-preview {
        min-height: 5rem;
    }
}

/* Skeleton Loaders */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin: 0.5rem 0;
}

.skeleton-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
}

.stats-skeleton {
    height: 3rem;
}

.chart-skeleton {
    height: 300px;
}

.dark .skeleton {
    background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
}

/* Dark mode toggle */
.theme-toggle {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.3);
}

.dark .theme-toggle {
    background: rgba(71,85,105,0.4);
    border-color: rgba(100,116,139,0.5);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* UI Refresh */
:root {
    --bg: #f5ede7;
    --bg-alt: #fbf6f2;
    --panel: rgba(255, 250, 246, 0.94);
    --panel-strong: #fffdfb;
    --text: #241814;
    --muted: #78645d;
    --line: #ead6c8;
    --primary: #b3543d;
    --primary-strong: #8d3c2c;
    --accent: #efc18d;
    --accent-soft: #f8e8db;
    --success: #1d8a6a;
    --shadow: 0 24px 64px rgba(94, 46, 33, 0.12);
    --shadow-soft: 0 14px 36px rgba(94, 46, 33, 0.08);
    --shadow-login: 0 32px 70px rgba(86, 38, 28, 0.16);
}

body {
    color: var(--text);
    background:
        radial-gradient(80rem 34rem at -10% -15%, rgba(239, 193, 141, 0.34), transparent 54%),
        radial-gradient(52rem 26rem at 110% 10%, rgba(179, 84, 61, 0.15), transparent 52%),
        linear-gradient(180deg, #fff9f5 0%, #f5ede7 100%);
}

.app-shell {
    grid-template-columns: 290px minmax(0, 1fr);
    gap: clamp(1rem, 2vw, 1.5rem);
}

.sidebar {
    background: linear-gradient(180deg, #92412f 0%, #b3543d 46%, #c47052 100%);
    margin: 1rem 0 1rem 1rem;
    padding: 1rem;
    border-right: none;
    border-radius: 1.5rem;
    box-shadow: 0 26px 60px rgba(94, 46, 33, 0.22);
    position: sticky;
    top: 1rem;
    height: calc(100vh - 2rem);
}

.sidebar h2 {
    padding: 1rem 1.1rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.14);
    color: #fff8f4;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.sidebar .muted {
    color: rgba(255, 241, 232, 0.74);
    font-size: 0.86rem;
}

#main-nav {
    gap: 0.6rem;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    color: rgba(255, 251, 248, 0.9);
    border-radius: 1rem;
    padding: 0.95rem 1rem;
    min-height: 52px;
    font-weight: 600;
    box-shadow: none;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.13);
    transform: translateX(4px);
    box-shadow: none;
    filter: none;
}

.nav-btn.active {
    background: #fff7f1;
    color: var(--primary-strong);
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 16px 30px rgba(71, 23, 13, 0.18);
}

.nav-btn.active:hover {
    background: #fffaf6;
    transform: translateX(6px);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
}

#logout-btn {
    margin-top: 0.5rem;
}

.content {
    padding: clamp(1.25rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem) 2rem 0;
}

.topbar {
    background: linear-gradient(135deg, rgba(255, 252, 249, 0.96), rgba(248, 235, 224, 0.84));
    border: 1px solid rgba(234, 214, 200, 0.92);
    box-shadow: var(--shadow-soft);
    padding: 1.25rem 1.4rem;
}

.topbar h1 {
    color: #311d17;
    font-size: clamp(2rem, 4.4vw, 2.8rem);
    letter-spacing: -0.04em;
}

.topbar-copy {
    margin: 0.3rem 0 0;
    max-width: 44rem;
    color: var(--muted);
    font-size: 0.96rem;
}

#global-message {
    margin: 0.15rem 0 0;
    font-weight: 600;
}

.stats-grid {
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    position: relative;
    min-height: 11rem;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -2rem;
    bottom: -2.75rem;
    width: 8rem;
    height: 8rem;
    background: radial-gradient(circle, rgba(179, 84, 61, 0.14), transparent 68%);
}

.stats-grid .card,
.card {
    background: linear-gradient(180deg, rgba(255, 253, 251, 0.97), rgba(255, 248, 242, 0.92));
    border: 1px solid rgba(234, 214, 200, 0.95);
    box-shadow: var(--shadow-soft);
}

.card {
    border-radius: 1.4rem;
    padding: 1.25rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card h3,
.card h4 {
    color: #311d17;
}

.stat-card h3 {
    max-width: 70%;
    margin-bottom: 0;
    color: #6d584f;
    font-size: 0.92rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stats-grid .card p {
    margin-top: 1.6rem;
    color: #2b1a14;
    font-size: clamp(1.95rem, 4vw, 2.6rem);
    letter-spacing: -0.05em;
}

.stat-icon {
    top: 1rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
    border-radius: 1rem;
    display: grid;
    place-items: center;
    background: rgba(179, 84, 61, 0.1);
    color: var(--primary);
    opacity: 1;
    font-size: 1.1rem;
}

.stat-card[data-stat="sales"] .stat-icon {
    background: rgba(29, 138, 106, 0.12);
    color: var(--success);
}

.stat-card[data-stat="gst"] .stat-icon {
    background: rgba(239, 193, 141, 0.22);
    color: #9a632e;
}

.stat-card[data-stat="monthly"] .stat-icon {
    background: rgba(141, 60, 44, 0.11);
    color: var(--primary-strong);
}

.dashboard-panels {
    gap: 1rem;
    align-items: stretch;
}

.dashboard-panels > .card {
    height: 100%;
}

.chart-card {
    min-height: 30rem;
}

.chart-shell {
    min-height: 24rem;
    padding: 1rem;
    border-radius: 1.2rem;
    border: 1px dashed rgba(179, 84, 61, 0.2);
    background: linear-gradient(180deg, #fffaf6, #fff);
}

.table-wrap {
    border-radius: 1.2rem;
    border: 1px solid rgba(234, 214, 200, 0.92);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

table {
    background: transparent;
}

thead {
    background: linear-gradient(180deg, #fff7f1, #f7ede6);
}

th {
    color: #70584f;
    background: transparent;
}

td {
    color: #34211c;
}

tbody tr:nth-child(even) td {
    background: rgba(255, 249, 244, 0.76);
}

tr:hover td {
    background: #fff1e6;
}

.table-wrap td:last-child {
    white-space: nowrap;
}

.table-wrap td button {
    min-height: 38px;
    padding: 0.6rem 0.8rem;
    font-size: 0.78rem;
}

.table-empty-row td {
    padding: 2.2rem 1rem;
    border-bottom: none;
    background: transparent !important;
}

.table-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    text-align: center;
}

.table-empty-icon {
    width: 3.2rem;
    height: 3.2rem;
    display: grid;
    place-items: center;
    border-radius: 1rem;
    background: rgba(179, 84, 61, 0.08);
    color: var(--primary);
    font-size: 1.15rem;
}

.table-empty-title {
    margin: 0;
    color: #341f19;
    font-weight: 700;
}

.table-empty-copy {
    margin: 0;
    max-width: 20rem;
    color: var(--muted);
}

.grid-form {
    gap: 1rem;
}

label {
    color: #7c655d;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

input,
textarea,
select {
    background: rgba(255, 253, 251, 0.98);
    border: 1px solid rgba(231, 214, 203, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

input:hover,
textarea:hover,
select:hover {
    border-color: rgba(179, 84, 61, 0.36);
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(179, 84, 61, 0.72);
    box-shadow: 0 0 0 4px rgba(179, 84, 61, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

button {
    border-radius: 1rem;
    background: linear-gradient(135deg, #bf6446, #8d3c2c);
    box-shadow: 0 18px 26px rgba(143, 60, 44, 0.22);
}

button:hover {
    box-shadow: 0 20px 30px rgba(143, 60, 44, 0.24);
}

button.secondary {
    background: linear-gradient(135deg, #ecdfd5, #dbc7b8);
    color: #53362e;
    box-shadow: 0 12px 22px rgba(108, 75, 63, 0.12);
}

button.secondary:hover {
    color: #402823;
    filter: none;
}

button.danger {
    background: linear-gradient(135deg, #d55452, #ad353e);
}

.sub-card {
    background: linear-gradient(180deg, #fff7f1, #fffaf7);
}

#report-summary {
    margin: 0 0 1rem;
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    background: rgba(248, 232, 219, 0.7);
    color: #5a433c;
    font-weight: 600;
}

.modal {
    background: rgba(46, 25, 20, 0.35);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: linear-gradient(180deg, #fffaf6, #fff);
    border: 1px solid rgba(234, 214, 200, 0.95);
}

.success-alert {
    border-radius: 1rem;
    box-shadow: 0 12px 24px rgba(16, 185, 129, 0.12);
}

.login-body {
    background:
        radial-gradient(76rem 32rem at -10% -12%, rgba(239, 193, 141, 0.32), transparent 55%),
        radial-gradient(36rem 24rem at 110% 12%, rgba(179, 84, 61, 0.14), transparent 58%),
        linear-gradient(180deg, #fff9f5 0%, #f5ede7 100%);
}

.login-wrap {
    width: min(460px, 95vw);
}

.login-card {
    padding: 1.75rem;
    border-radius: 1.5rem;
    animation: none;
}

.login-card h1 {
    color: var(--primary-strong);
    font-size: clamp(1.9rem, 4.5vw, 2.35rem);
    letter-spacing: -0.04em;
}

.login-card .muted a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.login-card .muted a:hover {
    text-decoration: underline;
}

.skeleton,
.theme-toggle {
    display: none !important;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .sidebar {
        position: relative;
        top: auto;
        height: auto;
        margin: 1rem;
    }

    .content {
        padding: 0 1rem 1.5rem;
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 1.1rem 1rem;
    }

    .topbar h1 {
        font-size: 1.85rem;
    }

    .table-wrap td button {
        width: 100%;
        margin-top: 0.35rem;
    }
}

@media print {
    body * {
        visibility: hidden;
    }

    .content, .content * {
        visibility: visible;
    }

    .content {
        position: absolute;
        left: 0;
        top: 0;
        padding: 0 !important;
    }

    table {
        font-size: 10pt !important;
    }
}
}
