/* OMNIFIN CRM — Haupt-Stylesheet */
@import url('themes.css');
@import url('components/sidebar.css');
@import url('components/topbar.css');
@import url('components/cards.css');
@import url('components/tables.css');
@import url('components/forms.css');
@import url('components/modals.css');
@import url('components/badges.css');
@import url('components/kanban.css');
@import url('components/phone-guide.css');
/* brand.css wird als separates <link> nach app.css geladen — nicht per @import,
   damit brand.css-Regeln in der Kaskade nach app.css-Regeln kommen und sauber überschreiben. */

/* ─── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-display);  /* Manrope — Luminous Slate editorial typography */
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition), color var(--transition);
}

/* ─── App-Layout ─────────────────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition);
}

.app-content {
    flex: 1;
    padding: 1.75rem 2rem;
    margin-top: var(--topbar-height);
    max-width: 1600px;
    width: 100%;
}

/* ─── Typografie ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

strong, b { font-weight: 600; }

code {
    font-family: var(--font-mono);
    font-size: .875em;
    background: var(--bg-elevated);
    padding: .15em .4em;
    border-radius: var(--radius-sm);
    color: var(--accent);
}

/* ─── Page-Header ────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header-left { display: flex; align-items: center; gap: .5rem; }
.page-header-left > div { display: flex; flex-direction: column; gap: .25rem; }

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.page-subtitle {
    font-size: .875rem;
    color: var(--text-muted);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex-wrap: wrap;
}

/* ─── Breadcrumbs ────────────────────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: .375rem;
    font-size: .825rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.breadcrumb a:hover { color: var(--accent); }

.breadcrumb-sep { color: var(--border-strong); }

.breadcrumb-current { color: var(--text-primary); font-weight: 500; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4375rem;
    padding: .5625rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    user-select: none;
}

.btn:hover { text-decoration: none; }

.btn:disabled, .btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-sm {
    padding: .375rem .75rem;
    font-size: .8125rem;
    border-radius: var(--radius-sm);
    gap: .3125rem;
}

.btn-lg {
    padding: .75rem 1.5rem;
    font-size: 1rem;
}

/* Varianten */
.btn-primary {
    background: var(--grad);
    color: var(--text-on-brand, #fff);
    -webkit-text-fill-color: var(--text-on-brand, #fff);
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(53,193,239,.20);
}
.btn-primary:hover {
    background: var(--grad);
    border-color: transparent;
    box-shadow: var(--glow-btn);
    transform: translateY(-1px);
    color: var(--text-on-brand, #fff);
    -webkit-text-fill-color: var(--text-on-brand, #fff);
}
.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-ghost svg { color: inherit; }

.btn-danger {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline:hover { background: var(--accent-light); }

.btn-danger-outline {
    background: transparent;
    color: var(--error);
    border-color: var(--error);
}
.btn-danger-outline:hover { background: var(--error-bg); }

.btn-danger-ghost {
    padding: .5rem;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.btn-danger-ghost:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: transparent;
}

.btn-icon {
    padding: .5rem;
    border-radius: var(--radius);
    background: transparent;
    border: 1.5px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Ensure SVG icons inside btn-ghost/btn-icon always inherit button text color */
.btn-ghost svg, .btn-icon svg, .btn-danger-ghost svg {
    pointer-events: none;
}

/* ─── Alerts & Flash Messages ────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .875rem 1.125rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
}

.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error   { background: var(--error-bg);   color: var(--error-text); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-info    { background: var(--info-bg);    color: var(--info-text); }

.alert-icon { flex-shrink: 0; margin-top: .1rem; }

/* ─── Grid & Layout-Helfer ───────────────────────────────────────────────── */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.gap-3  { gap: 1.5rem; }
.gap-4  { gap: 2rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

/* ─── Spacing ────────────────────────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.ml-auto { margin-left: auto; }

/* ─── Text-Utilities ─────────────────────────────────────────────────────── */
.text-sm    { font-size: .8125rem; }
.text-xs    { font-size: .75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-warning { color: var(--warning); }
.font-bold    { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Divider ────────────────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
    gap: 1rem;
}

.empty-state-icon {
    width: 60px; height: 60px;
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}

.empty-state h3 { font-size: 1.05rem; color: var(--text-secondary); }
.empty-state p  { font-size: .875rem; max-width: 360px; }

/* ─── Spinner ────────────────────────────────────────────────────────────── */
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

/* ─── Avatar ─────────────────────────────────────────────────────────────── */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    color: #fff;
    background: var(--accent);
    flex-shrink: 0;
    user-select: none;
}

.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar-md { width: 36px; height: 36px; font-size: .825rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-xl { width: 64px; height: 64px; font-size: 1.25rem; }

/* ─── KPI-Karten ─────────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.375rem 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: box-shadow var(--transition);
}

.kpi-card:hover { box-shadow: var(--shadow); }

/* Alert variant — dunning/escalation warning */
.kpi-card.kpi-card-alert {
    border-color: rgba(239,68,68,.35);
    background: rgba(239,68,68,.03);
}
[data-theme="dark"] .kpi-card.kpi-card-alert {
    border-color: rgba(239,68,68,.30);
    background: rgba(239,68,68,.05);
}

.kpi-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    /* Default: brand azure tint */
    background: rgba(53,193,239,.10);
    color: var(--accent);
}

/* Semantic KPI icon variants — use these instead of hardcoded inline styles */
.kpi-icon-accent  { background: rgba(53,193,239,.10);  color: var(--accent); }
.kpi-icon-violet  { background: rgba(93,51,162,.10);   color: #8b5cf6; }
.kpi-icon-success { background: rgba(16,185,129,.10);  color: var(--success); }
.kpi-icon-warning { background: rgba(245,158,11,.10);  color: var(--warning); }
.kpi-icon-error   { background: rgba(239,68,68,.10);   color: var(--error); }
.kpi-icon-info    { background: rgba(59,130,246,.10);  color: #3b82f6; }

[data-theme="dark"] .kpi-icon-accent  { background: rgba(53,193,239,.12); }
[data-theme="dark"] .kpi-icon-violet  { background: rgba(93,51,162,.14); }
[data-theme="dark"] .kpi-icon-success { background: rgba(16,185,129,.12); }
[data-theme="dark"] .kpi-icon-warning { background: rgba(245,158,11,.12); }
[data-theme="dark"] .kpi-icon-error   { background: rgba(239,68,68,.12); }
[data-theme="dark"] .kpi-icon-info    { background: rgba(59,130,246,.12); }

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: .25rem;
    color: var(--text-primary);
}

.kpi-label {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.kpi-trend {
    font-size: .8rem;
    font-weight: 600;
    margin-top: .375rem;
}

.kpi-trend.up   { color: var(--success); }
.kpi-trend.down { color: var(--error); }

/* ─── List Items (Entity-Listen) ─────────────────────────────────────────── */
.list-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-hover); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-title a { color: var(--text-primary); text-decoration: none; }
.list-item-title a:hover { color: var(--accent); text-decoration: none; }
.list-item-sub { font-size: .8125rem; color: var(--text-muted); margin-top: .125rem; }
.list-item-meta { font-size: .8125rem; color: var(--text-muted); flex-shrink: 0; }

/* ─── Detail-List (Schlüssel-Wert-Paare) ─────────────────────────────────── */
.detail-list {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: .625rem 1rem;
    font-size: .9375rem;
}
.detail-list dt { color: var(--text-muted); font-weight: 500; }
.detail-list dd { color: var(--text-primary); word-break: break-word; }

/* ─── Timeline ───────────────────────────────────────────────────────────── */
.timeline { padding: 1rem 1.5rem; display: flex; flex-direction: column; gap: 0; }

.timeline-item {
    display: flex;
    gap: .875rem;
    padding: .875rem 0;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin-top: .1rem;
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1.5px solid var(--border);
}
.timeline-icon--note    { background: var(--accent-light); color: var(--accent); border-color: rgba(var(--accent-rgb),.30); }
.timeline-icon--call    { background: rgba(16,185,129,.10); color: var(--success); border-color: rgba(16,185,129,.25); }
.timeline-icon--email   { background: rgba(53,193,239,.10); color: var(--accent); border-color: rgba(53,193,239,.25); }
.timeline-icon--meeting { background: rgba(245,158,11,.10); color: var(--warning); border-color: rgba(245,158,11,.25); }
.timeline-icon--system  { background: var(--bg-elevated); color: var(--text-muted); border-color: var(--border); }

.timeline-content { flex: 1; min-width: 0; }

.timeline-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .25rem;
    flex-wrap: wrap;
}

.timeline-author { font-weight: 600; font-size: .875rem; color: var(--text-primary); }
.timeline-time   { font-size: .8125rem; color: var(--text-muted); }
.timeline-text   { font-size: .9375rem; color: var(--text-primary); white-space: pre-line; word-break: break-word; }

/* ─── Filter Row ─────────────────────────────────────────────────────────── */
.filter-row {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex-wrap: wrap;
}
.filter-group { display: flex; align-items: center; gap: .5rem; }

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: .625rem;
    color: var(--text-muted);
    pointer-events: none;
}
.search-input { padding-left: 2.125rem !important; min-width: 220px; }

/* ─── Action Group ───────────────────────────────────────────────────────── */
.action-group { display: inline-flex; gap: .25rem; align-items: center; }

/* ─── Form Actions ───────────────────────────────────────────────────────── */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
/* When form-actions is the card-footer itself, reset margin/border (card-footer already has them) */
.card-footer.form-actions {
    margin-top: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ─── Tab Navigation ─────────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
}
.tab-nav::-webkit-scrollbar { display: none; }

/* ─── Settings Tab-Nav: 2-Zeilen Register-Stil ───────────────────────────── */
.settings-tab-nav {
    /* Kein border-bottom – eigenes Container-Design */
    border-bottom: none;
    overflow-x: visible;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .375rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.75rem;
}

/* Pill-Stil für Settings-Tabs (überschreibt allgemeinen .tab-item) */
.settings-tab-nav .tab-item {
    border-bottom: none;
    margin-bottom: 0;
    border-radius: var(--radius-sm);
    padding: .4375rem .875rem;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}

.settings-tab-nav .tab-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-tab-nav .tab-item.active {
    background: var(--bg-surface);
    color: var(--accent);
    font-weight: 600;
    border-bottom: none;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px var(--border);
}

/* Zeilenumbruch-Trenner zwischen Reihe 1 und Reihe 2 */
.settings-tab-sep {
    flex-basis: 100%;   /* erzwingt Zeilenumbruch */
    height: 1px;
    background: var(--border);
    margin: .125rem -.375rem;
    display: block;
}
.tab-item {
    padding: .625rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-item:hover { color: var(--text-primary); background: var(--bg-hover); text-decoration: none; }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── Misc Utilities ─────────────────────────────────────────────────────── */
.fw-600  { font-weight: 600; }
.fw-700  { font-weight: 700; }
.overdue { color: var(--error); }
.row-muted td { opacity: .7; }

/* ─── Checkbox Button ────────────────────────────────────────────────────── */
.btn-check {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color var(--transition);
}
.btn-check:hover { color: var(--success); }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .875rem 1.5rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}
.pagination-info { font-size: .8125rem; color: var(--text-muted); }
.pagination-controls { display: flex; align-items: center; gap: .25rem; }
.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px; height: 32px;
    padding: 0 .5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--bg-surface);
    transition: all var(--transition);
}
.pagination-btn:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--accent); text-decoration: none; }
.pagination-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Table Link / Extra ─────────────────────────────────────────────────── */
.table-link { color: var(--text-primary); text-decoration: none; }
.table-link:hover { color: var(--accent); text-decoration: none; }

/* ─── Table in card: auto-scroll wrapper ─────────────────────────────────── */
.card:has(> table.table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ─── .table — universal table style (alias für .data-table) ─────────────── */
table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
table.table thead th {
    background: var(--table-header-bg, var(--bg-elevated));
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .75rem 1.125rem;
    text-align: left;
    border-bottom: 1px solid var(--table-border, var(--border));
    white-space: nowrap;
}
table.table tbody tr {
    border-bottom: 1px solid var(--table-border, var(--border));
    transition: background var(--transition);
}
table.table tbody tr:last-child { border-bottom: none; }
table.table tbody tr:hover { background: var(--table-row-hover, var(--bg-hover)); }
table.table td {
    padding: .875rem 1.125rem;
    color: var(--text-primary);
    vertical-align: middle;
}
table.table th:first-child,
table.table td:first-child { padding-left: 1.25rem; }
table.table td.text-right,
table.table th.text-right { text-align: right; }
table.table td.nowrap { white-space: nowrap; }

/* row highlight for overdue */
.row-overdue td { background: rgba(239,68,68,.04); }
[data-theme="dark"] .row-overdue td { background: rgba(239,68,68,.08); }

/* filter row inside card body */
.filter-row-card {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex-wrap: wrap;
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

/* ─── Section Headings ───────────────────────────────────────────────────── */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Form section title — tonal divider, replaces raw <hr> */
.form-section-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin: 1.75rem 0 1.25rem;
    padding-bottom: .625rem;
    border-bottom: 1px solid var(--border);
}

/* Tonal <hr> replacement — use instead of bare <hr> inside cards/forms */
hr.section-rule,
.section-rule {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

/* Tablet (≤ 1024px) */
@media (max-width: 1024px) {
    .app-main { margin-left: 0; }
    .app-content { padding: 1.25rem; }
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }

    /* Tables: horizontal scroll on small containers */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Forms: reduce two-column grids */
    .form-grid-2 { grid-template-columns: 1fr; }
}

/* Mobile (≤ 768px) */
@media (max-width: 768px) {
    .app-content { padding: 1rem; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: .75rem;
    }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; justify-content: center; }

    /* All multi-column grids → single column */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 { grid-template-columns: 1fr; }

    /* KPI grid: 2 per row on mobile */
    .kpi-grid { grid-template-columns: 1fr 1fr; }

    /* Cards: remove horizontal overflow */
    .card { overflow-x: hidden; }

    /* Tables: make all tables scrollable on mobile */
    .card > .table,
    .table-wrapper > .table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Hide less-important table columns */
    .table th.hide-mobile,
    .table td.hide-mobile { display: none; }

    /* Detail list: single column */
    .detail-list { grid-template-columns: 1fr; gap: .25rem; }
    .detail-list .detail-label { color: var(--text-muted); font-size: .8rem; padding-bottom: 0; }

    /* Filter row: wrap fully */
    .filter-row { flex-direction: column; align-items: stretch; }
    .filter-row .form-control { width: 100%; }
    .filter-row .btn { width: 100%; justify-content: center; }

    /* Modals: full-width on mobile */
    .modal-dialog { max-width: 100% !important; margin: .5rem !important; }
    .modal-body { padding: 1rem; }
}

/* Small mobile (≤ 480px) */
@media (max-width: 480px) {
    .app-content { padding: .875rem; }

    h1.page-title { font-size: 1.25rem; }

    /* KPI grid: single column on very small screens */
    .kpi-grid { grid-template-columns: 1fr; }

    /* Buttons in tight spaces */
    .btn-lg { padding: .625rem 1rem; font-size: .9rem; }

    /* Tab items: smaller padding */
    .tab-item { padding: .5rem .75rem; font-size: .8rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   GLOBAL ACTION BUTTON STANDARDS
   Exactly 3 variants: btn-action-edit | btn-action-delete | modal-close
   These rules use !important on visual properties so no other class
   can accidentally override color, border or background.
   ═══════════════════════════════════════════════════════════════════ */

/* Base icon-only button — fixed-size utility (not a primary action style) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius, 6px);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    flex-shrink: 0;
    background: transparent;
}
.btn-icon.btn-sm { width: 28px; height: 28px; }
.btn-icon.btn-lg { width: 36px; height: 36px; }

/* ── EDIT — neutral outline, icon + text ─────────────────────────── */
.btn-action-edit,
.btn-action-edit:link,
.btn-action-edit:visited {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: .35rem !important;
    width: auto !important;
    height: auto !important;
    padding: .3rem .75rem !important;
    font-size: .8rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    border-radius: var(--radius, 6px) !important;
    border: 1px solid var(--border, rgba(255,255,255,.15)) !important;
    background: transparent !important;
    color: var(--text-secondary, #9CA3AF) !important;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none !important;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-action-edit:hover {
    color: var(--text-primary, #e8f0ff) !important;
    background: var(--bg-elevated, rgba(255,255,255,.08)) !important;
    border-color: var(--border-hover, rgba(255,255,255,.25)) !important;
}

/* ── DELETE — always red, icon + text ────────────────────────────── */
.btn-action-delete,
.btn-action-delete:link,
.btn-action-delete:visited {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: .35rem !important;
    width: auto !important;
    height: auto !important;
    padding: .3rem .75rem !important;
    font-size: .8rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    border-radius: var(--radius, 6px) !important;
    border: 1px solid rgba(239,68,68,.35) !important;
    background: rgba(239,68,68,.06) !important;
    color: #ef4444 !important;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none !important;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-action-delete:hover {
    background: rgba(239,68,68,.15) !important;
    border-color: rgba(239,68,68,.55) !important;
    color: #f87171 !important;
}

/* Alias — btn-danger-outline kept for legacy HTML that still uses it */
.btn-danger-outline,
.btn-danger-outline:link,
.btn-danger-outline:visited {
    color: #ef4444 !important;
    border-color: rgba(239,68,68,.35) !important;
    background: rgba(239,68,68,.06) !important;
}
.btn-danger-outline:hover {
    background: rgba(239,68,68,.15) !important;
    border-color: rgba(239,68,68,.55) !important;
}

/* ── MODAL CLOSE — X icon only ───────────────────────────────────── */
.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius, 6px);
    background: transparent;
    color: var(--text-secondary, #9CA3AF);
    cursor: pointer;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.modal-close:hover {
    background: var(--bg-elevated, rgba(255,255,255,.08));
    color: var(--text-primary, #fff);
}

/* ─── Print ──────────────────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .page-actions, .btn { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { margin-top: 0 !important; padding: 0 !important; }
}
