:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #f43f5e;
    --bg-ui: #1e293b;
    --card-ui: rgba(51, 65, 85, 0.9);
    --text-ui: #f8fafc;
    --text-muted: #cbd5e1;
    --print-black: #000000;
    --print-grey: #f2f2f2;
    --print-border: #000000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Noto Sans SC', sans-serif;
    background-color: var(--bg-ui);
    color: var(--text-ui);
    overflow-x: hidden;
    min-height: 100vh;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

#login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
                radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
                radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    background-size: 200% 200%;
    animation: bg-pan 15s ease infinite alternate;
    background-color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes bg-pan {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding: 3.5rem 3rem;
    border-radius: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    text-align: center;
    animation: scaleIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 50%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.03), transparent);
    transform: skewX(-25deg);
    animation: card-shine 8s infinite;
}

@keyframes card-shine {
    0%, 100% { left: -100%; }
    50% { left: 200%; }
}

.login-logo {
    width: 88px;
    height: 88px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 2rem;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.5);
    animation: logo-float 3s ease-in-out infinite;
    position: relative; z-index: 1;
}

@keyframes logo-float {
    0%, 100% { transform: translateY(0); box-shadow: 0 20px 40px -10px rgba(99, 102, 241, 0.5); }
    50% { transform: translateY(-8px); box-shadow: 0 30px 60px -12px rgba(99, 102, 241, 0.6); }
}

