/* PRC design system - formal, compact, Andel-branded.
   Palette anchored to the Andel logo: steel blue, cyan, lime; neutral greys carry the page. */

:root {
    --c-primary: #205a86;
    --c-primary-dark: #17425f;
    --c-accent: #35b3e3;
    --c-green: #6d8f1c;
    --c-green-bg: #eef4d9;
    --c-amber: #8a5a00;
    --c-amber-bg: #fdf3d7;
    --c-red: #a4321f;
    --c-red-bg: #fbe9e5;
    --c-slate: #4a5568;
    --c-slate-bg: #e9edf2;
    --c-blue-bg: #e1f2fb;
    --c-text: #1d2733;
    --c-muted: #5b6774;
    --c-border: #d8dee5;
    --c-bg: #f4f6f8;
    --c-surface: #ffffff;
    --c-thead: #eef2f6;
    --c-zebra: #f8fafc;
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.45;
}

/* Header */
.site-header {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    box-shadow: 0 1px 2px rgba(29, 39, 51, 0.04);
}

.site-header .bar {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--c-text);
}

.brand img { height: 30px; width: auto; display: block; }

.brand .app-name {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-left: 1px solid var(--c-border);
    padding-left: 0.6rem;
    color: var(--c-primary-dark);
}

.site-nav { margin-left: auto; display: flex; gap: 0.25rem; flex-wrap: wrap; }

.site-nav a {
    text-decoration: none;
    color: var(--c-muted);
    font-size: 0.9rem;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    border-bottom: 2px solid transparent;
}

.site-nav a:hover { color: var(--c-primary); background: var(--c-thead); }

.site-nav a.active {
    color: var(--c-primary-dark);
    font-weight: 600;
    border-bottom-color: var(--c-accent);
}

.dev-role {
    font-size: 0.75rem;
    color: var(--c-muted);
    border: 1px dashed var(--c-border);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    white-space: nowrap;
}

.dev-role a { margin-left: 0.3rem; text-decoration: none; color: var(--c-muted); }
.dev-role a.active { color: var(--c-primary-dark); font-weight: 700; }

/* Signed-in chip (AppManaged auth): name + sign-out inline in the header */
.user-chip { border-style: solid; display: inline-flex; align-items: center; gap: 0.45rem; }
.user-chip form { display: inline; margin: 0; }
.user-chip button { font-size: 0.75rem; padding: 0.1rem 0.45rem; }

/* Sign-in page */
.login-wrap { max-width: 22rem; margin: 3rem auto 0; }
.login-wrap h1 { margin-bottom: 0.1rem; }

/* Layout */
main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 3rem;
}

h1 { font-size: 1.35rem; font-weight: 600; margin: 0.25rem 0 0.35rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 0.5rem; color: var(--c-primary-dark); }
h3 { font-size: 0.95rem; font-weight: 600; margin: 1.1rem 0 0.4rem; }

.page-lede { color: var(--c-muted); margin: 0 0 1rem; font-size: 0.92rem; }

a { color: var(--c-primary); }
a:hover { color: var(--c-primary-dark); }

/* Cards and tiles */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 0.9rem 1.1rem;
}

.tiles { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 0.75rem 0 0.25rem; }

.tile {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 0.7rem 1rem;
    min-width: 10.5rem;
    text-decoration: none;
    color: var(--c-text);
    display: block;
}

a.tile:hover { border-color: var(--c-accent); box-shadow: 0 1px 3px rgba(53, 179, 227, 0.25); }

.tile .tile-title { font-weight: 600; color: var(--c-primary-dark); font-size: 0.95rem; }
.tile .tile-desc { color: var(--c-muted); font-size: 0.82rem; margin-top: 0.15rem; }
.tile .tile-count { font-size: 1.7rem; font-weight: 600; color: var(--c-primary-dark); line-height: 1.1; }
.tile .tile-label { color: var(--c-muted); font-size: 0.8rem; }

/* Tables - compact operational */
table.tbl {
    border-collapse: collapse;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    font-size: 0.88rem;
    min-width: 40rem;
}

table.tbl th {
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--c-muted);
    background: var(--c-thead);
    padding: 0.4rem 0.65rem;
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}

table.tbl td {
    padding: 0.35rem 0.65rem;
    border-bottom: 1px solid #e7ecf1;
    vertical-align: top;
}

