/* Blue Margin AI Access. Visual language carried over from the approved demo,
   with contrast raised to WCAG AA and keyboard/screen reader fixes. */
:root {
  --navy: #102d57; --blue: #255fc5; --blue-d: #1d50aa; --blue-soft: #eaf1ff; --ink: #10213d;
  --muted: #5b6a82; --label: #56667e; --line: #dbe3ef; --line2: #e8edf5; --soft: #f4f7fb; --white: #fff;
  --green: #08775e; --green-bg: #e7f6f1; --amber: #875000; --amber-bg: #fff1dc; --red: #b22e3c; --red-bg: #fdebed;
  --violet: #5842a0; --violet-bg: #f1edff;
  --shadow: 0 14px 38px rgba(21, 49, 91, .12); --shadow-card: 0 5px 20px rgba(26, 58, 100, .04);
  --focus: rgba(37, 95, 197, .45);
  --font: Inter, 'Segoe UI', Aptos, Calibri, system-ui, -apple-system, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--soft); font-size: 16px; line-height: 1.5; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { color: var(--navy); margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 34px; } h2 { font-size: 24px; } h3 { font-size: 18px; } h4 { font-size: 16px; }
p { margin: 0 0 14px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--navy); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* Shell */
.app { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.side { background: #fff; border-right: 1px solid var(--line); padding: 26px 20px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 11px; align-items: center; margin: 0 8px 30px; text-decoration: none; }
.mark { display: grid; grid-template-columns: 10px 10px; align-items: end; gap: 4px; width: 24px; height: 30px; }
.mark i { display: block; background: var(--blue); border-radius: 2px; height: 30px; }
.mark i:last-child { height: 21px; background: #83a9f0; }
.brand-text strong { display: block; font-size: 20px; color: var(--navy); }
.brand-text small { display: block; color: var(--label); font-size: 10px; letter-spacing: 1.8px; margin-top: 3px; }
.navlabel { font-size: 11px; letter-spacing: 1.5px; color: var(--label); font-weight: 800; margin: 18px 10px 10px; }
.navlabel:first-child { margin-top: 0; }
.nav a { display: flex; gap: 11px; align-items: center; border-radius: 10px; padding: 12px; color: #3d4f6d; font-size: 14px; text-decoration: none; margin-bottom: 4px; }
.nav a:hover, .nav a.active { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.nav svg { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-badge { margin-left: auto; background: var(--blue); color: #fff; font-size: 11px; font-weight: 800; border-radius: 99px; padding: 1px 7px; }
.privacy { margin-top: auto; border: 1px solid var(--line); border-radius: 12px; padding: 14px; color: var(--muted); font-size: 12px; line-height: 1.5; background: #f8faff; }
.privacy strong { display: block; color: var(--navy); font-size: 13px; margin-bottom: 4px; }
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: 72px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 34px; gap: 16px; }
.crumb { font-size: 14px; color: var(--muted); }
.crumb strong { color: var(--navy); }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #4a5a74; }
.avatar { width: 34px; height: 34px; border: 1px solid #d8e2f0; border-radius: 50%; display: grid; place-items: center; background: #f8fbff; color: var(--blue); font-weight: 800; font-size: 13px; }
.content { padding: 36px 4vw 64px; max-width: 1500px; width: 100%; margin: 0 auto; flex: 1; }
.content:focus { outline: none; }
.footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; padding: 14px 34px; border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12px; }
.conn { display: flex; gap: 6px; flex-wrap: wrap; }

/* Headings */
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 0 0 26px; }
.hero h1 { margin: 8px 0 7px; color: #0d2850; }
.hero p { margin: 0; color: var(--muted); line-height: 1.6; max-width: 75ch; }
.eyebrow, .category { font-size: 11px; letter-spacing: 1.6px; color: var(--label); font-weight: 800; text-transform: uppercase; }
.category { margin-bottom: 4px; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { font-size: 28px; margin-top: 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Buttons */
.btn { border: 1px solid #cfd9e9; background: #fff; color: var(--navy); border-radius: 9px; padding: 10px 15px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #8aa8d9; background: #f6f9ff; }
.btn.primary, .btn.accent { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover, .btn.accent:hover { background: var(--blue-d); border-color: var(--blue-d); }
.btn.secondary { background: #fff; }
.btn.ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ok:hover { background: #066450; }
.btn.danger { color: var(--red); border-color: #ecc8cd; background: #fff; }
.btn.danger:hover { background: var(--red-bg); }
.modal .btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.warn { color: var(--amber); border-color: #f0d4a8; background: #fff; }
.btn.warn:hover { background: var(--amber-bg); }
.btn.manager { background: var(--violet-bg); border-color: #d9cffb; color: var(--violet); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--blue); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: none; color: var(--blue); font: inherit; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }

/* Cards */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 17px; align-items: start; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow-card); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.tool-card { display: flex; flex-direction: column; min-height: 206px; }
.tool-card.selected { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.tool-top { display: flex; align-items: center; gap: 12px; }
.tool-top h3 { margin: 0 0 2px; font-size: 17px; }
.tool-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-weight: 900; color: #fff; flex: 0 0 auto; }
.logo-0 { background: #111; } .logo-1 { background: #a2532b; } .logo-2 { background: #2f5fd6; } .logo-3 { background: #156082; } .logo-4 { background: #5842a0; } .logo-5 { background: #08775e; }
.tool-card p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 12px 0 18px; }
.tool-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; }
.tool-card .btn { margin-top: 17px; width: 100%; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 17px; display: flex; flex-direction: column-reverse; justify-content: flex-end; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat .num { font-size: 27px; font-weight: 800; margin-top: 8px; color: var(--navy); line-height: 1.1; }
.stat.alert { border-color: #f0d4a8; background: #fffaf2; }
.stat.alert .num { color: var(--amber); }

/* Forms */
.form-row { margin-bottom: 16px; }
label, .label { display: block; font-size: 13px; font-weight: 750; margin-bottom: 7px; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=url], input[type=email], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; border: 1px solid #b9c6d9; border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 15px; color: var(--ink); background: #fff;
}
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid var(--focus); outline-offset: 0; }
input:disabled, select:disabled, textarea:disabled { background: var(--soft); color: var(--muted); }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.checks label { display: flex; gap: 10px; align-items: center; font-weight: 600; margin: 0; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; font-size: 14px; }
.toolbar .checks { display: flex; align-self: end; }
.toolbar .checks label { border: none; padding: 10px 0; }
.req::after { content: ' Required'; color: #a34848; font-size: 12px; font-weight: 600; margin-left: 4px; }

/* Tables */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--label); background: #f9fbfe; padding: 13px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--line2); font-size: 14px; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tr.clickable:focus td { background: #f1f6ff; }
td .title { font-weight: 700; color: var(--ink); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Pills and status */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 7px; background: #edf3fd; color: #2c5288; white-space: nowrap; }
.pill.good { background: var(--green-bg); color: var(--green); border-radius: 99px; font-weight: 600; }
.pill.warnp { background: var(--amber-bg); color: var(--amber); border-radius: 99px; font-weight: 600; }
.pill[class*=" s-"]::before, .pill[class*=" r-"]::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.s-submitted { background: #e6effd; color: #234f99; }
.pill.s-in-review { background: var(--amber-bg); color: var(--amber); }
.pill.s-needs-info { background: #fff4e5; color: #8a4b00; }
.pill.s-with-manager { background: #ece9ff; color: #5b47a8; }
.pill.s-approved { background: var(--green-bg); color: var(--green); }
.pill.s-denied { background: var(--red-bg); color: var(--red); }
.pill.s-withdrawn { background: #eef1f5; color: #4b5870; }
.pill.s-approver-not-found { background: var(--red-bg); color: var(--red); }
.pill.r-low { background: var(--green-bg); color: var(--green); }
.pill.r-medium { background: var(--amber-bg); color: var(--amber); }
.pill.r-high { background: var(--red-bg); color: var(--red); }
.pill.r-unrated { background: #eef1f5; color: #4b5870; }
.pill.overdue, .pill.off { background: var(--red-bg); color: var(--red); }
.pill.live { background: var(--green-bg); color: var(--green); }
.pill.manual, .pill.flag { background: var(--amber-bg); color: var(--amber); }

/* Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar label { margin-bottom: 4px; font-size: 12px; }
.toolbar select, .toolbar input { min-width: 140px; }

/* Detail */
dl.facts { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 13px; }
dl.facts dd { margin: 0; font-size: 14px; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.section { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 10px; background: #fff; border-left-width: 4px; }
.section.s-pass { border-left-color: var(--green); }
.section.s-concern { border-left-color: #d98b00; }
.section.s-fail { border-left-color: var(--red); }
.section.s-na { border-left-color: #8a99b0; }
.section.s-not-started { border-left-color: var(--line); }
.section-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.section-head h4 { margin: 0; font-size: 15px; }
.section-head select { width: auto; min-width: 140px; }
details.prompts { font-size: 13px; margin-bottom: 8px; }
details.prompts summary { cursor: pointer; color: var(--blue); font-weight: 700; }
details.prompts ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.gate { border-radius: 9px; padding: 11px 12px; margin: 14px 0; font-size: 13px; line-height: 1.45; }
.gate.blocked { background: var(--amber-bg); color: #6e4100; border: 1px solid #f0d4a8; }
.gate.ready { background: var(--green-bg); color: #065a48; border: 1px solid #b9e3d7; }
.gate ul { margin: 4px 0 0; padding-left: 20px; }
.timeline { list-style: none; border-left: 2px solid #dbe5f4; margin: 12px 0 0 7px; padding: 0 0 0 18px; }
.timeline li { margin-bottom: 15px; position: relative; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--blue); left: -24px; top: 4px; }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .what { font-weight: 700; }
.timeline .detail, .timeline-detail { white-space: pre-wrap; overflow-wrap: anywhere; }
.callout { border-radius: 10px; padding: 12px 14px; background: #f2f6fc; color: #1f3556; font-size: 14px; margin-bottom: 16px; line-height: 1.5; }
.callout.warn { background: var(--amber-bg); color: #6e4100; }
.callout.err { background: var(--red-bg); color: #8c1f2c; }
hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 22, 44, .55); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: min(640px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px rgba(0, 0, 0, .25); }
.modal header { padding: 22px 24px 15px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 21px; }
.modal .body { padding: 20px 24px 8px; }
.modal footer { padding: 0 24px 22px; }

/* Toast */
.toast { position: fixed; right: 24px; bottom: 24px; background: #12325e; color: #fff; padding: 14px 17px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; z-index: 60; max-width: 380px; opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
.toast:not(.show) { visibility: hidden; }
.toast.err { background: var(--red); }

/* Loading / sign-in */
.loading { display: grid; place-items: center; padding: 64px 0; color: var(--muted); }
.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .9s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.signin { max-width: 520px; margin: 48px auto; text-align: center; }
.signin .card { padding: 40px 32px; }

.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mb-0 { margin-bottom: 0; } .right { text-align: right; }

/* Responsive: icon rail keeps link names for screen readers (fixes a demo issue) */
@media (max-width: 1000px) {
  .app { grid-template-columns: 84px minmax(0, 1fr); }
  .side { padding: 22px 12px; }
  .brand { justify-content: center; margin: 0 0 24px; }
  .brand-text, .privacy, .navlabel { display: none; }
  .nav a { justify-content: center; position: relative; }
  .nav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-badge { position: absolute; top: 4px; right: 4px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .app { display: block; }
  .side { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 8px; }
  .brand { margin: 0 6px 0 0; }
  .nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .nav a { margin: 0; padding: 10px; }
  .topbar { padding: 0 16px; height: 60px; }
  .user .who { display: none; }
  .content { padding: 22px 15px 50px; }
  .hero { flex-direction: column; align-items: start; }
  h1, .hero h1 { font-size: 28px; }
  .grid-2, .grid-3, .checks { grid-template-columns: 1fr; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dd { margin-bottom: 8px; }
  .footer { padding: 14px 16px; }
  .toast { left: 16px; right: 16px; max-width: none; }
}
.toolbar .checks label { justify-content: flex-start; white-space: nowrap; width: auto; gap: 8px; }

/* IT tickets (additive) */
.pill.s-new { background: #e6effd; color: #234f99; }
.pill.s-in-progress { background: var(--amber-bg); color: var(--amber); }
.pill.s-waiting-on-you { background: #fff4e5; color: #8a4b00; }
.pill.s-resolved { background: var(--green-bg); color: var(--green); }
.pill.s-closed, .pill.s-cancelled { background: #eef1f5; color: #4b5870; }
.pill.p-p1 { background: var(--red-bg); color: var(--red); }
.pill.p-p2 { background: var(--amber-bg); color: var(--amber); }
.pill.p-p3 { background: #e6effd; color: #234f99; }
.pill.p-p4 { background: #eef1f5; color: #4b5870; }
.shots { display: flex; flex-wrap: wrap; gap: 10px; }
.shots .shot { display: block; width: 160px; height: 110px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #f5f7fa; }
.shots .shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
