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

:root {
    --primary: #2196F3;
    --primary-dark: #1976D2;
    --secondary: #757575;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --info: #00BCD4;
    --background: #f5f5f5;
    --surface: #ffffff;
    --text: #212121;
    --text-secondary: #757575;
    --border: #e0e0e0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Auth Screen */
.auth-container {
    max-width: 400px;
    margin: auto;
    padding: 20px;
    text-align: center;
}

.auth-container h1 {
    margin-bottom: 10px;
    color: var(--primary);
}

.auth-container p {
    margin-bottom: 30px;
    color: var(--text-secondary);
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

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

/* Buttons */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: none;
    letter-spacing: 0.3px;
}

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

.btn-primary {
    background: #2E7D32;
    color: white;
    box-shadow: 0 2px 4px rgba(46, 125, 50, 0.3);
}

.btn-primary:hover {
    background: #1B5E20;
    box-shadow: 0 4px 8px rgba(46, 125, 50, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #546E7A;
    color: white;
    box-shadow: 0 2px 4px rgba(84, 110, 122, 0.3);
}

.btn-secondary:hover {
    background: #37474F;
}

.btn-danger {
    background: #C62828;
    color: white;
    box-shadow: 0 2px 4px rgba(198, 40, 40, 0.3);
}

.btn-danger:hover {
    background: #B71C1C;
}

.btn-warning {
    background: #E65100;
    color: white;
    box-shadow: 0 2px 4px rgba(230, 81, 0, 0.3);
}

.btn-warning:hover {
    background: #BF360C;
}

.btn-info {
    background: #00695C;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 105, 92, 0.3);
}

.btn-info:hover {
    background: #004D40;
}

/* Product Navigation */
.product-nav {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.product-nav-top {
    margin-bottom: 12px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.back-btn:hover {
    background: rgba(255,255,255,0.25);
}

.back-icon {
    font-size: 18px;
    font-weight: bold;
}

.back-text {
    font-weight: 500;
}

.product-nav-main {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.product-title-input {
    flex: 2;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    background: white;
    color: var(--text);
}

.product-title-input::placeholder {
    color: var(--text-secondary);
}

.product-category-select {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: var(--text);
}

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

.product-nav-actions .btn {
    padding: 10px 16px;
    font-size: 13px;
    border-radius: 6px;
}

/* Header */
header {
    background: var(--surface);
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.header-actions input {
    flex: 1;
    min-width: 200px;
}

/* Sync Status */
.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--success);
    color: #0a0a0a;
    border-radius: 20px;
    font-size: 14px;
}

.sync-status.offline {
    background: var(--warning);
}

.online-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

/* Main Content */
main {
    flex: 1;
    padding: 15px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Categories */
.category-section {
    margin-bottom: 20px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.category-header h3 {
    font-size: 16px;
}

.category-products {
    display: none;
    padding: 10px;
}

.category-products.active {
    display: block;
}

/* Product Card */
.product-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.product-card:hover {
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.product-card h4 {
    margin-bottom: 5px;
}

.product-card .product-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 14px;
}

.product-card .product-price {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary);
    margin-top: 10px;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-draft {
    background: #E3F2FD;
    color: #1976D2;
}

.status-active {
    background: #E8F5E9;
    color: #388E3C;
}

.status-archived {
    background: #F5F5F5;
    color: #757575;
}

/* Product Screen */
.product-header {
    flex: 1;
    display: flex;
    gap: 10px;
}

.product-header input {
    flex: 2;
}

.product-header select {
    flex: 1;
}

.product-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

/* Items */
.items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.items-header h3 {
    font-size: 18px;
}

.item-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.item-card .item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.item-card .item-name {
    font-weight: bold;
    font-size: 16px;
}

.item-card .item-actions {
    display: flex;
    gap: 5px;
}

.item-card .item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.item-card .item-price {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary);
    margin-top: 10px;
}

/* Total Section */
.total-section {
    background: var(--primary);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    font-size: 24px;
    margin-top: 20px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 800px;
}

.admin-footer {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 15px;
    border-top: 1px solid var(--border);
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-content form {
    padding: 15px;
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

#admin-content {
    padding: 15px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Admin Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: var(--background);
    font-weight: 500;
}

.admin-table tr:hover {
    background: var(--background);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state h3 {
    margin-bottom: 10px;
}

/* Responsive */
@media (max-width: 600px) {
    .header-actions {
        flex-direction: column;
    }

    .header-actions input {
        min-width: 100%;
    }

    .product-nav-main {
        flex-direction: column;
    }

    .product-nav-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .product-nav-actions .btn {
        width: 100%;
    }

    .back-btn {
        padding: 10px 20px;
        font-size: 16px;
    }
}

@media (min-width: 768px) {
    .product-nav {
        padding: 16px 24px;
    }

    .product-title-input {
        font-size: 22px;
    }

    .product-nav-actions .btn {
        padding: 12px 20px;
    }
}

/* Loading Spinner */
.loading {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.calc-shapes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 15px;
    border-bottom: 1px solid var(--border);
}
.calc-shapes .btn {
    font-size: 12px;
    padding: 8px 12px;
}
.calc-shapes .btn.active {
    background: var(--primary);
    color: white;
}
#calc-fields {
    padding: 15px;
}
#calc-fields .calc-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}
#calc-fields .calc-row label {
    min-width: 80px;
    font-size: 13px;
}
#calc-fields .calc-row input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
}
#calc-fields .calc-row select {
    width: 80px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
}
.calc-result {
    margin: 0 15px 15px;
    padding: 15px;
    background: var(--surface);
    border: 2px solid var(--primary);
    border-radius: 8px;
}
.calc-result-text {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}
.calc-result-text div {
    margin-bottom: 5px;
}
.calc-result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.calc-result-actions .btn {
    font-size: 12px;
    padding: 8px 12px;
}