/* ==========================================================================
   EngMan 2.0 - design system
   Local-only, no external fonts or CDNs (uses the system font stack).
   ========================================================================== */

:root {
    /* Neutrals (slate) */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #64748b;

    /* Brand (indigo) */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-border: #c7d2fe;

    /* Accents on the dark shell */
    --shell: #0f172a;
    --shell-2: #1e293b;
    --shell-fg: #e2e8f0;
    --shell-muted: #94a3b8;

    /* Semantic */
    --green: #15803d;
    --green-bg: #dcfce7;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
    --blue: #1d4ed8;
    --blue-bg: #dbeafe;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .10);
    --ring: 0 0 0 3px rgba(79, 70, 229, .25);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

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

h1, h2, h3 {
    color: var(--text);
    letter-spacing: -0.01em;
}

h1 { font-size: 26px; }
h2 { font-size: 19px; }

a {
    color: var(--primary);
}

/* ---- Top shell ---------------------------------------------------------- */

.topbar {
    min-height: 60px;
    padding: 0 24px;
    background: var(--shell);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand a {
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.brand a::before {
    content: "";
    width: 11px;
    height: 11px;
    border-radius: 3px;
    background: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .25);
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--shell-fg);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}

.main-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.main-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.main-nav a.active {
    color: #fff;
    background: var(--primary);
}

.user-area {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    color: var(--shell-fg);
    font-size: 14px;
}

.logout-form {
    display: inline;
}

/* ---- Project context bar ----------------------------------------------- */

.project-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 8px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.project-nav-title {
    color: var(--primary);
    font-weight: 700;
    font-size: 14px;
    margin-right: 12px;
    padding: 4px 10px;
    background: var(--primary-soft);
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.project-nav a {
    color: var(--text-soft);
    text-decoration: none;
    font-size: 14px;
    padding: 7px 12px;
    border-radius: var(--radius-pill);
    transition: background .15s, color .15s;
}

.project-nav a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.project-nav a.active {
    background: var(--primary);
    color: #fff;
}

/* ---- Layout ------------------------------------------------------------- */

.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-header h1 { margin: 0; }
.page-header h2 { margin: 0; }
.page-header p { margin: 4px 0 0; }

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card h2 {
    margin-top: 0;
}

/* ---- Stat cards --------------------------------------------------------- */

.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-title {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-number {
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
}

.stat-link {
    display: block;
    text-decoration: none;
    color: var(--text);
    transition: transform .12s, box-shadow .12s, border-color .12s;
}

.stat-link:hover {
    border-color: var(--primary-border);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-attention {
    border-left: 4px solid var(--amber);
}

/* Coloured stat cards (import preview) */
.stat-green { color: var(--green); }
.stat-blue { color: var(--blue); }
.stat-orange { color: var(--amber); }
.stat-red { color: var(--red); }

.stat-accent-green { border-top: 3px solid var(--green); }
.stat-accent-blue { border-top: 3px solid var(--blue); }
.stat-accent-orange { border-top: 3px solid var(--amber); }
.stat-accent-red { border-top: 3px solid var(--red); }

/* ---- Tables ------------------------------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 14px;
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--surface-2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-strong);
}

tbody tr {
    transition: background .12s;
}

tbody tr:hover td {
    background: var(--primary-soft);
}

td a {
    font-weight: 600;
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

/* ---- Buttons ------------------------------------------------------------ */

.button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    padding: 9px 15px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: background .15s, box-shadow .15s, border-color .15s,
        transform .05s;
}

.button:hover {
    background: var(--surface-2);
    border-color: var(--muted);
}

.button:active {
    transform: translateY(1px);
}

.button-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(79, 70, 229, .3);
}

.button-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.button-danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.button-danger:hover {
    background: #991b1b;
    border-color: #991b1b;
    color: #fff;
}

.button-small {
    padding: 5px 11px;
    font-size: 12px;
}

/* ---- Icon buttons ------------------------------------------------------- */

.actions-col {
    white-space: nowrap;
    width: 1%;
    text-align: right;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-soft);
    text-decoration: none;
    padding: 5px 9px;
    font-size: 15px;
    line-height: 1;
    transition: background .15s, border-color .15s, color .15s;
}

.icon-button:hover {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: var(--primary);
}

.icon-danger {
    color: var(--red);
    border-color: #fecaca;
}

.icon-danger:hover {
    background: var(--red-bg);
    border-color: #fca5a5;
    color: var(--red);
}

/* ---- Forms -------------------------------------------------------------- */

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-soft);
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary);
}

