:root {
  --bg: #f4f6f9; --surface: #fff; --fg: #14202e; --muted: #5b6878; --faint: #8a95a3; --line: #dfe4ea;
  --navy: #0f3d68; --blue: #1565b8; --blue-soft: #e8f0fa; --brand: #00466E;
  --ok: #1f7a4a; --ok-soft: #e6f4ec; --warn: #9a560c; --warn-soft: #fdf1e2; --bad: #b3261e; --bad-soft: #fbe9e8;
  --violet: #5b3fa6; --violet-soft: #efeafb;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; color: var(--fg); background: var(--bg); line-height: 1.45; }
a { color: var(--blue); }
h1 { font-size: 26px; margin: 0; color: var(--fg); font-weight: 650; }
h2 { font-size: 17px; margin: 0; font-weight: 600; }
h3 { font-size: 14px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 12px; }
.boot { padding: 40px; color: var(--muted); }
[hidden] { display: none !important; }

/* forms */
label, .label { display: block; font-size: 13px; font-weight: 600; color: #3c4652; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input:not([type]), select, textarea {
  width: 100%; height: 40px; border: 1px solid #cfd6de; border-radius: 8px; padding: 0 12px; font: inherit; color: var(--fg); background: #fff;
}
textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--fg); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #b9c3ce; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #105aa6; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #e3b4b0; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--blue); padding: 0; height: auto; }
.btn:disabled { opacity: .55; cursor: default; }

