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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    min-height: 100vh;
    background: #f0f2f5;
    color: #333;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: #1e293b;
    color: #fff;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

/* Hamburger */
.hamburger {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    background: #1e293b;
    border: none;
    border-radius: 6px;
    padding: 10px 11px;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

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

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #334155;
}

.sidebar-header h2 {
    font-size: 1.2rem;
}

.nav-links {
    list-style: none;
    padding: 10px 0;
}

.nav-links li a {
    display: block;
    padding: 12px 20px;
    color: #94a3b8;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    font-size: 0.95rem;
}

.nav-links li a:hover,
.nav-links li a.active {
    background: #334155;
    color: #fff;
}

/* Main Content */
.content {
    margin-left: 220px;
    padding: 30px;
    flex: 1;
    width: calc(100% - 220px);
}

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

.page-header h1 {
    font-size: 1.5rem;
    color: #1e293b;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }

.btn-primary { background: #3b82f6; color: #fff; }
.btn-success { background: #22c55e; color: #fff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

/* Tables */
.table-wrapper {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
}

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

table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 22px;
}

th.sortable::after {
    content: '\25B2';
    position: absolute;
    right: 6px;
    opacity: 0.3;
    font-size: 0.5rem;
    letter-spacing: -2px;
}

th.sort-asc::after {
    content: '\25B2';
    opacity: 0.8;
    font-size: 0.6rem;
}

th.sort-desc::after {
    content: '\25BC';
    opacity: 0.8;
    font-size: 0.6rem;
}

table tr:hover { background: #f8fafc; }

table td .actions {
    display: flex;
    gap: 6px;
}

/* Forms */
.form-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 24px;
    max-width: 600px;
}

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

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #475569;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-group textarea { resize: vertical; min-height: 80px; }

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

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-card h3 {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1e293b;
}

.dashboard-section {
    margin-bottom: 30px;
}

.dashboard-section h2 {
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 12px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Delete form inline */
form.inline { display: inline; }

/* Form Validation Errors */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-danger ul {
    margin: 0;
    padding-left: 18px;
}

.alert-danger li {
    margin-bottom: 2px;
}

/* Clickable rows */
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: #e2e8f0; }

/* Detail card */
.detail-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 30px;
    max-width: 800px;
}

.detail-title {
    font-size: 1.4rem;
    color: #1e293b;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.detail-grid {
    display: grid;
    gap: 0;
}

.detail-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.detail-label {
    width: 180px;
    flex-shrink: 0;
    font-weight: 600;
    color: #64748b;
    font-size: 0.9rem;
}

.detail-value {
    color: #1e293b;
    font-size: 0.95rem;
}

/* Mobile styles */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .content {
        margin-left: 0;
        width: 100%;
        padding: 70px 12px 20px;
    }

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

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-left: -12px;
        margin-right: -12px;
        padding: 0 12px;
        width: calc(100% + 24px);
    }

    table {
        min-width: 600px;
    }

    .form-card {
        max-width: 100%;
        padding: 16px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .detail-card {
        max-width: 100%;
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .page-header h1 {
        font-size: 1.2rem;
    }

    .btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

/* Print styles — letter size */
@media print {
    @page {
        size: letter;
        margin: 0.75in;
    }

    body {
        display: block;
        background: #fff;
        color: #000;
    }

    .sidebar, .no-print, .page-header .btn, .page-header a {
        display: none !important;
    }

    .page-header {
        padding: 0;
        margin-bottom: 10px;
    }

    .page-header h1 {
        display: block;
        font-size: 1.3rem;
        color: #000;
    }

    main {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .detail-card {
        box-shadow: none;
        padding: 0;
        max-width: 100%;
    }

    .detail-title {
        font-size: 1.2rem;
        color: #000;
    }

    .detail-label {
        color: #333;
    }

    .detail-value {
        color: #000;
    }

    .badge {
        border: 1px solid #999;
        background: transparent !important;
        color: #000 !important;
    }

    table {
        box-shadow: none;
    }
}
