:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary: #ec4899;
    --background: #0f172a;
    --surface: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
    --glow: rgba(139, 92, 246, 0.5);
    
    --radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Background animated orbs */
.background-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
    animation: float 20s infinite alternate;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: #3b82f6;
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

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

/* Typography & Layout */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.app-header {
    text-align: center;
    margin-bottom: 3rem;
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.view-hidden {
    display: none !important;
}

/* Glassmorphism */
.glass-panel {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.form-layout {
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.form-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--surface-border);
    color: var(--text-primary);
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input, textarea, select {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position-x: 95%;
    background-position-y: center;
}

select option {
    background: var(--background);
    color: var(--text-primary);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--glow);
}

input::placeholder, textarea::placeholder {
    color: rgba(148, 163, 184, 0.4);
}

/* Line Items */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    margin-bottom: 0;
    border: none;
}

.items-table-container {
    background: rgba(15, 23, 42, 0.3);
    border-radius: 8px;
    border: 1px solid var(--surface-border);
    overflow: hidden;
}

.items-header {
    display: flex;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--surface-border);
}

.item-row {
    display: flex;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 1rem;
    align-items: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.item-row:last-child {
    border-bottom: none;
}

.col-name { flex: 2; }
.col-qty { flex: 0.5; min-width: 70px; }
.col-price { flex: 1; min-width: 100px; }
.col-total { flex: 1; min-width: 100px; text-align: right; font-weight: 500; }
.col-action { flex: 0 0 40px; display: flex; justify-content: flex-end; }

.item-row input {
    width: 100%;
    padding: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Totals */
.totals-section {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1rem;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    width: 300px;
    font-size: 1.1rem;
}

.tax-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tax-input-wrapper input {
    width: 70px;
    padding: 0.3rem 0.5rem;
}

.grand-total {
    font-size: 1.5rem;
    font-weight: 700;
    padding-top: 1rem;
    border-top: 1px solid var(--surface-border);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.95rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px var(--glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--glow);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    width: 100%;
}

.form-actions {
    margin-top: 2rem;
}

/* Loading state */
.btn-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

.btn.loading .btn-text { display: none; }
.btn.loading .btn-loader { display: block; }

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    position: relative;
    width: 90%;
    max-width: 500px;
    padding: 3rem 2rem;
    text-align: center;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal {
    transform: scale(0.9);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover { color: white; }

.success-icon {
    margin-bottom: 1.5rem;
}

.modal h2 { margin-bottom: 1rem; }
.modal p { color: var(--text-secondary); margin-bottom: 2rem; }

.action-links {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--danger);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4);
    z-index: 2000;
    transition: all 0.3s ease;
    transform: translateY(0);
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* Responsive */
@media (max-width: 768px) {
    .input-grid { grid-template-columns: 1fr; }
    .items-header { display: none; }
    .item-row { flex-wrap: wrap; position: relative; padding-bottom: 3rem; }
    .col-name { flex: 100%; margin-bottom: 0.5rem; }
    .col-qty, .col-price { flex: 1; }
    .col-total { flex: 100%; text-align: left; margin-top: 0.5rem; }
    .col-action { position: absolute; bottom: 1rem; right: 1rem; }
    .action-links { flex-direction: column; }
}