textarea {
    min-height: 120px;
}

.form-field {
    margin-bottom: 16px;
    max-width: 640px;
}

.form-actions {
    margin-top: 22px;
    display: flex;
    gap: 10px;
}

.search-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.search-form input,
.search-form select {
    max-width: 280px;
    width: auto;
    flex: 1 1 180px;
}

/* ---- Badges ------------------------------------------------------------- */

.badge {
    display: inline-block;
    border-radius: var(--radius-pill);
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    background: #e2e8f0;
    color: var(--text-soft);
    white-space: nowrap;
}

/* semantic status badges */
.badge-approved, .badge-green {
    background: var(--green-bg);
    color: var(--green);
}

.badge-review, .badge-orange {
    background: var(--amber-bg);
    color: var(--amber);
}

.badge-blocked, .badge-red {
    background: var(--red-bg);
    color: var(--red);
}

.badge-info {
    background: var(--blue-bg);
    color: var(--blue);
}

.badge-draft {
    background: var(--primary-soft);
    color: var(--primary-hover);
}

.badge-neutral {
    background: #e2e8f0;
    color: var(--muted);
}

/* confirmation status (independent of workflow status) */
.badge-confirmed {
    background: var(--green-bg);
    color: var(--green);
}

.badge-provisional {
    background: var(--amber-bg);
    color: var(--amber);
}

/* a badge that toggles confirmation on click */
button.badge-button {
    border: none;
    cursor: pointer;
    font-family: inherit;
}

button.badge-button:hover {
    filter: brightness(0.96);
}

/* ---- Alerts ------------------------------------------------------------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--green-bg);
    color: #166534;
    border-color: #bbf7d0;
}

.alert-danger, .alert-error {
    background: var(--red-bg);
    color: #991b1b;
    border-color: #fecaca;
}

.alert-warning {
    background: var(--amber-bg);
    color: #92400e;
    border-color: #fde68a;
}

/* ---- Login -------------------------------------------------------------- */

.login-card {
    max-width: 400px;
    margin: 72px auto;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.login-card h1 {
    margin-top: 0;
    margin-bottom: 4px;
}

.login-card label {
    margin-top: 14px;
}

.login-card input {
    margin-bottom: 4px;
}

.login-card .button {
    width: 100%;
    justify-content: center;
    margin-top: 22px;
    padding: 11px;
}

/* ---- Detail grids ------------------------------------------------------- */

.detail-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 12px 16px;
}