.login-card h1 { 
    font-size: 2rem; 
    margin-bottom: 0.5rem; 
    letter-spacing: -0.03em; 
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.login-card p { color: var(--text-muted); margin-bottom: 3rem; font-size: 1rem; opacity: 0.8; }

.input-group { position: relative; margin-bottom: 1.5rem; z-index: 1; text-align: left; }
.input-group input {
    width: 100%;
    background: rgba(15, 23, 42, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.05);
    padding: 1.1rem 1rem;
    border-radius: 1.25rem;
    color: white;
    font-size: 1.05rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}
.input-group input::placeholder { color: rgba(255,255,255,0.3); }
.input-group input:focus { 
    background: rgba(15, 23, 42, 0.8);
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.btn-login {
    width: 100%;
    padding: 1.1rem;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: 1.25rem;
    color: white;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
    position: relative; overflow: hidden; z-index: 1;
}
.btn-login:hover { 
    transform: translateY(-3px) scale(1.02); 
    box-shadow: 0 20px 30px -10px rgba(99, 102, 241, 0.6);
    background: linear-gradient(90deg, #818cf8, var(--primary));
}
.btn-login:active { transform: translateY(-1px) scale(0.98); }

#main-app { display: none; padding: 2rem; max-width: 1400px; margin: 0 auto; animation: fadeIn 0.8s ease-out; }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.brand { display: flex; align-items: center; gap: 1rem; }
.brand-icon {
    width: 44px; height: 44px; background: var(--primary); 
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
}
.brand h2 { font-size: 1.5rem; font-weight: 700; }

.glass-toolbar {
    display: flex;
    gap: 0.75rem;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(24px);
    padding: 0.5rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.1rem;
    border-radius: 0.9rem;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.03);
    white-space: nowrap;
    position: relative;
}

.tool-btn i {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 18px; height: 18px;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-3px) scale(1.02);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.tool-btn:hover i { transform: scale(1.2); }
.tool-btn:active { transform: translateY(-1px) scale(0.96); }

.btn-green i { color: #4ade80; }
.btn-blue i { color: #60a5fa; }
.btn-yellow i { color: #fbbf24; }
.btn-purple i { color: #a78bfa; }
.btn-stamp i { color: #f43f5e; }
.btn-print i { color: #f8fafc; }

.btn-green:hover { 
    box-shadow: 0 10px 25px -5px rgba(74, 222, 128, 0.35); 
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.4);
}
.btn-blue:hover { 
    box-shadow: 0 10px 25px -5px rgba(96, 165, 250, 0.35); 
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.4);
}
.btn-yellow:hover { 
    box-shadow: 0 10px 25px -5px rgba(251, 191, 36, 0.35); 
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.4);
}
.btn-purple:hover { 
    box-shadow: 0 10px 25px -5px rgba(167, 139, 250, 0.35); 
    background: rgba(167, 139, 250, 0.12);
    border-color: rgba(167, 139, 250, 0.4);
}
.btn-stamp:hover {
    box-shadow: 0 10px 25px -5px rgba(244, 63, 94, 0.35);
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.4);
}

.btn-stamp-active { 
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.3), rgba(244, 63, 94, 0.1)) !important; 
    border-color: rgba(244, 63, 94, 0.6) !important;
    color: #fff !important;
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.3) !important;
}

.app-grid {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 2rem;
    align-items: start;
}

.entry-panel {
    background: var(--card-ui);
    backdrop-filter: blur(10px);
    border-radius: 1.5rem;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-height: calc(100vh - 150px);
    display: flex;
    flex-direction: column;
}

.entry-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.item-list { overflow-y: auto; flex-grow: 1; padding-right: 0.5rem; }

.item-card {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 1rem;
    padding: 0;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideInRight 0.4s ease-out;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.item-card-header {
    padding: 1rem 1rem 1rem 3.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
}
.item-card-header:hover { background: rgba(255, 255, 255, 0.05); }

.item-card-content {
    padding: 0 1rem 1.25rem 3.5rem;
    display: block;
}

.item-card.collapsed .item-card-content {
    display: none;
}

.item-card.collapsed .btn-collapse { transform: rotate(-90deg); }

.item-info-preview {
    font-size: 0.95rem; font-weight: 600; color: white;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 180px;
}

.btn-collapse {
    position: absolute; right: 2.5rem; top: 1rem;
    color: var(--text-muted); transition: transform 0.3s;
}

.item-index {
    position: absolute;
    left: 1rem;
    top: 1.5rem;
    width: 1.8rem;
    height: 1.8rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
}

.card-row-single { margin-bottom: 1rem; }
.card-row-triple { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 0.75rem; }

.item-card label { font-size: 0.75rem; color: #facc15; display: block; margin-bottom: 0.25rem; font-weight: 600; text-transform: uppercase; }

.input-minimal {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.25rem 0;
    font-size: 0.95rem;
    outline: none;
}
.input-minimal:focus { border-bottom-color: var(--primary); }

.btn-remove-item {
    position: absolute; top: 0.5rem; right: 0.5rem;
    padding: 0.4rem; color: #94a3b8; cursor: pointer; transition: 0.2s;
}
.btn-remove-item:hover { color: var(--accent); scale: 1.1; }

.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-container {
    width: 210mm;
    height: 297mm;
    background: white;
    padding: 15mm;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    position: relative;
    transform-origin: top center;
    overflow: hidden;
}

#official-stamp, .official-stamp {
    position: absolute;
    width: 42mm;
    height: 42mm;
    opacity: 0.88;
    pointer-events: none;
    mix-blend-mode: multiply;
    display: none;
    z-index: 1000;
    transform: translate(-50%, -50%) rotate(-15deg);
}

@media print {
    @page { size: A4 portrait; margin: 0; }
    html, body { height: auto; overflow: visible; background: white !important; margin: 0; padding: 0; }
    #login-overlay, .header, .entry-panel, .stamp-hint-banner, .btn-float, .antigravity-visuals { display: none !important; }
    #main-app { padding: 0; display: block !important; }
    .app-grid { display: block; }
    .preview-panel { 
        width: 100% !important; 
        margin: 0 !important; 
        padding: 0 !important; 
        background: white !important;
        display: block !important;
    }
    .preview-container { 
        width: 210mm !important; 
        height: 297mm !important;
        padding: 15mm !important; 
        margin: 0 !important; 
        box-shadow: none !important;
        border: none !important;
        page-break-after: always;
        break-after: page;
        overflow: hidden;
    }
    .preview-panel.stamping-active-cursor { cursor: default !important; }
    * { color: var(--print-black) !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; scroll-margin: 0 !important; }
    .print-table th { background-color: var(--print-grey) !important; color: var(--print-black) !important; }
    .quotation-title { color: var(--print-black) !important; }
}

.quotation-title {
    position: relative; z-index: 2; text-align: center;
    font-size: 24pt; font-weight: 800; 
    margin-top: 15mm; 
    margin-bottom: 8mm;
    color: #000; letter-spacing: 0.5em;
}

.content-wrapper { 
    position: relative; 
    width: 100%; 
    height: 100%;
    z-index: 10; 
    display: flex;
    flex-direction: column;
}


.print-table { width: 100%; border-collapse: collapse; table-layout: fixed; border: 1.5pt solid #000; position: relative; z-index: 2; flex-shrink: 0; background: transparent; }

.print-table th, .print-table td { 
    border: 1pt solid #000; 
    padding: 10pt 6pt; 
    text-align: center; 
    font-size: 10.5pt; 
    color: #000; 
    word-break: break-all;
    overflow-wrap: break-word;
}
.print-table th { background-color: transparent; font-weight: 700; }

.official-stamp {
    position: absolute;
    z-index: 1; /* Lower than table (2) */
    width: 40mm; /* Standard size 40mm */
    height: 40mm;
    pointer-events: none; /* Allow clicking through to table if needed */
    opacity: 0.8; /* Make it look a bit more like ink */
    top: 5mm; 
    left: 40mm;
}

.footer-section { position: relative; z-index: 2; margin-top: 10mm; text-align: right; color: #000; padding-right: 5mm; }
.company-bold { font-weight: 700; font-size: 14pt; margin-bottom: 5mm; letter-spacing: 1px; }

.page-number-fixed {
    position: absolute;
    bottom: 8mm;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8.5pt;
    color: #999;
    z-index: 1;
}

.stamping-active-cursor { cursor: crosshair !important; }
.stamp-hint-banner {
    padding: 1rem; background: var(--accent); color: white; 
    border-radius: 1rem; margin-bottom: 1rem; width: 100%; text-align: center;
    font-weight: 600; display: none; animation: fadeIn 0.3s;
}

.modal-overlay {
    position: fixed; inset: 0; background: rgba(8, 10, 15, 0.85);
    backdrop-filter: blur(12px); z-index: 10000; display: none;
    align-items: center; justify-content: center; animation: fadeIn 0.3s;
}
.settings-modal {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2rem; width: 90%; max-width: 600px;
    max-height: 85vh; overflow-y: auto; padding: 2.5rem;
    box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.7);
    color: white;
}
.settings-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 2.5rem; border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 1.5rem;
}
.settings-title { display: flex; align-items: center; gap: 0.75rem; }
.settings-title h2 { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }

.btn-reset-subtle {
    background: rgba(239, 68, 68, 0.1); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.5rem 1rem; border-radius: 0.75rem; font-size: 0.85rem; font-weight: 600;
    display: flex; align-items: center; gap: 0.5rem; cursor: pointer; transition: 0.2s;
}
.btn-reset-subtle:hover { background: rgba(239, 68, 68, 0.2); transform: translateY(-1px); }

.settings-section-title {
    font-size: 0.9rem; font-weight: 600; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem;
    display: flex; align-items: center; gap: 0.5rem;
}

.settings-grid-compact { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }

.input-group-field { display: flex; flex-direction: column; gap: 0.5rem; }
.input-group-field label { font-size: 0.85rem; color: #cbd5e1; }
.input-premium {
    background: rgba(15, 23, 42, 0.5); border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem; padding: 0.75rem 1rem; color: white; outline: none;
    transition: 0.2s; font-size: 0.95rem;
}
.input-premium:focus { border-color: #818cf8; background: rgba(15, 23, 42, 0.8); box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.15); }

.column-config-container {
    background: rgba(15, 23, 42, 0.3); border: 1px solid rgba(255,255,255,0.05);
    border-radius: 1.25rem; padding: 1rem; max-height: 320px; overflow-y: auto;
}
.column-config-row {
    display: flex; align-items: center; gap: 1rem; padding: 0.75rem;
    border-radius: 0.75rem; transition: 0.2s;
}
.column-config-row:hover { background: rgba(255,255,255,0.03); }
.column-config-row input[type="checkbox"] {
    appearance: none; width: 1.25rem; height: 1.25rem; border: 2px solid rgba(255,255,255,0.2);
    border-radius: 0.4rem; cursor: pointer; position: relative; transition: 0.2s;
}
.column-config-row input[type="checkbox"]:checked { background: #818cf8; border-color: #818cf8; }
.column-config-row input[type="checkbox"]:checked::after {
    content: "✓"; position: absolute; color: white; font-size: 0.8rem;
    left: 50%; top: 50%; transform: translate(-50%, -50%);
}
.column-config-row input[type="text"] {
    flex: 1; background: transparent; border: none; color: white; font-size: 0.95rem;
    padding: 0.25rem 0.5rem; border-bottom: 2px solid transparent; transition: 0.2s;
}
.column-config-row input[type="text"]:focus { border-bottom-color: #818cf8; }
.col-width-tag { font-size: 0.75rem; color: #64748b; width: 45px; text-align: right; font-family: monospace; }

.settings-actions { display: flex; gap: 1rem; margin-top: 2.5rem; }
.btn-save-premium {
    flex: 1.5; background: #818cf8; color: white; border: none; padding: 1rem;
    border-radius: 1rem; font-weight: 700; cursor: pointer; transition: 0.3s;
    box-shadow: 0 10px 20px rgba(129, 140, 248, 0.3);
}
.btn-save-premium:hover { transform: translateY(-2px); box-shadow: 0 15px 30px rgba(129, 140, 248, 0.4); }
.btn-cancel-premium {
    flex: 1; background: rgba(255,255,255,0.05); color: #94a3b8; border: 1px solid rgba(255,255,255,0.1);
    padding: 1rem; border-radius: 1rem; font-weight: 600; cursor: pointer; transition: 0.2s;
}
.btn-cancel-premium:hover { background: rgba(255,255,255,0.1); color: white; }
