/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: var(--color-white);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
    box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; box-shadow: 0 6px 14px rgba(15, 149, 227, 0.3); }
.btn:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-secondary { background: var(--color-white); color: var(--color-primary); border: 1px solid var(--color-border); box-shadow: none; }
.btn-secondary:hover { background: var(--color-bg-alt); border-color: var(--color-primary); box-shadow: none; }

.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #B83838; box-shadow: 0 6px 14px rgba(214, 69, 69, 0.3); }
.btn-success { background: var(--color-success); }
.btn-success:hover { background: #17804A; box-shadow: 0 6px 14px rgba(31, 157, 85, 0.3); }
.btn-block { width: 100%; }

/* Cards */
.card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s var(--ease);
}

/* Badges / status pills */
.badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: var(--radius-lg);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--color-white);
    background: var(--color-text-muted);
}
.badge-primary { background: var(--color-primary); }
.badge-success { background: var(--color-success); }
.badge-warning { background: var(--color-warning); }
.badge-danger  { background: var(--color-danger); }

/* Dashboard stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
@media (min-width: 600px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: var(--radius-md);
    font-size: 1.3rem;
    background: var(--color-primary-tint);
    color: var(--color-primary);
    flex-shrink: 0;
}
.stat-icon.accent  { background: var(--color-accent-tint); color: var(--color-primary-dark); }
.stat-icon.warning { background: #FBF3DC; color: var(--color-warning); }
.stat-icon.success { background: #E4F6EA; color: var(--color-success); }

.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--color-heading); line-height: 1.1; }
.stat-label { font-size: 0.8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* Tabs */
.tab-nav {
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-4);
    gap: var(--space-1);
}
.tab-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: var(--space-3) var(--space-3);
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}
.tab-btn:hover { color: var(--color-primary); }
.tab-btn.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fadeIn 0.15s var(--ease); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 50, 0.5);
    backdrop-filter: blur(2px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: var(--space-3);
    animation: fadeIn 0.15s var(--ease);
}
.modal-overlay.is-open { display: flex; }
.modal {
    background: var(--color-white);
    border-radius: var(--radius-md);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.18s var(--ease);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 var(--space-1);
}

/* Crucial note banner */
.crucial-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    background: #FDEAEA;
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
}
.crucial-banner .crucial-icon { font-size: 1.4rem; flex-shrink: 0; }
.crucial-banner .crucial-text { font-weight: 700; color: #8A1F1F; flex: 1; }
.crucial-banner .crucial-edit-link { font-size: 0.85rem; font-weight: 600; flex-shrink: 0; }

/* Notes list */
.note-item {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
}
.note-item:last-child { border-bottom: none; }
.note-meta { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 2px; }

/* Forms */
.form-row { margin-bottom: var(--space-3); }
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
}
@media (min-width: 600px) {
    .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
    .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* Data tables — collapse to stacked cards below tablet width so nothing requires horizontal scrolling on a phone. */
.data-table thead { display: none; }
.data-table, .data-table tbody, .data-table tr, .data-table td {
    display: block;
    width: 100%;
}
.data-table tr {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-3);
    padding: var(--space-2) var(--space-3);
    transition: box-shadow 0.15s var(--ease);
}
.data-table td {
    border: none;
    padding: var(--space-1) 0;
    text-align: left;
}
.data-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
}

@media (min-width: 768px) {
    .data-table thead { display: table-header-group; }
    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: revert;
        width: revert;
    }
    .data-table {
        background: var(--color-white);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }
    .data-table tr { box-shadow: none; }
    .data-table tbody tr { transition: background 0.12s var(--ease); }
    .data-table tbody tr:hover { background: var(--color-bg-alt); }
    .data-table th, .data-table td {
        padding: var(--space-3);
        border-bottom: 1px solid var(--color-border);
        text-align: left;
    }
    .data-table tbody tr:last-child td { border-bottom: none; }
    .data-table th {
        background: var(--color-bg-alt);
        color: var(--color-heading);
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }
    .data-table td::before { content: none; }
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
    animation: fadeIn 0.2s var(--ease);
}
.alert-success { background: #EAF7EE; color: #166B3A; border: 1px solid #BFE6CD; }
.alert-error   { background: #FBEAEA; color: #A23030;  border: 1px solid #F2C5C5; }