.detail-label {
    font-weight: 600;
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

/* ---- Batch entry grid --------------------------------------------------- */

.batch-scroll {
    overflow-x: auto;
    padding: 12px;
}

.batch-table {
    min-width: 100%;
    font-size: 13px;
}

.batch-table th,
.batch-table td {
    padding: 6px 8px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.batch-table th.row-num,
.batch-table td.row-num {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.batch-table input,
.batch-table select {
    min-width: 96px;
    padding: 6px 8px;
    font-size: 13px;
}

.cell-error {
    color: var(--red);
    font-size: 12px;
    margin-top: 4px;
    white-space: normal;
}

/* Bulk actions */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.bulk-bar select {
    width: auto;
    min-width: 190px;
}

.check-col {
    width: 1%;
    text-align: center;
    white-space: nowrap;
}

.check-col input {
    width: auto;
    cursor: pointer;
}

/* ---- Responsive --------------------------------------------------------- */

@media (max-width: 980px) {
    .topbar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 16px;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-container {
        padding: 18px 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 600px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form input,
    .search-form select {
        max-width: none;
    }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 4px 0;
    }

    .detail-label {
        margin-top: 10px;
    }
}

/* ==========================================================
   MODERN DASHBOARD
   ========================================================== */

.dashboard-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    padding: 38px 42px;
    margin-bottom: 22px;
    border-radius: 16px;
    color: #ffffff;
    background:
        radial-gradient(circle at 88% 15%, rgba(74, 144, 226, 0.35), transparent 27%),
        radial-gradient(circle at 70% 100%, rgba(66, 153, 225, 0.18), transparent 33%),
        linear-gradient(125deg, #111c31 0%, #1a3359 55%, #1b4c75 100%);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
}

.dashboard-hero::after {
    content: "";
    position: absolute;
    width: 290px;
    height: 290px;
    right: -110px;
    top: -145px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 50%;
    box-shadow:
        0 0 0 30px rgba(255, 255, 255, 0.025),
        0 0 0 60px rgba(255, 255, 255, 0.02);
}

.dashboard-hero-content,
.dashboard-hero-actions {
    position: relative;
    z-index: 1;
}

.dashboard-hero h1 {
    margin: 8px 0 10px;
    font-size: 32px;
    letter-spacing: -0.7px;
    color: #ffffff;
}

.dashboard-hero p {
    max-width: 610px;
    margin: 0;
    color: rgba(255, 255, 255, 0.76);
    font-size: 15px;
    line-height: 1.6;
}

.eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #a8d5ff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.3px;
}

.eyebrow-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #50d890;
    box-shadow: 0 0 0 5px rgba(80, 216, 144, 0.14);
}

.dashboard-hero-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.button-hero-primary,
.button-hero-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 17px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.button-hero-primary {
    color: #10233d;
    border-color: #ffffff;
    background: #ffffff;
}

.button-hero-primary:hover {
    color: #10233d;
    background: #e8f4ff;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

.button-hero-secondary {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
}

.button-hero-secondary:hover {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.16);
}

.button-icon {
    font-size: 20px;
    font-weight: 400;
    line-height: 12px;
}

/* Small project overview strip */

.dashboard-summary {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 16px 22px;
    margin-bottom: 24px;
    border: 1px solid #e4e9f0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 5px 18px rgba(15, 23, 42, 0.04);
}

.summary-item {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.summary-item strong {
    color: #12233d;
    font-size: 20px;
}

.summary-label {
    color: #728096;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.summary-divider {
    width: 1px;
    height: 28px;
    background: #e5eaf1;
}

.summary-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #24794e !important;
    font-size: 14px !important;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #35b46b;
    box-shadow: 0 0 0 4px rgba(53, 180, 107, 0.12);
}

/* Project cards */

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(355px, 1fr));
    gap: 20px;
}

.project-card {
    overflow: hidden;
    border: 1px solid #e1e7ef;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 7px 22px rgba(15, 23, 42, 0.055);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

.project-card:hover {
    border-color: #b7c9df;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.11);
    transform: translateY(-4px);
}

.project-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 22px 22px 18px;
}

.project-identity {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.project-icon {
    display: flex;
    width: 43px;
    height: 43px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 11px;
    color: #2d6da3;
    background: linear-gradient(145deg, #e5f3ff, #d8ebfa);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.4px;
}

.project-number {
    margin-bottom: 4px;
    color: #45789e;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.75px;
}

/* the badge shows the full project number, so it needs to grow */
.project-icon-number {
    width: auto;
    min-width: 43px;
    padding: 0 12px;
    font-size: 15px;
    letter-spacing: 0.3px;
}

.project-card h2 {
    overflow: hidden;
    max-width: 250px;
    margin: 0;
    color: #17263c;
    font-size: 17px;
    letter-spacing: -0.15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-open-icon {
    display: flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid #e1e8f0;
    border-radius: 9px;
    color: #5c728b;
    background: #f8fafc;
    font-size: 21px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.project-open-icon:hover {
    border-color: #2b78b5;
    color: #ffffff;
    background: #2b78b5;
}

.project-client {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 22px 20px;
}

.client-label {
    color: #98a5b5;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.8px;
}

.client-name {
    overflow: hidden;
    color: #53647a;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 22px;
    padding: 15px 0;
    border-top: 1px solid #e9edf2;
    border-bottom: 1px solid #e9edf2;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 15px;
    border-left: 1px solid #e9edf2;
}

.metric:first-child {
    padding-left: 0;
    border-left: none;
}

.metric-value {
    color: #1f334c;
    font-size: 22px;
    font-weight: 700;
}

.metric-label {
    color: #8190a3;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.project-attention {
    min-height: 83px;
    padding: 18px 22px;
}

.attention-title {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    color: #66788e;
    font-size: 12px;
    font-weight: 700;
}

.attention-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #ffffff;
    background: #8090a3;
    font-size: 11px;
    font-weight: 800;
}

.attention-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modern-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 650;
}

.modern-badge-warning {
    color: #a45b05;
    background: #fff4df;
}

.modern-badge-danger {
    color: #b3333c;
    background: #ffeaec;
}

.modern-badge-success {
    color: #22794b;
    background: #e6f7ed;
}

.badge-check {
    margin-right: 5px;
    font-weight: 900;
}

.project-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 22px;
    border-top: 1px solid #e9edf2;
    background: #fbfcfe;
}

.project-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #648096;
    font-size: 12px;
    font-weight: 650;
}

