.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    max-width: 100%;
    overflow-x: hidden;
}

.main-content > * {
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--space-md, 16px);
}

.grid { display: grid; gap: var(--space-md, 16px); }

.toolbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-actions select { min-width: 190px; }
/* Smart Notifications: span full row so it doesn't leave empty columns */
.alert-panel {
    grid-column: 1 / -1;
}

.ops-band {
    display: grid;
    grid-template-columns: minmax(220px, 0.6fr) 1.4fr;
    gap: 18px;
    align-items: center;
    background: #101827;
    color: #fff;
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 22px;
    border: 1px solid rgba(255,255,255,0.08);
}
.ops-band h2 { color: #fff; margin: 4px 0 0; font-size: 22px; }
.eyebrow { color: #9db7ff; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; }
.role-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.role-metrics div {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 12px;
}
.role-metrics span, .mini-kpi span { display: block; color: var(--ink-3); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.role-metrics span { color: #aebce4; }
.role-metrics strong { display: block; color: #fff; font-size: 18px; margin-top: 4px; }
.kpi-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.kpi-group {
    background: var(--card);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 16px;
}
.kpi-group h3 { font-size: 14px; margin-bottom: 12px; }
.kpi-group > div { display: grid; gap: 8px; }
.mini-kpi {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}
.mini-kpi strong { font-size: 16px; color: var(--ink); text-align: right; }
.ops-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}
.chart-card canvas { width: 100%; display: block; }
.alert-panel { grid-row: span 1; }
.smart-alert {
    display: grid;
    grid-template-columns: 86px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
}
.smart-alert:last-child { border-bottom: 0; }
.smart-alert strong { text-transform: uppercase; font-size: 11px; }
.smart-alert.warning strong { color: var(--warning); }
.smart-alert.danger strong { color: var(--danger); }
.smart-alert.success strong { color: var(--success); }
.smart-alert.info strong, .smart-alert.update strong, .smart-alert.upload strong, .smart-alert.team strong { color: var(--blue); }
.smart-alert span { color: var(--ink); font-weight: 700; }
.smart-alert small { color: var(--ink-3); }
.progress-track { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; min-width: 86px; }
.progress-fill { height: 100%; background: var(--blue); border-radius: inherit; }
.module-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-row input, .filter-row select { max-width: 260px; }
.entity-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.entity-card { cursor: pointer; }
.entity-card .card-header { align-items: flex-start; gap: 10px; }
.kv-list { display: grid; gap: 9px; }
.kv-list div { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.kv-list span { color: var(--ink-3); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.kv-list strong { text-align: right; color: var(--ink); }
.kv-list span,
.kv-list strong {
    min-width: 0;
    overflow-wrap: anywhere;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tab-list { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 4px; }
.tab-button {
    height: 40px;
    padding: 0 14px;
    border: 1.5px solid var(--line);
    background: var(--card);
    color: var(--ink-2);
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}
.tab-button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.timeline { display: grid; gap: 12px; }
.timeline-item { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--blue); margin-top: 6px; }
.evidence-tile {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--bg);
}

.btn-group,
.project-card-actions,
.card-footer {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-group { justify-content: flex-start; }
.card-footer { justify-content: flex-end; }

/* Icon-only action buttons (used in tables, tight spaces) */
.btn-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
}

.btn-icon .icon { width: 16px; height: 16px; }

/* Team card action section — full-width 2-up buttons with text */
.tmc-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--line);
}

.tmc-actions .btn {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    font-size: 13px;
    justify-content: center;
    gap: 6px;
}

.tmc-actions .btn .icon { width: 14px; height: 14px; }
.tmc-actions .btn span { display: inline; }

/* Project card action buttons */
.proj-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    border-radius: var(--radius-md, 10px);
}

.proj-action-btn .icon { width: 15px; height: 15px; }
.proj-action-btn span { display: inline; }

/* Team cards: match entity-grid pattern */
.team-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 4px 0;
}

.team-list {
    display: grid;
    gap: 10px;
}

.team-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.1fr) minmax(120px, .8fr) minmax(180px, 1.2fr) minmax(150px, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.team-row strong,
.team-row span,
.team-row small {
    min-width: 0;
    overflow-wrap: anywhere;
}

.team-row-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--ink-3);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.file-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.file-card {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 12px;
    padding: 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.file-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-l);
    color: var(--blue);
}

.file-icon .icon { width: 22px; height: 22px; }

.file-meta {
    min-width: 0;
}

.file-name {
    display: block;
    color: var(--ink);
    font-weight: 800;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-sub {
    color: var(--ink-3);
    font-size: 12px;
    margin-top: 4px;
}

.file-card .btn-group {
    grid-column: 1 / -1;
    justify-content: flex-start;
}

.file-preview-shell {
    min-height: 280px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview-shell img,
.file-preview-shell iframe {
    width: 100%;
    height: min(68vh, 640px);
    border: 0;
    object-fit: contain;
}

.download-fallback {
    padding: 32px;
    text-align: center;
}

.modal[data-close-on-backdrop="true"] {
    padding: 16px;
}

.modal-content.modal-wide {
    width: min(920px, 96vw);
    max-width: 920px;
}

table {
    table-layout: auto;
}

.card,
.dashboard-header,
.ops-band,
.kpi-group,
.stat-card {
    box-shadow: var(--shadow-sm);
}

.card {
    padding: 18px;
}

.card-header {
    gap: 12px;
}

@media (max-width: 1100px) {
    .ops-grid { grid-template-columns: 1fr 1fr; }
    .team-row { grid-template-columns: 1fr 1fr; }
    .team-row .tmc-actions { justify-content: flex-start; }
}
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .main-content > * { max-width: 100%; }

    /* Team cards: single column on mobile */
    .team-cards-grid {
        grid-template-columns: 1fr !important;
    }

    /* Fix project/supplier grid top gap (cards touching container top) */
    #projectsGrid,
    #suppliersGrid {
        padding-top: 8px !important;
    }
    .ops-band, .ops-grid { grid-template-columns: 1fr; }
    .stats-grid, .kpi-groups, .entity-grid, .file-card-grid, .grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
    .smart-alert { grid-template-columns: 1fr; gap: 2px; }
    .timeline-item { grid-template-columns: 1fr; }
    .toolbar-actions,
    .filter-row,
    .module-toolbar {
        align-items: stretch;
        width: 100%;
    }
    .toolbar-actions > *,
    .filter-row > *,
    .module-toolbar > *,
    .filter-row input,
    .filter-row select {
        width: 100%;
        max-width: 100%;
    }
    /* Full-width buttons on mobile, except icon buttons, proj-action, and btn-group children */
    .btn:not(.btn-icon):not(.proj-action-btn) { width: 100%; }
    .btn-group .btn { width: auto; min-width: 0; }
    .tmc-actions .btn { width: 100%; }

    .team-row {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 14px;
    }
    .file-card {
        grid-template-columns: 38px 1fr;
    }
    .tab-list {
        margin-left: -2px;
        margin-right: -2px;
    }
    .tab-button {
        flex: 0 0 auto;
    }
}
