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

:root {
    --bg: #0F172A;
    --surface: #1E293B;
    --surface-hover: #334155;
    --surface-light: #475569;
    --border: #334155;
    --text: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --blue: #3B82F6;
    --violet: #8B5CF6;
    --amber: #F59E0B;
    --emerald: #10B981;
    --green: #22C55E;
    --red: #EF4444;
    --orange: #F97316;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--blue); text-decoration: none; }

/* === HEADER === */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo i { color: var(--blue); font-size: 1.4rem; }
.header-date { color: var(--text-secondary); font-size: 0.9rem; }
.user-badge {
    background: var(--surface-hover);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--text-secondary);
    transition: var(--transition);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

/* === MAIN === */
.app-main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.app-main.full-width { max-width: 100%; }

/* === FLASH MESSAGES === */
.flash-messages { margin-bottom: 20px; }
.flash {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    animation: slideDown 0.3s ease;
    font-size: 0.95rem;
}
.flash-success { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.flash-error { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.flash-info { background: rgba(59,130,246,0.15); color: var(--blue); border: 1px solid rgba(59,130,246,0.3); }

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

/* === HOME GRID === */
.home-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.box-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.box-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-color, var(--blue));
}
.box-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--card-color, var(--blue));
}
.box-card:active { transform: scale(0.97); }
.box-card .card-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 4px;
}
.box-card .card-title { font-size: 1.3rem; font-weight: 700; }
.box-card .card-subtitle { font-size: 0.85rem; color: var(--text-secondary); }
.box-card .card-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* === SECONDARY BUTTONS ROW === */
.home-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}
.btn-reports {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 14px 32px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-reports:hover { background: var(--surface-hover); border-color: var(--blue); }
.btn-reports i { color: var(--blue); }

/* === STATS BAR === */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.stats-bar .stat-value { color: var(--text); font-weight: 700; font-size: 1.1rem; }

/* === MASTER CARDS === */
.masters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.master-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}
.master-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--blue);
}
.master-card:active { transform: scale(0.97); }
.master-card .avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 2rem;
    color: white;
}
.master-card .name { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.master-card .spec { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 12px; }
.master-card .mini-stats { color: var(--text-muted); font-size: 0.8rem; }

/* === BACK BUTTON === */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 20px;
    transition: var(--transition);
    background: none;
    border: none;
    cursor: pointer;
}
.back-btn:hover { color: var(--text); }

/* === PAGE TITLE === */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.page-subtitle { color: var(--text-secondary); margin-bottom: 24px; }

/* === FORM === */
.form-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
}
.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.form-input::placeholder { color: var(--text-muted); }

.form-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
}

/* === SERVICE CHIPS === */
.chips-label { margin-bottom: 12px; }
.chips-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.chip {
    padding: 12px 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    user-select: none;
}
.chip:hover { border-color: var(--blue); background: rgba(59,130,246,0.1); }
.chip.selected {
    background: rgba(59,130,246,0.2);
    border-color: var(--blue);
    color: var(--blue);
}
.chip .chip-name { font-weight: 600; }
.chip .chip-price { color: var(--text-secondary); margin-left: 8px; font-size: 0.85rem; }

/* === SELECTED SERVICES LIST === */
.services-list {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.services-list:empty { display: none; }
.service-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    animation: slideDown 0.2s ease;
}
.service-item:last-child { border-bottom: none; }
.service-item .name { flex: 1; }
.service-item .price-input {
    width: 120px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 0.95rem;
    text-align: right;
    outline: none;
}
.service-item .price-input:focus { border-color: var(--blue); }
.service-item .remove-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--red);
    cursor: pointer;
    transition: var(--transition);
    margin-left: 8px;
    background: none;
    border: none;
    font-size: 1rem;
}
.service-item .remove-btn:hover { background: rgba(239,68,68,0.15); }

/* === TOTAL === */
.total-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    font-size: 1.3rem;
    font-weight: 700;
}
.total-bar .label { color: var(--text-secondary); font-weight: 400; }

/* === BUTTONS === */
.btn {
    padding: 16px 32px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: #16A34A; box-shadow: 0 4px 16px rgba(34,197,94,0.4); }
.btn-secondary { background: var(--surface-hover); color: var(--text); }
.btn-secondary:hover { background: var(--surface-light); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #2563EB; }
.btn-sm { padding: 10px 20px; font-size: 0.9rem; width: auto; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #DC2626; }

/* === SUCCESS PAGE === */
.success-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    animation: fadeIn 0.4s ease;
}
.success-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(34,197,94,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--green);
    margin-bottom: 24px;
    animation: bounceIn 0.5s ease;
}
.success-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 12px; }
.success-details { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 32px; }
.success-actions { display: flex; gap: 16px; }