.project-open-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #236ca6;
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
}

.project-open-button:hover {
    color: #164d7a;
}

.project-open-button span {
    font-size: 17px;
    transition: transform 0.2s ease;
}

.project-open-button:hover span {
    transform: translateX(3px);
}

/* Empty dashboard */

.empty-projects {
    max-width: 720px;
    margin: 55px auto;
    padding: 48px 35px;
    border: 1px solid #e2e9f1;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
    text-align: center;
}

.empty-project-icon {
    display: flex;
    width: 58px;
    height: 58px;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    border-radius: 16px;
    color: #3776a9;
    background: #e8f3fc;
    font-size: 28px;
    font-weight: bold;
}

.empty-projects h2 {
    margin: 0 0 10px;
    color: #1c2d44;
    font-size: 22px;
}

.empty-projects p {
    max-width: 510px;
    margin: 0 auto 24px;
    color: #6f8094;
    line-height: 1.6;
}

.empty-project-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.empty-projects .button-hero-primary {
    color: #ffffff;
    border-color: #2563eb;
    background: #2563eb;
}

.empty-projects .button-hero-primary:hover {
    color: #ffffff;
    background: #1d4ed8;
}

/* Responsive dashboard */

@media (max-width: 850px) {
    .dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 30px;
    }

    .dashboard-hero-actions {
        width: 100%;
    }

    .dashboard-hero-actions .button {
        flex: 1;
    }
}