table.tbl tbody tr:nth-child(even) { background: var(--c-zebra); }
table.tbl tbody tr:hover { background: #f0f7fc; }

/* Completed items scan green at a glance */
table.tbl tbody tr.row-done,
table.tbl tbody tr.row-done:nth-child(even) { background: #f3f8ea; }
table.tbl tbody tr.row-done td:first-child { box-shadow: inset 3px 0 0 var(--c-green); }
table.tbl tbody tr.row-done:hover { background: #edf5e0; }

/* Items waiting on someone else (from the current role's point of view) */
table.tbl tbody tr.row-waiting,
table.tbl tbody tr.row-waiting:nth-child(even) { background: #fcf9f0; }
table.tbl tbody tr.row-waiting td:first-child { box-shadow: inset 3px 0 0 #e3c56b; }

/* The row just acted on glows briefly, then settles back to its own colour: the keyframe only
   sets the start, so the animation ends on whatever the row's cascade resolves to. */
@keyframes prc-row-flash {
    from { background-color: #ffe89a; }
}

table.tbl tbody tr.row-flash { animation: prc-row-flash 2s ease-out; }

/* Status messages float so they are visible wherever the reader is on the page */
.alert.toast {
    position: fixed;
    top: 0.9rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    box-shadow: 0 3px 12px rgba(29, 39, 51, 0.25);
    max-width: min(46rem, 90vw);
    font-weight: 600;
}

.alert.error.toast { border-width: 2px; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .muted { color: var(--c-muted); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--c-slate-bg);
    color: var(--c-slate);
}

.badge.gate-G1Scope { background: var(--c-slate-bg); color: var(--c-slate); }
.badge.gate-G2ApprovedForTrial { background: var(--c-amber-bg); color: var(--c-amber); }
.badge.gate-G3Validated { background: var(--c-blue-bg); color: var(--c-primary); }
.badge.gate-G4Released { background: var(--c-green-bg); color: var(--c-green); }

.badge.st-NotStarted { background: var(--c-slate-bg); color: var(--c-slate); }
.badge.st-InReview { background: var(--c-amber-bg); color: var(--c-amber); }
.badge.st-Approved, .badge.st-Pass { background: var(--c-green-bg); color: var(--c-green); }
.badge.st-Amend, .badge.st-Repeat { background: var(--c-red-bg); color: var(--c-red); }
.badge.st-Waived { background: var(--c-blue-bg); color: var(--c-primary); }

.badge.carry-Unchanged { background: var(--c-slate-bg); color: var(--c-slate); }
.badge.carry-Changed { background: var(--c-amber-bg); color: var(--c-amber); }
.badge.carry-New { background: var(--c-blue-bg); color: var(--c-primary); }

.badge.badge-sm { font-size: 0.64rem; padding: 0 0.4rem; }

/* Gate stepper - a didactic breadcrumb; gates only ever move forward one step.
   The full track always shows all four gates; a green marker points at the current one and the
   TD's advance button hangs under the gate it moves to. */
.gate-steps {
    display: flex;
    align-items: flex-start;
    list-style: none;
    margin: 0 0 1rem;
    padding: 1.35rem 0.9rem 0.7rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    flex-wrap: wrap;
    row-gap: 0.6rem;
}

.gate-step { display: flex; flex-direction: column; position: relative; }

.gate-step-main { display: flex; align-items: center; gap: 0.45rem; }

/* Connector segments sit between steps, aligned to the dot centres */
.gate-link {
    width: 2.2rem;
    height: 2px;
    background: var(--c-border);
    margin: calc(0.775rem - 1px) 0.7rem 0;
    flex-shrink: 0;
}

.gate-link.done { background: var(--c-primary); }

/* The you-are-here marker: a green arrow pointing down at the current gate's dot */
.gate-here {
    position: absolute;
    top: -1rem;
    left: 0.775rem;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 0.55rem solid transparent;
    border-right: 0.55rem solid transparent;
    border-top: 0.8rem solid var(--c-green);
}

.gate-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 50%;
    border: 2px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-muted);
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.gate-step.done .gate-dot { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.gate-step.current .gate-dot { border-color: var(--c-green); color: var(--c-primary-dark); }

.gate-step-name { font-size: 0.85rem; color: var(--c-muted); white-space: nowrap; }
.gate-step.done .gate-step-name { color: var(--c-text); }
.gate-step.current .gate-step-name { color: var(--c-primary-dark); font-weight: 700; font-size: 0.9rem; }

/* The advance button sits on its own row below the track, left-aligned */
.gate-actions { flex-basis: 100%; margin-top: 0.55rem; }

.gate-advance { white-space: nowrap; }

/* Forms and buttons */
input, select, button, textarea { font: inherit; }

input[type="text"], input:not([type]), select, textarea {
    padding: 0.28rem 0.5rem;
    border: 1px solid #c3cbd4;
    border-radius: 4px;
    background: var(--c-surface);
    color: var(--c-text);
}

input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: 1px;
}

button, .btn {
    padding: 0.28rem 0.8rem;
    border: 1px solid #b9c2cc;
    border-radius: 4px;
    background: var(--c-surface);
    color: var(--c-text);
    cursor: pointer;
}

button:hover, .btn:hover { background: var(--c-thead); border-color: #9aa6b2; }

button.primary {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
    font-weight: 600;
}

button.primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }

label { font-size: 0.85rem; color: var(--c-muted); font-weight: 600; }

.field { margin: 0 0 0.7rem; }
.field label { display: block; margin-bottom: 0.15rem; }
.card .field input, .card .field select { width: 100%; }

fieldset {
    border: 1px solid var(--c-border);
    border-radius: 6px;
    margin: 0 0 0.9rem;
    padding: 0.6rem 0.9rem 0.75rem;
    background: var(--c-surface);
}

legend { font-size: 0.8rem; font-weight: 600; color: var(--c-primary-dark); padding: 0 0.35rem; }

/* Label/input pair grids (Promotions page fieldsets) */
fieldset.pairs { display: grid; grid-template-columns: 13rem minmax(14rem, 28rem); gap: 0.3rem 0.75rem; align-items: center; }
fieldset.pairs legend { grid-column: 1 / -1; }

/* Alerts */
.alert {
    border: 1px solid;
    border-radius: 4px;
    padding: 0.45rem 0.75rem;
    font-size: 0.9rem;
    margin: 0.5rem 0 0.9rem;
    max-width: 46rem;
}

.alert.error { background: var(--c-red-bg); border-color: #e5b7ae; color: var(--c-red); }
.alert.info { background: var(--c-blue-bg); border-color: #b5dff2; color: var(--c-primary-dark); }

/* Detail page helpers */
.meta-line { display: flex; align-items: center; gap: 0.6rem; color: var(--c-muted); font-size: 0.9rem; margin: 0.1rem 0 0.9rem; flex-wrap: wrap; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.inline-form { display: inline-flex; align-items: center; gap: 0.25rem; margin: 0.1rem 0.35rem 0.1rem 0; }
.stack > * { display: block; margin-bottom: 0.25rem; }
.actions-cell { min-width: 21rem; }
.actions-cell form { display: flex; align-items: center; gap: 0.25rem; margin: 0 0 0.25rem; flex-wrap: wrap; }
.actions-cell input[name="justification"] { width: 9.5rem; }
.actions-cell input[name="approverRole"] { width: 3.2rem; }
.evidence-cell form { display: flex; align-items: center; gap: 0.25rem; margin: 0.15rem 0; flex-wrap: wrap; }
.evidence-cell select { max-width: 13rem; }

.doc-link { display: inline-flex; align-items: center; gap: 0.3rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 0.9rem; align-items: start; }

.check-grid { columns: 2; column-gap: 1.5rem; font-weight: 400; }
.check-grid label { display: block; font-weight: 400; color: var(--c-text); font-size: 0.86rem; margin: 0.1rem 0; }

.back-link { font-size: 0.85rem; }

.item-title { font-weight: 600; }
.item-sub { color: var(--c-muted); font-size: 0.78rem; }

/* Footer */
.site-footer {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem 1.5rem;
    color: var(--c-muted);
    font-size: 0.78rem;
    border-top: 1px solid var(--c-border);
}

/* Responsive: let wide tables scroll rather than break the page */
.tbl-wrap { overflow-x: auto; }

@media (max-width: 760px) {
    .site-header .bar { flex-wrap: wrap; }
    .site-nav { margin-left: 0; }
    .check-grid { columns: 1; }
}
