/*
 * MBorrega SIS — global interface cleanup
 * Corrects crowded layouts, undersized operational text, excessive spacing,
 * and action/header overlap without changing module behavior.
 */

:root {
    --ui-readable-text: 15px;
    --ui-readable-small: 13px;
    --ui-control-height: 42px;
    --ui-space-1: 6px;
    --ui-space-2: 10px;
    --ui-space-3: 14px;
    --ui-space-4: 18px;
}

html { font-size: 16px; }
body { line-height: 1.5; }
img, svg, video, canvas { max-width: 100%; }

/* Authenticated application shell */
.system-app {
    font-size: var(--ui-readable-text);
    line-height: 1.5;
}
.system-app .app-shell { grid-template-columns: 248px minmax(0, 1fr); }
.system-app .sidebar { padding: 18px 12px; overflow-y: auto; overflow-x: hidden; }
.system-app .sidebar-head { margin-bottom: 14px; }
.system-app .brand { gap: 10px; margin-bottom: 0; min-width: 0; }
.system-app .brand-copy { min-width: 0; }
.system-app .brand-copy strong,
.system-app .brand-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.system-app .sidebar-nav { gap: 8px; }
.system-app .nav-section-title { min-height: 36px; padding: 7px 10px; font-size: 12px; }
.system-app .nav-section-items { gap: 3px; }
.system-app .nav-link {
    min-height: 40px;
    padding: 8px 10px;
    gap: 9px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.25;
}
.system-app .nav-link > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }

.system-app .main { min-width: 0; padding: 0; }
.system-app .topbar {
    min-width: 0;
    padding: 16px clamp(16px, 2vw, 24px);
    gap: 14px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.system-app .topbar-leading,
.system-app .topbar-actions,
.system-app .page-heading { min-width: 0; }
.system-app .topbar-leading { flex: 1 1 420px; }
.system-app .topbar-actions {
    flex: 0 1 auto;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}
.system-app .page-heading h1 {
    margin: 2px 0 4px;
    font-size: clamp(24px, 2.2vw, 32px);
    line-height: 1.15;
    letter-spacing: -.02em;
    overflow-wrap: anywhere;
}
.system-app .page-heading p {
    max-width: 76ch;
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
}
.system-app .breadcrumb { font-size: 12px; }
.system-app .page-content {
    width: 100%;
    max-width: 1600px;
    min-width: 0;
    margin-inline: auto;
    padding: clamp(14px, 1.8vw, 24px);
}

/* Readable, compact panels. */
.system-app .panel,
.system-app .metric,
.system-app .dashboard-metric,
.system-app .stat-card {
    min-width: 0;
    padding: clamp(15px, 1.5vw, 20px);
    margin-bottom: 14px;
    border-radius: 13px;
}
.system-app .panel > h2:first-child,
.system-app .panel-heading-row h2,
.system-app .form-heading-row h2,
.system-app .section-heading h2 {
    font-size: 18px !important;
    line-height: 1.25;
}
.system-app h3 { font-size: 16px; line-height: 1.3; }
.system-app :is(p, li, td, dd) { line-height: 1.5; }
.system-app :is(.muted, small, .field-help, .context-help, .help-text) {
    font-size: var(--ui-readable-small) !important;
    line-height: 1.45 !important;
}
.system-app .eyebrow { font-size: 12px; line-height: 1.3; }

/* Headings and actions wrap instead of colliding. */
.system-app :is(.panel-heading-row, .form-heading-row, .page-actions, .heading-actions, .system-action-row, .form-actions, .filter-actions, .record-filter-actions, .welcome-actions, .row-actions, .inline-actions) {
    min-width: 0;
    max-width: 100%;
    gap: 10px;
    flex-wrap: wrap;
}
.system-app :is(.panel-heading-row, .form-heading-row) > :first-child { flex: 1 1 360px; min-width: 0; }
.system-app :is(.panel-heading-row, .form-heading-row) > :last-child:not(:first-child) { flex: 0 1 auto; max-width: 100%; }
.system-app .inline-form { min-width: 0; flex-wrap: wrap; gap: 8px; }

/* Controls retain a readable size across the desktop density layer. */
.system-app label { gap: 6px; font-size: 14px !important; line-height: 1.35; }
.system-app :is(input, select, textarea) {
    min-width: 0;
    max-width: 100%;
    min-height: var(--ui-control-height);
    padding: 9px 11px !important;
    border-radius: 10px;
    font-size: 15px !important;
    line-height: 1.35;
}
.system-app textarea { min-height: 96px; resize: vertical; }
.system-app :is(button, .button, .button-link) {
    min-height: 40px;
    max-width: 100%;
    padding: 9px 13px !important;
    border-radius: 10px;
    font-size: 14px !important;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
}
.system-app .icon-button { min-width: 38px; min-height: 38px; padding: 8px !important; }

/* Stop wide-screen compact mode from shrinking text below an operational size. */
@media (min-width: 1180px) {
    body.desktop-workspace .page-content { padding: 18px 24px 30px; }
    body.desktop-workspace .panel { padding: 16px 18px; }
    body.desktop-workspace .panel-heading-row h2,
    body.desktop-workspace .form-heading-row h2 { font-size: 18px !important; }
    body.desktop-workspace .panel-heading-row p,
    body.desktop-workspace .form-heading-row p,
    body.desktop-workspace .section-heading p,
    body.desktop-workspace .section-heading .muted { font-size: 13px !important; line-height: 1.45; }
    body.desktop-data-workspace table th { font-size: 11px !important; }
    body.desktop-data-workspace table td { font-size: 13.5px !important; line-height: 1.4; }
    body.desktop-form-workspace .form-grid,
    body.desktop-form-workspace .application-section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
}

/* Adaptive grids eliminate overlap and empty space. */
.system-app :is(.metric-grid, .summary-grid, .three-column, .stat-grid) {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
    gap: 12px;
}
.system-app :is(.two-column, .split, .two-column-grid) {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    gap: 14px;
}
.system-app .form-grid,
.system-app .application-section-grid,
.system-app .record-filter-grid {
    min-width: 0;
    gap: 12px 14px;
}
.system-app .summary-grid > :is(div, article) { min-width: 0; padding: 12px; }
.system-app .summary-grid strong { font-size: 15px !important; overflow-wrap: anywhere; }

/* Tables are readable and scroll within their panel instead of the whole page. */
.system-app .table-wrap {
    max-width: 100%;
    overflow: auto;
    overscroll-behavior-inline: contain;
    border-radius: 10px;
}
.system-app table { min-width: 720px; }
.system-app th,
.system-app td { padding: 10px 11px !important; vertical-align: top; }
.system-app th { font-size: 11px !important; line-height: 1.3; }
.system-app td { font-size: 13.5px !important; }
.system-app td :is(small, .muted) { font-size: 12.5px !important; }
.system-app .record-actions { flex-wrap: wrap !important; white-space: normal !important; }

/* Cards and content never escape their columns. */
.system-app :is(.list-card, .quick-action, .application-handoff-card, .application-journey-item, .dashboard-welcome, .notice, .flash, details) {
    min-width: 0;
    overflow-wrap: anywhere;
}
.system-app details > summary { padding-block: 8px; line-height: 1.4; }
.system-app code { max-width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Public pages and application forms use the same readable baseline. */
.public-page { font-size: 16px; line-height: 1.55; }
.public-page :is(input, select, textarea, button, .button) { font-size: 15px; }
.public-page :is(input, select) { min-height: 44px; }
.public-page textarea { min-height: 100px; }
.public-page :is(.public-card, .application-section, .panel) { min-width: 0; }
.public-page :is(.muted, small, .field-help, .context-help) { font-size: 13px; line-height: 1.45; }

@media (max-width: 1100px) {
    .system-app .app-shell { grid-template-columns: minmax(0, 1fr); }
    .system-app .topbar-actions { flex: 1 1 100%; justify-content: flex-start; }
}

@media (max-width: 760px) {
    .system-app .topbar { padding: 13px 14px; }
    .system-app .page-content { padding: 14px; }
    .system-app .panel,
    .system-app .metric,
    .system-app .dashboard-metric,
    .system-app .stat-card { padding: 14px; }
    .system-app .form-grid,
    .system-app .application-section-grid,
    .system-app .record-filter-grid { grid-template-columns: 1fr !important; }
    .system-app :is(.form-grid, .application-section-grid, .record-filter-grid) > * { grid-column: 1 !important; }
    .system-app :is(.panel-heading-row, .form-heading-row) { align-items: stretch; flex-direction: column; }
    .system-app :is(.panel-heading-row, .form-heading-row) > * { width: 100%; }
    .system-app :is(.form-actions, .system-action-row, .filter-actions, .page-actions) > :is(button, .button, .button-link, form) { width: 100%; }
    .system-app :is(.form-actions, .system-action-row, .filter-actions, .page-actions) form > :is(button, .button) { width: 100%; }
    .system-app table { min-width: 640px; }
}

@media print {
    .system-app .page-content { max-width: none; padding: 0; }
}


/* 2026-07-16 audit: stored user avatars and fullscreen control. */
.system-app .user-avatar{overflow:hidden;flex:0 0 auto}
.system-app .user-avatar img{display:block;width:100%;height:100%;object-fit:cover;object-position:center}
.system-app .topbar-icon-button{display:inline-flex;align-items:center;gap:7px;min-height:40px;padding:0 12px;border:1px solid var(--border,#d9e3ef);border-radius:10px;background:#fff;color:var(--text,#17324f);font:inherit;font-weight:700;cursor:pointer}
.system-app .topbar-icon-button:hover{background:#f4f8fc}
@media(max-width:760px){.system-app .topbar-icon-button span{display:none}.system-app .topbar-icon-button{width:40px;justify-content:center;padding:0}}

/* Practical role-workspace context */
.workspace-context-banner{display:flex;align-items:center;gap:10px;margin:0 0 14px;padding:10px 12px;border:1px solid var(--line,#dbe3ec);border-radius:12px;background:var(--surface-soft,#f7f9fc);color:var(--text,#172033)}
.workspace-context-banner>span{display:grid;place-items:center;width:30px;height:30px;border-radius:9px;background:var(--surface,#fff);border:1px solid var(--line,#dbe3ec)}
.workspace-context-banner div{display:grid;gap:2px;min-width:0}.workspace-context-banner strong{font-size:12px}.workspace-context-banner small{font-size:10px;color:var(--muted,#667085);line-height:1.35}

.readiness-check-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px;margin:14px 0}.readiness-check{display:flex;gap:10px;padding:12px;border:1px solid var(--line,#dbe3ec);border-radius:12px;background:var(--surface,#fff)}.readiness-check>span{font-size:9px;font-weight:800;letter-spacing:.08em;min-width:48px}.readiness-check div{display:grid;gap:3px}.readiness-check strong{font-size:12px}.readiness-check small{font-size:10px;color:var(--muted,#667085);line-height:1.4}.readiness-pass>span{color:#047857}.readiness-warn>span,.readiness-manual>span{color:#b45309}.readiness-fail>span{color:#b42318}