@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === REPORTS === */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 24px;
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.filter-group select,
.filter-group input[type="date"] {
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}
.filter-group select:focus,
.filter-group input[type="date"]:focus { border-color: var(--blue); }
.quick-filters { display: flex; gap: 8px; align-items: end; }
.quick-btn {
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}
.quick-btn:hover { border-color: var(--blue); color: var(--blue); }

/* === DATA TABLE === */
.data-table-wrapper {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.data-table tr:hover td { background: rgba(59,130,246,0.05); }
.data-table .amount { text-align: right; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.data-table .total-row td {
    font-weight: 700;
    color: var(--text);
    font-size: 1rem;
    background: rgba(59,130,246,0.05);
}

.export-btns {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-bottom: 20px;
}

/* === MASTER SUMMARY CARDS === */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 24px;
    margin-bottom: 24px;
}
.summary-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    border-left: 4px solid var(--blue);
}
.summary-card .sc-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.summary-card .sc-spec { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 12px; }
.summary-card .sc-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.9rem; color: var(--text-secondary); }
.summary-card .sc-row .val { color: var(--text); font-weight: 600; }
.summary-card .sc-total {
    display: flex;
    justify-content: space-between;
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 1.05rem;
    font-weight: 700;
}

/* === TAB SWITCHER === */
.tabs { display: flex; gap: 4px; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 20px; width: fit-content; }
.tab {
    padding: 10px 20px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: var(--transition);
    border: none;
    background: none;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; }

/* === LOGIN === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    width: 380px;
    box-shadow: var(--shadow);
}
.login-logo { font-size: 3rem; color: var(--blue); margin-bottom: 16px; }
.login-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.login-subtitle { color: var(--text-secondary); margin-bottom: 32px; }
.pin-display {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 32px;
}
.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    transition: var(--transition);
}
.pin-dot.filled { background: var(--blue); border-color: var(--blue); }
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 280px;
    margin: 0 auto;
}
.num-btn {
    width: 80px;
    height: 64px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}
.num-btn:hover { background: var(--surface-hover); border-color: var(--blue); }
.num-btn:active { transform: scale(0.95); }
.num-btn.action { font-size: 1rem; color: var(--text-secondary); }

/* === ADMIN === */
.admin-section { margin-bottom: 32px; }
.admin-section-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.admin-list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.admin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.admin-item:last-child { border-bottom: none; }
.admin-item:hover { background: var(--surface-hover); }
.admin-item .info { display: flex; align-items: center; gap: 12px; flex: 1; }
.admin-item .info .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.admin-item .info .dot.active { background: var(--green); }
.admin-item .info .dot.inactive { background: var(--red); }
.admin-item .actions { display: flex; gap: 8px; }
.admin-item .actions button,
.admin-item .actions a {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
}
.admin-item .actions button:hover,
.admin-item .actions a:hover { border-color: var(--blue); color: var(--blue); }

/* === MODAL === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    width: 440px;
    max-width: 90vw;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease;
}
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.modal-actions .btn { flex: 1; }

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

/* === PHOTO BUTTON === */
.photo-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}
.photo-btn:hover { border-color: var(--blue); color: var(--blue); }
.photo-btn i { font-size: 1.2rem; }
.photo-preview {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    display: none;
}

/* === SPARE PARTS FORM === */
.parts-list { margin-top: 12px; }
.part-item {
    display: grid;
    grid-template-columns: 2fr 80px 120px 120px 40px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    animation: slideDown 0.2s ease;
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .home-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .home-grid { grid-template-columns: 1fr; }
    .app-main { padding: 16px; }
    .filters-bar { flex-direction: column; }
}

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

/* === COLOR PICKER IN ADMIN === */
.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.color-option {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}
.color-option:hover { transform: scale(1.1); }
.color-option.selected { border-color: white; box-shadow: 0 0 0 2px var(--blue); }

/* === SEARCH === */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}
.search-bar input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    outline: none;
}
.search-bar input:focus { border-color: var(--blue); }
.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}
.search-results.active { display: block; }
.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.search-result-item:hover { background: var(--surface-hover); }
