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

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --primary: #2d3436;
    --accent: #0984e3;
    --accent-hover: #0770c2;
    --text: #2d3436;
    --text-secondary: #636e72;
    --border: #e0e0e0;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #d63031;
    --info: #74b9ff;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2d3436 0%, #0984e3 100%);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.login-logo span { color: var(--accent); }

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s;
    outline: none;
    background: var(--bg);
}

.form-input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(9, 132, 227, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(9, 132, 227, 0.3);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== LAYOUT ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo h2 {
    font-size: 20px;
    font-weight: 700;
}

.sidebar-logo h2 span { color: var(--accent); }

.sidebar-logo p {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    padding: 12px 12px 8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.nav-item.active .nav-badge {
    background: rgba(255,255,255,0.25);
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: white;
}

.user-info:hover { background: rgba(255,255,255,0.08); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: rgba(255,255,255,0.5); }

/* Main Content */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.search-bar {
    flex: 1;
    max-width: 560px;
    position: relative;
}

.search-bar svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: var(--bg);
}

.search-bar input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(9,132,227,0.08);
}

.search-bar input::placeholder { color: #b2bec3; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.content {
    padding: 28px 32px;
    flex: 1;
}

/* ===== PAGE TITLE ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 2px;
}

/* ===== STATS CARDS ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-card-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 4px;
}

.stat-card-change {
    font-size: 13px;
    margin-top: 4px;
}

.stat-card-change.up { color: var(--success); }
.stat-card-change.down { color: var(--danger); }

/* ===== FILTERS ===== */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    text-decoration: none;
}

.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active { background: var(--accent); color: white; border-color: var(--accent); }

.filter-select {
    padding: 8px 32px 8px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    font-size: 13px;
    background: var(--surface);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23636e72' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.filter-select:focus { border-color: var(--accent); }

/* ===== TABLE ===== */
.table-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.table-title {
    font-size: 16px;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }
tr { cursor: pointer; transition: background 0.15s; }
thead tr:hover td { background: transparent; }
thead tr { cursor: default; }

.table-overflow { overflow-x: auto; }

/* ===== STATUS BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-new { background: #dfe6e9; color: #2d3436; }
.badge-new .badge-dot { background: #636e72; }
.badge-waiting { background: #fef9e7; color: #e17055; }
.badge-waiting .badge-dot { background: #e17055; }
.badge-assigned { background: #e3f2fd; color: #0984e3; }
.badge-assigned .badge-dot { background: #0984e3; }
.badge-call { background: #e0f7fa; color: #00838f; }
.badge-call .badge-dot { background: #00acc1; }
.badge-failed { background: #fdeaea; color: #d63031; }
.badge-failed .badge-dot { background: #d63031; }
.badge-payment { background: #fff8e1; color: #f57f17; }
.badge-payment .badge-dot { background: #ffb300; }
.badge-rework { background: #f3e5f5; color: #7b1fa2; }
.badge-rework .badge-dot { background: #ab47bc; }
.badge-nodelivery { background: #fce4ec; color: #c62828; }
.badge-nodelivery .badge-dot { background: #e53935; }
.badge-nocall { background: #fce4ec; color: #ad1457; }
.badge-nocall .badge-dot { background: #e91e63; }
.badge-rejected { background: #efebe9; color: #4e342e; }
.badge-rejected .badge-dot { background: #6d4c41; }
.badge-done { background: #e0f5ee; color: #00b894; }
.badge-done .badge-dot { background: #00b894; }
.badge-completed { background: #e8f5e9; color: #2e7d32; }
.badge-completed .badge-dot { background: #43a047; }

.badge-designer {
    background: #f3e5f5;
    color: #8e24aa;
    font-size: 11px;
    padding: 2px 8px;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.pagination-info { font-size: 13px; color: var(--text-secondary); }

.pagination-btns {
    display: flex;
    gap: 4px;
}

.page-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ===== DETAIL PAGE ===== */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 20px;
    transition: color 0.2s;
    text-decoration: none;
}

.back-btn:hover { color: var(--accent); }

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
}

.detail-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-title {
    font-size: 22px;
    font-weight: 700;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.info-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.info-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-card-body { padding: 16px 20px; }

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    gap: 16px;
}

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

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 140px;
}

.info-value {
    font-size: 14px;
    font-weight: 500;
    text-align: right;
}

/* Photos */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px 20px;
}

.photo-thumb {
    aspect-ratio: 1;
    border-radius: 10px;
    background: var(--bg);
    border: 2px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.photo-thumb:hover {
    border-color: var(--accent);
    transform: scale(1.03);
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Services table in detail */
.services-table {
    width: 100%;
    border-collapse: collapse;
}

.services-table th {
    background: var(--bg);
    padding: 10px 16px;
    font-size: 12px;
    text-align: left;
}

.services-table td {
    padding: 12px 16px;
    font-size: 14px;
}

.total-row td {
    font-weight: 700;
    border-top: 2px solid var(--border);
}

/* Comment block */
.comment-block {
    background: #fffde7;
    border-left: 4px solid #fdcb6e;
    padding: 14px 18px;
    border-radius: 0 8px 8px 0;
    margin: 12px 20px 16px;
    font-size: 14px;
}

.comment-block strong {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ===== RESPONSIVE ===== */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .mobile-toggle { display: flex; }
    .content { padding: 20px 16px; }
    .header { padding: 0 16px; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .stats-row { grid-template-columns: 1fr; }
    .login-card { padding: 32px 24px; }
    .filters-bar { gap: 6px; }
    .filter-chip { padding: 6px 12px; font-size: 12px; }
}

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 90;
}

.sidebar-overlay.active { display: block; }

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox.active { display: flex; }

.lightbox img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 12px;
}

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

.fade-in { animation: fadeIn 0.3s ease; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* Login error */
.login-errors {
    background: #fdeaea;
    border: 1px solid #f5c6cb;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: var(--danger);
    font-size: 14px;
}