@media (max-width: 560px) {
    .dashboard-hero {
        padding: 24px;
    }

    .dashboard-hero h1 {
        font-size: 27px;
    }

    .dashboard-hero-actions,
    .empty-project-actions {
        flex-direction: column;
    }

    .dashboard-hero-actions .button,
    .empty-project-actions .button {
        width: 100%;
    }

    .dashboard-summary {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .summary-divider {
        display: none;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Mass & heat balance - stream cards
   ========================================================================== */

.stream-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.stream-card {
    --accent: #64748b;
    --accent-soft: #f1f5f9;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    scroll-margin-top: 16px;
}

.stream-card:target {
    box-shadow: var(--ring), var(--shadow-md);
}

/* Stream medium groups: red = vapour/steam, blue = brine/slurry,
   green = make-up/cooling/sealing/wash water, slate = other. */
.accent-red    { --accent: #dc2626; --accent-soft: #fef2f2; }
.accent-blue   { --accent: #2563eb; --accent-soft: #eff6ff; }
.accent-green  { --accent: #16a34a; --accent-soft: #f0fdf4; }
.accent-slate  { --accent: #64748b; --accent-soft: #f1f5f9; }

/* Excluded from print: faded on screen, hidden in print. */
.stream-card.is-no-print {
    opacity: .6;
    border-left-style: dashed;
}

/* ---- Header ---- */

.stream-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px 24px;
    align-items: center;
    padding: 16px 20px 12px;
    background: linear-gradient(to right, var(--accent-soft), var(--surface) 60%);
    border-bottom: 1px solid var(--border);
}

.stream-id {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stream-no {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    min-width: 56px;
}

.stream-id-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.medium-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.medium-pill b {
    font-weight: 800;
    margin-right: 3px;
}

.stream-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.stream-route {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.route-node {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.route-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.route-name {
    font-weight: 600;
    color: var(--text);
}

.route-arrow {
    color: var(--accent);
    font-size: 20px;
    font-weight: 700;
}

.stream-desc {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--text-soft);
}

/* No-print toggle switch */
.stream-print-toggle { margin: 0; }

.print-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text-soft);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.print-switch:hover { border-color: var(--border-strong); }

.switch-track {
    position: relative;
    width: 30px;
    height: 18px;
    border-radius: var(--radius-pill);
    background: var(--green);
    transition: background .15s;
}

.switch-knob {
    position: absolute;
    top: 2px;
    left: 14px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: left .15s;
}

.print-switch.off { color: var(--red); }
.print-switch.off .switch-track { background: var(--border-strong); }
.print-switch.off .switch-knob { left: 2px; }

/* ---- KPI strip ---- */

.stream-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-bottom: 1px solid var(--border);
}

.kpi {
    display: flex;
    flex-direction: column;
    padding: 10px 20px;
    border-right: 1px solid var(--border);
}

.kpi:last-child { border-right: 0; }

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}

.kpi-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.kpi-value small {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}

/* ---- Body ---- */

.stream-body {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.2fr) minmax(0, .8fr);
}

.stream-section {
    padding: 14px 20px 16px;
    border-right: 1px solid var(--border);
}

.stream-section:last-child { border-right: 0; }

.section-title {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.section-title + table + .section-title,
.props-table + .section-title {
    margin-top: 16px;
}

.phase-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.phase {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.phase-head {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    color: var(--text);
    font-size: 13px;
}

.phase-units {
    font-weight: 500;
    font-size: 11px;
    color: var(--muted);
}

.phase-na {
    border-style: dashed;
    background: var(--surface-2);
}

.phase-na .phase-head {
    color: var(--muted);
    background: transparent;
}

.phase-empty {
    margin: 0;
    padding: 18px 10px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
}

/* Compact numeric tables inside the card */
.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.mini-table th,
.mini-table td {
    padding: 4px 10px;
    border: 0;
    border-bottom: 1px solid var(--surface-2);
    background: none;
    text-align: left;
}

.mini-table th {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
}

.mini-table .num { text-align: right; white-space: nowrap; }
.mini-table .pct { color: var(--muted); width: 1%; }
.mini-table tr.is-zero td { color: var(--muted); }

.mini-table tfoot td {
    border-top: 1px solid var(--border);
    border-bottom: 0;
    font-weight: 700;
    color: var(--text);
    background: var(--surface-2);
}

.props-table td:first-child { color: var(--text-soft); }
.props-table th,
.props-table td { padding-left: 0; }
.props-table .unit { width: 1%; }

.unit {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.na {
    color: #cbd5e1;
    font-style: italic;
    font-weight: 400;
}

.kv-list { margin: 0; }

.kv {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px solid var(--surface-2);
    font-size: 13px;
}

.kv dt { color: var(--text-soft); }

.kv dd {
    margin: 0;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kv-na dt,
.kv-na dd { color: #cbd5e1; font-weight: 400; }

.stream-pipe { background: var(--surface-2); }

.soon-badge {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    background: var(--amber-bg);
    color: var(--amber);
    font-size: 10px;
    letter-spacing: .02em;
    text-transform: none;
}

.pipe-hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.stream-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.line-chip {
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
    text-decoration: none;
    font-weight: 600;
}

.stream-empty { text-align: center; }

@media (max-width: 1150px) {
    .stream-body { grid-template-columns: 1fr 1fr; }
    .stream-composition {
        grid-column: 1 / -1;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
}

@media (max-width: 760px) {
    .stream-head { grid-template-columns: 1fr; }
    .stream-kpis { grid-template-columns: 1fr 1fr; }
    .kpi:nth-child(2) { border-right: 0; }
    .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
    .stream-body,
    .phase-grid { grid-template-columns: 1fr; }
    .stream-section { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* Print / PDF: only streams without "No print". */
@media print {
    .topbar,
    .project-nav,
    .stream-filters,
    .header-actions,
    .stream-print-toggle,
    .alert,
    .stream-card.is-no-print {
        display: none !important;
    }

    body { background: #fff; }
    .page-container { max-width: none; padding: 0; }

    .stream-card {
        box-shadow: none;
        break-inside: avoid;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .stream-body { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.2fr) minmax(0, .8fr); }
    .stream-composition { grid-column: auto; border-right: 1px solid var(--border); border-bottom: 0; }
}

.chip-row { display: flex; gap: 4px; }
.chip-row .stream-chip { margin-right: 0; }

.button:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Project schedule progress bar ------------------------------------- */

.project-schedule { padding: 0 22px 16px; }

/* narrower than the card so it reads as a compact indicator */
.project-schedule .schedule-head,
.project-schedule .progress-track { width: 78%; }

.schedule-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 7px;
}

.schedule-date { font-variant-numeric: tabular-nums; }
.schedule-state { font-weight: 700; }
.schedule-on-track { color: var(--green); }
.schedule-due-soon { color: var(--amber); }
.schedule-overdue { color: var(--red); }
.schedule-set { color: var(--primary); font-weight: 600; text-decoration: none; }
.schedule-set:hover { text-decoration: underline; }

.progress-track {
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width .4s ease;
}

.progress-on-track { background: var(--green); box-shadow: 0 0 8px rgba(21, 128, 61, .55); }
.progress-due-soon { background: var(--amber); box-shadow: 0 0 8px rgba(180, 83, 9, .55); }
.progress-overdue  { background: var(--red);   box-shadow: 0 0 8px rgba(185, 28, 28, .55); }
.progress-empty { background: transparent; }

/* ---- Recent activity feed ---------------------------------------------- */

.activity-section { margin-top: 24px; }

.activity-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.activity-header h2 { margin: 0; }

.activity-list { list-style: none; margin: 0; padding: 0; }

.activity-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 2px;
    border-bottom: 1px solid var(--border);
}

.activity-row:last-child { border-bottom: none; }

.activity-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-created { background: var(--green); }
.activity-updated { background: var(--blue); }
.activity-deleted { background: var(--red); }
.activity-changed { background: var(--muted); }

.activity-text a { color: var(--text); font-weight: 600; text-decoration: none; }
.activity-text a:hover { color: var(--primary); }
.activity-text strong { color: var(--text); }

.activity-action {
    color: var(--muted);
    font-size: 12px;
    margin-left: 6px;
    text-transform: capitalize;
}

.activity-meta {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.activity-empty { padding: 16px 2px; }

/* ---- Section placeholder ----------------------------------------------- */

.placeholder-card { text-align: center; padding: 48px 24px; }
.placeholder-icon { font-size: 44px; margin-bottom: 8px; }
.placeholder-card h2 { margin: 0 0 8px; }
.placeholder-card p { max-width: 520px; margin: 0 auto; }

/* ---- Mass & heat balance import ---- */

.stoff-panel {
    margin-top: 14px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.stoff-panel summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
}

.compact-table th,
.compact-table td {
    padding: 6px 10px;
    font-size: 13px;
}

.import-help { margin: 0; padding-left: 18px; }
.import-help li { margin-bottom: 6px; }

.import-stats { grid-template-columns: repeat(5, 1fr); }

.import-table td { vertical-align: top; }
.import-table tr.import-unchanged td { color: var(--muted); }
.import-table tr.import-error td { background: var(--red-bg); }

.import-warning {
    color: var(--amber);
    font-size: 13px;
}

.import-changes summary {
    cursor: pointer;
    color: var(--blue);
    font-size: 13px;
    font-weight: 600;
}

.change-table { margin-top: 4px; width: auto; }

.change-table td {
    padding: 2px 8px 2px 0;
    border: 0;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    background: none;
}

.change-table .old { color: var(--muted); text-decoration: line-through; }
.change-table .new { color: var(--text); font-weight: 600; }

@media (max-width: 760px) {
    .import-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Stoff codes ---- */

.stoff-scroll { overflow-x: auto; }
.stoff-table { min-width: 1100px; }
.stoff-table th,
.stoff-table td { white-space: nowrap; }
.stoff-table .group-start { border-left: 2px solid var(--border-strong); }
.stoff-table td.na { color: #cbd5e1; }

.stoff-form-head {
    display: grid;
    grid-template-columns: 160px 1fr 1fr;
    gap: 16px;
}

.stoff-slot-groups {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 16px;
    margin-top: 8px;
}

.stoff-slot-groups fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px 12px;
    margin: 0;
}

.stoff-slot-groups legend {
    padding: 0 6px;
    font-weight: 700;
    color: var(--text);
}

.slot-field {
    display: grid;
    grid-template-columns: 70px 1fr;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.slot-field span {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

@media (max-width: 900px) {
    .stoff-form-head,
    .stoff-slot-groups { grid-template-columns: 1fr; }
}
