/* Yamato Document System — staff UI.
   Palette and type deliberately mirror the approved proforma so the tool and its
   documents read as one family: navy structure, red only for attention, Helvetica. */
:root {
    --navy: #1F4E79;
    --navy-dark: #173C5E;
    --red: #D7191F;
    --mist: #F2F6FA;
    --mist-2: #E9EFF5;
    --line: #C9D3DE;
    --ink: #1E2A36;
    --muted: #5E6B78;
    --ok: #1E7B34;
    --warn: #A35F00;
    --radius: 6px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: var(--ink); background: var(--mist); line-height: 1.45; }
a { color: var(--navy); }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; }
h1 { font-size: 1.6rem; margin: 0 0 .9rem; color: var(--navy); letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .7rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
code { background: var(--mist-2); padding: .1em .35em; border-radius: 3px; font-size: .9em; }
code.wrap { white-space: pre-wrap; word-break: break-all; }
pre { background: var(--mist); border: 1px solid var(--line); padding: .7rem; white-space: pre-wrap; font-size: .85rem; border-radius: var(--radius); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* top bar: the proforma's navy band with its red rule */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1.5rem; padding: .55rem 1.5rem; border-bottom: 4px solid var(--red); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; font-weight: bold; }
.brand img { height: 34px; background: #fff; border-radius: 4px; padding: 2px 6px; }
.topbar nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; }
.topbar nav a, .topbar nav .soon { color: #DCE6F0; text-decoration: none; padding: .45rem .75rem; border-radius: var(--radius); }
.topbar nav a:hover { background: var(--navy-dark); color: #fff; }
.topbar nav a.on { background: #fff; color: var(--navy); font-weight: bold; }
.topbar nav .soon { opacity: .55; cursor: default; }
.who { display: flex; align-items: center; gap: .9rem; font-size: .9rem; }
.who a, .who .link { color: #DCE6F0; }
.who form { margin: 0; }

main { max-width: 1180px; margin: 1.5rem auto 3rem; padding: 0 1.25rem; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.head h1 { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.crumb { font-size: .85rem; margin-bottom: .2rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 520px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.src { font-size: .75rem; font-weight: normal; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: .05rem .5rem; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.tile { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--navy); border-radius: var(--radius); padding: 1rem 1.2rem; text-decoration: none; color: var(--ink); }
.tile:hover { border-color: var(--navy); }
.tile.muted { border-left-color: var(--line); }
.tile h2 { color: var(--navy); }
.nums { display: flex; flex-direction: column; gap: .15rem; }
.nums b { font-size: 1.25rem; color: var(--ink); margin-right: .25rem; }
.nums .warn b, .nums .warn { color: var(--warn); }

dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0 0 .5rem; }
dt { color: var(--muted); }
dd { margin: 0; }

table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th { text-align: left; font-size: .85rem; color: var(--muted); font-weight: bold; border-bottom: 2px solid var(--line); padding: .5rem .6rem; background: var(--mist-2); }
table.list td { border-bottom: 1px solid var(--mist-2); padding: .55rem .6rem; vertical-align: middle; }
table.list tr.old td { color: var(--muted); }
table.list .actions { justify-content: flex-end; }
.r { text-align: right; }
.list form { margin: 0; display: inline; }

.btn { display: inline-block; font: inherit; font-size: .92rem; padding: .5rem .95rem; border-radius: var(--radius); border: 1px solid var(--navy); background: #fff; color: var(--navy); cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--mist); }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); }
.btn.ghost { border-color: var(--line); color: var(--ink); }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.small { font-size: .82rem; padding: .3rem .65rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }

.badge { display: inline-block; font-size: .75rem; font-weight: bold; padding: .15rem .55rem; border-radius: 99px; background: var(--mist-2); color: var(--navy); }
.badge.ok { background: #E3F2E6; color: var(--ok); }
.badge.warn { background: #FCEFD9; color: var(--warn); }
.tag { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 .3rem; }

.flash { border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1rem; border: 1px solid; background: #fff; }
.flash ul { margin: .35rem 0 0 1.1rem; padding: 0; }
.flash.success { border-color: #9CCBA8; background: #F1FAF3; }
.flash.error { border-color: #EBA1A3; background: #FDF2F2; }
.flash.warning { border-color: #E9C48A; background: #FFF8EC; }
.flash.info { border-color: var(--line); }

form.stack, .stack { display: flex; flex-direction: column; gap: .75rem; }
form.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input:not([type]), input[inputmode] { font: inherit; color: var(--ink); padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; min-width: 0; }
input.ro { background: var(--mist); font-weight: bold; letter-spacing: .03em; }
.search { display: flex; gap: .5rem; margin: .5rem 0 1rem; }
.search input { flex: 1; max-width: 460px; }
.pager { display: flex; gap: 1rem; margin-top: .8rem; }

.vehicle { display: grid; grid-template-columns: 300px 1fr; gap: 1.5rem; }
.photo img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; margin-bottom: .6rem; }
.nophoto { height: 190px; border: 2px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; color: var(--muted); margin-bottom: .6rem; }
table.spec { border-collapse: collapse; width: 100%; margin: .6rem 0 .9rem; }
table.spec th { text-align: left; font-weight: normal; color: var(--muted); padding: .25rem .8rem .25rem 0; width: 34%; white-space: nowrap; }
table.spec td { padding: .2rem .4rem .2rem 0; }
table.spec input { width: 100%; }
.pill { font-size: .72rem; border-radius: 99px; padding: .1rem .5rem; white-space: nowrap; }
.pill.ok { background: #E3F2E6; color: var(--ok); }
.pill.warn { background: #FCEFD9; color: var(--warn); }
.pill.miss { background: #FDE7E7; color: var(--red); }
.pill.staff { background: var(--mist-2); color: var(--navy); }
details summary { cursor: pointer; color: var(--navy); }

.tabs { display: flex; gap: .3rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .5rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.on { color: var(--navy); border-bottom-color: var(--red); font-weight: bold; }

/* sign-in */
body.plain { display: grid; place-items: center; min-height: 100vh; background: var(--navy); }
.authbox { background: #fff; width: min(420px, 92vw); padding: 2rem 2rem 1.5rem; border-radius: 8px; border-top: 5px solid var(--red); }
.authlogo { width: 170px; display: block; margin: 0 auto 1.2rem; }
.qr { display: flex; justify-content: center; margin: .5rem 0; }

@media (max-width: 860px) {
    .grid2, .grid3, .tiles { grid-template-columns: 1fr; }
    .vehicle { grid-template-columns: 1fr; }
    .topbar { padding: .55rem .8rem; gap: .6rem; }
    main { padding: 0 .75rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Phase 3 additions */
.badge.bad { background: #FDE7E7; color: var(--red); }
.big { font-size: 1.35rem; font-weight: bold; margin: .2rem 0; color: var(--navy); }
select, textarea { font: inherit; color: var(--ink); padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
textarea { width: 100%; line-height: 1.45; resize: vertical; }
.formgrid h2 { margin-top: 1rem; }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem 1rem; }
.cols .wide { grid-column: 1 / -1; }
fieldset.section { border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: var(--radius); margin: 1rem 0; padding: .6rem 1rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
fieldset.section legend { color: var(--navy); font-weight: bold; padding: 0 .4rem; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .35rem; }
.help { margin-top: 1rem; }
.help code { display: inline-block; margin: .15rem .1rem; }
.clause { max-width: 75ch; }
h3 { font-size: .95rem; color: var(--navy); margin: 1rem 0 .3rem; }
ol.timeline { list-style: none; padding: 0; margin: 0 0 .6rem; display: flex; flex-direction: column; gap: .35rem; }
ol.timeline li { padding-left: 1.6rem; position: relative; color: var(--muted); }
ol.timeline li::before { content: ""; position: absolute; left: .2rem; top: .35rem; width: .7rem; height: .7rem; border-radius: 50%; border: 2px solid var(--line); background: #fff; }
ol.timeline li.done { color: var(--ink); }
ol.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

/* Zoho → new design mapping tables */
table.spec.map th { color: var(--muted); font-size: .8rem; font-weight: bold; padding-bottom: .4rem; border-bottom: 2px solid var(--line); width: auto; }
table.spec.map td { border-bottom: 1px solid var(--mist-2); padding: .3rem .5rem .3rem 0; vertical-align: middle; }
td.zoho { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .82rem; color: #3B4A5A; }
table.spec.map td.zoho { width: 34%; }

/* Signature & stamp settings */
.brandimg { background: repeating-conic-gradient(#EEF2F6 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--line); border-radius: var(--radius); height: 140px; display: grid; place-items: center; margin-bottom: .8rem; }
.brandimg img { max-height: 120px; max-width: 90%; }

/* Document wording editor */
fieldset.section .item { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: start; }
fieldset.section .item .num { color: var(--muted); padding-top: .55rem; min-width: 1.4rem; }
fieldset.section .item:not(:has(.num)) { grid-template-columns: 1fr auto; }
.card.narrow2 { max-width: 760px; }
ul.clause, ol.clause { padding-left: 1.2rem; margin: .3rem 0 .8rem; }
ul.clause li, ol.clause li { margin-bottom: .3rem; }