.msg { padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.info { background: var(--blue-soft); color: var(--navy); }

/* auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, var(--brand) 0 38%, var(--bg) 38%); }
.auth-card { width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 26px; display: grid; gap: 20px; box-shadow: 0 10px 30px rgba(0,40,70,.12); }
.auth-card h1 { font-size: 20px; }

/* shell */
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100%; }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; }
.brand-row { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.logo { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 800; color: var(--brand); letter-spacing: .04em; background: radial-gradient(circle at 50% 40%, #e6f2fa, #fff 70%); flex: none; }
.brand-name { font-weight: 650; font-size: 16px; }
.brand-sub { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
nav { display: grid; gap: 4px; }
nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--fg); text-decoration: none; font-size: 15px; }
nav a:hover { background: #f1f4f8; }
nav a.active { background: var(--navy); color: #fff; }
nav a .count { margin-left: auto; font-size: 12px; background: #eef1f5; color: var(--muted); border-radius: 999px; padding: 1px 8px; font-weight: 600; }
nav a.active .count { background: rgba(255,255,255,.18); color: #fff; }
nav hr { border: 0; border-top: 1px solid var(--line); margin: 8px 6px; }
nav svg { width: 20px; height: 20px; flex: none; }
.me { margin-top: auto; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.main { padding: 28px 32px 60px; min-width: 0; display: grid; gap: 22px; align-content: start; max-width: 1280px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .effort-row { grid-template-columns: 1fr 1fr 36px; }
  .effort-row .ah { grid-column: 1 / 3; }
  .form-layout, .detail { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; }
  .me { margin-top: 0; }
  .main { padding: 20px 16px 48px; }
}
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.section { display: grid; gap: 14px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.tile { padding: 16px 18px; display: grid; gap: 4px; text-decoration: none; color: inherit; }
.tile .n { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile:hover { border-color: #b9c3ce; }

/* tables */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list th button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
table.list th button[aria-sort] { color: var(--fg); }
table.list td { padding: 13px 16px; border-bottom: 1px solid #edf0f3; vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f8fafc; }
.num { font-variant-numeric: tabular-nums; }
.group-row td { background: #f7f9fb; font-weight: 600; font-size: 13px; color: var(--navy); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-draft { background: var(--warn-soft); color: var(--warn); }
.s-submitted { background: var(--blue-soft); color: var(--blue); }
.s-changes_requested { background: var(--bad-soft); color: var(--bad); }
.s-approving { background: var(--violet-soft); color: var(--violet); }
.s-approved { background: var(--violet-soft); color: var(--violet); }
.s-signed { background: var(--ok-soft); color: var(--ok); }
.s-rejected { background: #eef0f3; color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--blue); }

/* segmented + toggle */
.seg { display: inline-flex; border: 1px solid #cfd6de; border-radius: 9px; padding: 3px; gap: 3px; background: #f6f8fa; flex-wrap: wrap; }
.seg button { border: 0; background: none; font: inherit; padding: 7px 14px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--navy); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px #cfd6de; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 13px; color: #3c4652; }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 12px; background: #cfd6de; position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--blue); }
.switch input:checked::after { left: 19px; }

/* form specifics */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .form-layout { grid-template-columns: 1fr; } }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.preset { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font: inherit; font-weight: 600; text-align: left; color: var(--fg); }
.preset:hover, .preset[aria-expanded="true"] { border-color: var(--blue); }
.preset svg { width: 20px; height: 20px; color: var(--blue); flex: none; }
.preset-pop { border: 1px solid var(--blue); background: var(--blue-soft); border-radius: 10px; padding: 12px 14px; display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.preset-pop input { width: 110px; }
.effort-row { display: grid; grid-template-columns: 110px 120px auto 36px; gap: 8px; align-items: center; }
.ah { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 8px; background: #f3f5f8; color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; }
.ah.on { background: var(--blue-soft); color: var(--blue); }
.icon-btn { width: 36px; height: 36px; border: 0; background: none; border-radius: 8px; color: var(--faint); cursor: pointer; font-size: 20px; line-height: 1; }
.icon-btn:hover { background: #f1f4f8; color: var(--bad); }
.deliv { display: grid; grid-template-columns: 24px minmax(0,1fr) 36px; gap: 8px; align-items: center; }
.deliv .n { color: var(--faint); font-size: 12px; text-align: right; }
.sticky { position: sticky; top: 20px; display: grid; gap: 14px; }
.price-box { display: grid; gap: 8px; }
.price-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.price-line span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.price-total { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 700; }

/* detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } }
.preview { background: #e9edf2; border-radius: var(--radius); padding: 16px; min-height: 480px; overflow: auto; max-height: calc(100vh - 160px); }
.preview .docx-wrapper { background: transparent !important; padding: 0 !important; }
.preview .docx-wrapper > section.docx { box-shadow: 0 2px 10px rgba(0,0,0,.15); margin-bottom: 16px !important; }
.preview iframe { width: 100%; height: calc(100vh - 200px); min-height: 600px; border: 0; background: #fff; border-radius: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.choice { display: grid; gap: 8px; }
.opt { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; display: grid; gap: 2px; cursor: pointer; background: #fff; font: inherit; text-align: left; color: var(--fg); }
.opt strong { font-size: 14px; } .opt small { color: var(--muted); font-size: 12.5px; }
.opt[aria-pressed="true"] { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.timeline { display: grid; gap: 10px; border-left: 2px solid var(--line); padding-left: 14px; font-size: 13px; }
.timeline div span { display: block; color: var(--faint); font-size: 12px; }
.files { display: grid; gap: 6px; }
.file { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; padding: 7px 10px; border: 1px solid #edf0f3; border-radius: 8px; }
.file a { font-weight: 600; text-decoration: none; }
.drop { border: 1.5px dashed #c3ccd6; border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; display: block; }
.drop:hover, .drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop input { display: none; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters input { max-width: 280px; }
.filters select { width: auto; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.pw-reveal { font-family: ui-monospace, Consolas, monospace; background: #f3f5f8; padding: 6px 10px; border-radius: 6px; user-select: all; }
.token-list { display: flex; flex-wrap: wrap; gap: 6px; }
.token-list code { background: #f3f5f8; padding: 2px 7px; border-radius: 5px; font-size: 12px; }
.preset-edit { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 12px; }

/* ---- brand ---- */
.brand-col { display: grid; gap: 10px; padding: 0 8px 4px; }
.km-logo { width: 104px; height: auto; display: block; }
.auth-brand { display: grid; justify-items: center; gap: 12px; text-align: center; }
.km-logo-lg { width: 150px; height: auto; display: block; }

/* ---- PIN sign-in ---- */
.auth-card { max-width: 420px; }
.who-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 360px; overflow: auto; padding: 2px; }
.who { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font: inherit; text-align: left; color: var(--fg); min-width: 0; }
.who:hover { border-color: var(--blue); background: #f8fbff; }
.who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.who .avatar { width: 30px; height: 30px; font-size: 12px; }
.pin-head { text-align: center; display: grid; gap: 4px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 6px 0 2px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #9fb0c2; display: block; transition: background .1s, border-color .1s; }
.pin-dots i.on { background: var(--navy); border-color: var(--navy); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.numpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; }
.numpad button { height: 64px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 24px; font-weight: 600; color: var(--fg); cursor: pointer; touch-action: manipulation; user-select: none; }
.numpad button:hover { background: #f3f6fa; }
.numpad button:active { background: var(--blue-soft); border-color: var(--blue); }
.numpad button.fn { font-size: 14px; color: var(--muted); }
.numpad button:disabled { opacity: .4; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .pin-dots.shake { animation: none; } }

/* ---- library ---- */
.lib-pop { border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 8px 24px rgba(0,30,60,.12); padding: 12px; display: grid; gap: 8px; }
.lib-list { display: grid; gap: 4px; max-height: 300px; overflow: auto; }
.lib-item { text-align: left; border: 1px solid transparent; background: none; border-radius: 8px; padding: 8px 10px; cursor: pointer; font: inherit; color: var(--fg); display: grid; gap: 2px; }
.lib-item:hover { background: #f3f6fa; border-color: var(--line); }
.lib-item small { color: var(--faint); }
.saved-note { font-size: 12px; color: var(--ok); }
.preview-wait { display: grid; place-items: center; gap: 10px; min-height: 420px; color: var(--muted); text-align: center; }
.numpad button.done { grid-column: 1 / -1; height: 52px; font-size: 16px; background: var(--blue); border-color: var(--blue); color: #fff; }
.numpad button.done:disabled { background: #c5d3e2; border-color: #c5d3e2; opacity: 1; }
.pin-dots i.opt { border-style: dashed; }

/* ---- Microsoft sign-in ---- */
.or-rule { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.or-rule::before, .or-rule::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
#msLogin svg { flex: none; }

/* ---- saved deliverables picker ---- */
.saved-dels { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 8px; }
.saved-dels .lib-list { max-height: 260px; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.pick { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 400; font-size: 14px; color: var(--fg); margin: 0; }
.pick:hover { background: #f3f6fa; }
.pick.on { background: var(--blue-soft); }
.pick input { margin-top: 3px; flex: none; width: 16px; height: 16px; }
.pick span { display: grid; gap: 1px; }
.pick small { color: var(--faint); font-size: 12px; }

/* ---- pricing controls that stand out ---- */
.price-card { border: 1.5px solid #9dbbe0; background: linear-gradient(180deg, #f3f8fe, #fff 120px); }
.price-card .section-title { color: var(--navy); }
.seg.strong { background: #fff; border: 1.5px solid #9dbbe0; padding: 4px; gap: 4px; display: flex; width: 100%; }
.seg.strong button { flex: 1 1 auto; color: var(--navy); font-size: 14px; padding: 9px 12px; border: 1px solid transparent; }
.seg.strong button:hover { background: var(--blue-soft); }
.seg.strong button[aria-pressed="true"] { background: var(--blue); color: #fff; box-shadow: 0 1px 3px rgba(21,101,184,.35); }
.price-card .price-total { font-size: 15px; color: var(--navy); }
.btn.secondary { background: var(--blue-soft); border-color: #a9c6e8; color: var(--blue); }
.btn.secondary:hover { background: #dbe8f8; border-color: var(--blue); }

/* ---- SharePoint folder inside PS Doco ---- */
.spo-dlg { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,30,60,.3); color: var(--fg); background: #fff; }
.spo-dlg::backdrop { background: rgba(10,25,45,.45); }
.spo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 16px; margin-top: 4px; }
.crumbs .btn.link { font-size: 16px; }
.crumbs [aria-current] { color: var(--fg); font-weight: 650; }
.crumbs span { color: var(--faint); }
.spo-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px dashed var(--blue); border-radius: 8px; background: var(--blue-soft); color: var(--navy); font-size: 13px; cursor: grab; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip::before { content: "PDF"; font-size: 10px; font-weight: 700; color: #fff; background: var(--bad); border-radius: 3px; padding: 1px 4px; }
.spo-drop { margin: 10px 18px 18px; border: 2px dashed #c3ccd6; border-radius: 12px; overflow: auto; max-height: 52vh; position: relative; }
.spo-drop.over { border-color: var(--blue); background: var(--blue-soft); }
.spo-drop .drop-hint { text-align: center; padding: 14px; color: var(--muted); font-size: 13px; border-top: 1px solid #edf0f3; }
.spo-drop.over .drop-hint { color: var(--blue); font-weight: 600; }
.spo-list td, .spo-list th { padding: 9px 14px; }
