/* ==========================================================================
   EngMan blue theme (trial)

   Loaded after styles.css. Everything for the new look lives here:
   1. the palette (overrides the variables in styles.css),
   2. shell / hero recolours,
   3. the dashboard project card (.pc-*),
   4. the project overview (.po-*).
   Type sizes, weights, radii and spacing follow styles.css (14px body,
   h1 26px, h2 19px, 11-13px labels, weights 600/700), so these pages
   match the registers. To switch the theme off, remove the theme.css
   <link> in base.html.
   ========================================================================== */

/* ---- 1. Palette --------------------------------------------------------- */

:root {
    /* Neutrals (cool blue-grey) */
    --bg: #f2f5f9;
    --surface: #ffffff;
    --surface-2: #f5f8fb;
    --border: #e2e8f0;
    --border-strong: #c8d4e2;
    --text: #0f1e33;
    --text-soft: #2c3b50;
    --muted: #66768a;

    /* Brand (navy blue) */
    --primary: #12569b;
    --primary-hover: #0d4681;
    --primary-soft: #e7eff8;
    --primary-border: #bcd0e6;
    --primary-light: #7fa6d1;

    /* Brand accent (red), used sparingly */
    --accent: #d7262e;

    /* Shell */
    --shell: #0c335d;
    --shell-2: #134477;
    --shell-fg: #dce7f3;
    --shell-muted: #93abc6;

    /* Semantic */
    --green: #15803d;
    --green-bg: #e3f7ea;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --red: #c1262d;
    --red-bg: #fdeaea;
    --rose: #7a2140;
    --rose-bg: #f6e7ec;
    --blue: #12569b;
    --blue-bg: #e1ecf8;

    --shadow: 0 1px 2px rgba(12, 51, 93, .04), 0 2px 6px rgba(12, 51, 93, .06);
    --shadow-md: 0 6px 18px rgba(12, 51, 93, .09);
    --ring: 0 0 0 3px rgba(18, 86, 155, .25);
}

/* ---- 2. Shell, buttons, dashboard hero ---------------------------------- */

.brand a::before {
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(215, 38, 46, .25);
}

.button-primary {
    box-shadow: 0 1px 2px rgba(18, 86, 155, .3);
}

.chip-scope { background: var(--shell); }
.chip-tech,
.chip-product,
.chip-plant {
    background: #eef2f7;
    color: var(--text-soft);
}

