:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary);
    text-decoration: none;
}

.site-header nav a {
    margin-left: 1.25rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.site-header nav a:hover { color: var(--primary); }

main.container { padding-top: 1.75rem; padding-bottom: 3rem; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.card h1 { margin-top: 0; }

.subtitle { color: var(--muted); margin-top: -0.5rem; }

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
}

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

.alert ul { margin: 0; padding-left: 1.2rem; }

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.1rem;
}

.form-group { display: flex; flex-direction: column; }

.form-group label {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
}

.form-group input,
.form-group select {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    background: var(--muted);
    transition: filter 0.15s ease;
}

.btn:hover { filter: brightness(0.92); }

.btn-primary { background: var(--primary); }
.btn-secondary { background: #4b5563; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }

.btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.summary-item {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.summary-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.summary-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.save-form {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.table-controls { margin-bottom: 0.85rem; }

.table-controls input {
    width: 100%;
    max-width: 320px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

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

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.schedule-table th,
.schedule-table td {
    padding: 0.55rem 0.7rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.schedule-table th:first-child,
.schedule-table td:first-child,
.schedule-table th:nth-child(2),
.schedule-table td:nth-child(2) {
    text-align: left;
}

.schedule-table thead th {
    background: #f9fafb;
    position: sticky;
    top: 0;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--muted);
}

.schedule-table tbody tr:hover { background: #f3f4f6; }

.actions-cell { display: flex; gap: 0.5rem; }

#balance-chart {
    width: 100%;
    max-width: 100%;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafafa;
}

.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 1.5rem 0;
}

@media print {
    .site-header, .site-footer, .form-actions, .save-form, .table-controls, nav { display: none !important; }
    .card { box-shadow: none; border: none; }
    body { background: #fff; }
}

@media (max-width: 640px) {
    .header-inner { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
}
