:root {
    --blue: #2563eb;
    --white: #ffffff;
    --gray: #f5f5f5;
    --gray-border: #e5e7eb;
    --text: #1f2937;
    --text-muted: #6b7280;
    --green: #22c55e;
    --red: #ef4444;
    --radius: 12px;
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    --font-size: 16px;
    --input-height: 44px;
    --btn-height: 44px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    font-size: var(--font-size);
    color: var(--text);
    background: var(--gray);
    line-height: 1.5;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.app-header {
    margin-bottom: 24px;
}

.app-header h1 {
    margin: 0 0 8px;
    font-size: 2rem;
    color: var(--blue);
}

.subtitle {
    margin: 0;
    color: var(--text-muted);
}

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

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

.stat-label {
    display: block;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    color: var(--blue);
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card h2 {
    margin: 0 0 20px;
    font-size: 1.25rem;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

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

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.search-box input {
    width: 100%;
    min-height: var(--input-height);
    padding: 10px 14px;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    font: inherit;
    background: var(--white);
}

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

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--btn-height);
    padding: 0 18px;
    border-radius: var(--radius);
    border: none;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-success {
    background: var(--green);
    color: var(--white);
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--text);
}

.btn-outline {
    background: var(--white);
    color: var(--blue);
    border: 1px solid var(--blue);
}

.btn-small {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.875rem;
}

.btn-edit {
    background: var(--blue);
    color: var(--white);
}

.btn-danger {
    background: var(--red);
    color: var(--white);
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
}

.search-box {
    flex: 1 1 260px;
}

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

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border: 1px solid var(--gray-border);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.data-table th {
    background: #e8eef9;
    color: var(--text);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.data-table tbody tr:hover {
    background: #f0f7ff;
}

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

.inline-form {
    display: inline;
}

.empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 12px;
}

.hidden-row {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.print-only {
    display: none;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .export-actions,
    .form-actions {
        width: 100%;
    }

    .export-actions .btn,
    .form-actions .btn {
        flex: 1 1 calc(50% - 6px);
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 0.875rem;
    }
}

@media print {
    body {
        background: var(--white);
    }

    .app {
        max-width: none;
        padding: 0;
    }

    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
        margin-bottom: 16px;
    }

    .card {
        box-shadow: none;
        padding: 0;
    }

    .data-table th,
    .data-table td {
        font-size: 11px;
        padding: 6px 8px;
        border: 1px solid #ccc;
        white-space: normal;
    }

    .data-table th {
        background: #e8eef9;
    }
}