.dashboard-hero {
    background:
        radial-gradient(circle at 88% 15%, rgba(127, 166, 209, .30), transparent 28%),
        linear-gradient(125deg, #0c335d 0%, #12569b 100%);
    box-shadow: 0 14px 30px rgba(12, 51, 93, .18);
}

.eyebrow { color: #bcd4ee; }

/* Small uppercase labels, same as .info-group-title in styles.css. */
.pc-phase-head,
.po-dates dt,
.po-capacity-label,
.po-stage-group h3 {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* ---- 3. Dashboard project card ----------------------------------------- */

.pc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

.pc-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, #3b3f86 55%, var(--accent) 100%);
}

.pc-card:hover {
    border-color: var(--primary-border);
}

.pc-top,
.pc-head,
.pc-phase-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.pc-top { align-items: center; }

.pc-id {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pc-number {
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--shell);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pc-client {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Same size as .badge. */
.pc-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--green-bg);
    color: var(--green);
    font-size: 12px;
    font-weight: 600;
}

.pc-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
}

.pc-name { min-width: 0; }

.pc-name h2 {
    margin: 0;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.pc-sub {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.pc-capacity {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    max-width: 45%;
    text-align: right;
}

.pc-capacity-value {
    color: var(--primary);
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
}

.pc-capacity-label {
    color: var(--muted);
    font-size: 12px;
}

.pc-phase {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.pc-phase-head {
    margin-bottom: 8px;
    color: var(--muted);
}

.pc-phase-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pc-seg-bar {
    display: block;
    height: 6px;
    border-radius: var(--radius-pill);
    background: #e1e7ee;
}

.pc-seg-code {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.pc-seg-done .pc-seg-bar { background: var(--primary-light); }
.pc-seg-current .pc-seg-bar { background: var(--primary); }
.pc-seg-done .pc-seg-code,
.pc-seg-current .pc-seg-code { color: var(--primary); }
.pc-seg-current .pc-seg-code { font-weight: 700; }

.pc-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pc-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.pc-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    text-decoration: none;
}

.pc-stat strong {
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pc-stat-changes.pc-stat-on { background: var(--rose-bg); color: var(--rose); }
.pc-stat-changes.pc-stat-on strong { color: var(--rose); }
.pc-stat-review.pc-stat-on { background: var(--red-bg); color: var(--rose); }
.pc-stat-review.pc-stat-on strong { color: var(--red); }

.pc-stat:hover { filter: brightness(.97); }

/* Same metrics as .button.button-primary, full width. */
.pc-open {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}

.pc-open:hover { background: var(--primary-hover); color: #fff; }

/* ---- 4. Project overview ------------------------------------------------ */

.po-page { padding-top: 0; }

/* Full-width blue band; the cards below overlap its lower edge. */
.po-hero {
    position: relative;
    padding: 24px 0 72px;
    background: var(--primary);
    box-shadow: 0 0 0 100vmax var(--primary);
    clip-path: inset(0 -100vmax);
    color: #fff;
}

.po-hero-top,
.po-hero-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 32px;
}

.po-crumbs {
    display: flex;
    gap: 6px;
    color: #bcd4ee;
    font-size: 13px;
    font-weight: 600;
}

.po-crumbs a { color: #bcd4ee; text-decoration: none; }
.po-crumbs a:hover { color: #fff; }
.po-crumbs span:last-child { color: #fff; }

.po-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.po-title h1 {
    margin: 0;
    color: #fff;
}

/* Same size as .badge. */
.po-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.po-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #bcd4ee;
}

.po-status-active .po-status-dot { background: #4ade80; }
.po-status-on_hold .po-status-dot { background: #fbbf24; }

.po-subtitle {
    margin: 4px 0 0;
    color: #d6e4f3;
}

.po-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Same metrics as .button, recoloured for the blue band. */
.po-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 15px;
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}

.po-btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.po-btn-solid {
    border-color: #fff;
    background: #fff;
    color: var(--primary);
}

.po-btn-solid:hover { background: var(--primary-soft); color: var(--primary-hover); }

.po-hero-bottom {
    margin-top: 24px;
    align-items: flex-start;
}

.po-stepper {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex: 1 1 520px;
    max-width: 900px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.po-step {
    position: relative;
    display: flex;
    flex-direction: column;
    padding-right: 12px;
}

/* Line from this dot to the next one. */
.po-step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 13px;
    left: 38px;
    right: 10px;
    height: 2px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .35);
}

.po-step-done:not(:last-child)::after { background: #fff; }

.po-step-dot {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
    border: 2px solid rgba(255, 255, 255, .55);
    border-radius: 50%;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
}

.po-step-done .po-step-dot {
    border-color: #fff;
    background: #fff;
}

.po-step-current .po-step-dot {
    border: 7px solid #fff;
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .25);
}

.po-step-code {
    font-size: 14px;
    font-weight: 700;
}

.po-step-label {
    color: #d6e4f3;
    font-size: 13px;
}

.po-step-next .po-step-code,
.po-step-next .po-step-label { color: #c4d6ea; }

.po-dates {
    display: flex;
    gap: 36px;
    margin: 0;
    padding-left: 36px;
    border-left: 1px solid rgba(255, 255, 255, .3);
}

.po-dates dt { color: #bcd4ee; }

.po-dates dd {
    margin: 4px 0 0;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

/* Cards: same radius, padding and spacing as .card. */

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

.po-card h2 { margin: 0 0 10px; }

.po-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.po-card-head h2 { margin: 0; }

.po-muted { color: var(--muted); font-size: 13px; }

.po-info {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: -52px;
}

.po-rows { margin: 0; }

.po-rows > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.po-rows > div:last-child { border-bottom: 0; padding-bottom: 0; }

.po-rows dt { color: var(--muted); }

.po-rows dd {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    text-align: right;
}

.po-break { overflow-wrap: anywhere; }

.po-capacity {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.po-capacity-label { color: var(--muted); }

.po-capacity-value {
    color: var(--primary);
    font-size: 19px;
    font-weight: 700;
    line-height: 1.25;
    text-align: right;
}

/* Register counters: six tiles, then Open Changes across the full width. */

.po-counters {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.po-counter {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 22px;
    border-right: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
    transition: background .15s;
}

.po-counter:nth-child(6) { border-right: 0; }
.po-counter:hover { background: var(--surface-2); }

.po-counter .counter-value,
.po-stage .counter-value {
    font-size: 22px;
    line-height: 1.2;
}

.po-counter-wide {
    grid-column: 1 / -1;
    border-right: 0;
    background: var(--blue-bg);
    color: var(--primary);
}

.po-counter-wide:hover { background: #d5e4f4; }
.po-counter-wide .counter-value { color: var(--primary); }

/* Tags status: stages grouped Preparation / Sourcing / Delivery / Closed. */

.po-stage-groups {
    display: grid;
    grid-template-columns: 3fr 3fr 2fr 1.3fr;
    gap: 18px 24px;
}

.po-stage-group h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    color: var(--muted);
}

.po-stage-group h3::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.po-stage-tiles {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 10px;
}

.po-stage {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-top: 3px solid var(--stage-color, var(--border-strong));
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}

.po-stage:hover { background: var(--primary-soft); }

.po-group-prep { --stage-color: #9dbad9; }
.po-group-sourcing { --stage-color: #4a7fb8; }
.po-group-delivery { --stage-color: var(--shell); }
.po-group-delivery .po-stage:last-child { --stage-color: #0b1f36; }

.po-group-closed .po-stage {
    border: 1px dashed var(--border-strong);
    background: transparent;
}

.po-group-closed .counter-value { color: var(--muted); }

.po-attention { border-color: #f3c6c8; }

.po-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 28px 20px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.po-empty strong {
    color: var(--text);
    font-size: 14px;
}

@media (max-width: 1100px) {
    .po-counters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .po-counter:nth-child(3) { border-right: 0; }
    .po-counter:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
    .po-stage-groups { grid-template-columns: 1fr 1fr; }
    .po-dates { padding-left: 0; border-left: 0; }
}

@media (max-width: 720px) {
    .po-hero { padding-bottom: 64px; }
    .po-info { grid-template-columns: 1fr; gap: 0; }
    .po-info .po-card { margin-bottom: 20px; }
    .po-counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .po-counter { padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .po-counter:nth-child(odd) { border-right: 1px solid var(--border); }
    .po-counter:nth-child(even) { border-right: 0; }
    .po-stage-groups { grid-template-columns: 1fr; }
    .po-step-label { display: none; }
}
