/* AOPACK Dealer Portal — brand blue from the AOPACK logo (#5078A0). */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dde3ec;
  --border-strong: #c5cfdc;
  --text: #1c2533;
  --muted: #5d6b80;
  --brand: #5078a0;
  --primary: #2f6da8;
  --primary-hover: #275d90;
  --ok: #157a52;   --ok-bg: #e7f6ef;
  --warn: #8a5a00; --warn-bg: #fff4dc;
  --err: #b42323;  --err-bg: #fdecec;
  --info: #24588a; --info-bg: #e8f1fb;
  --radius: 10px;
  --focus: 0 0 0 3px rgba(47, 109, 168, .35);
  font-size: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
h1 { font-size: 1.55rem; line-height: 1.25; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .9rem; }
h3 { font-size: 1rem; margin: 1.4rem 0 .6rem; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-line; overflow-wrap: anywhere; }

/* top bar */
.topbar { background: #1f2f44; color: #fff; }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 8px; color: #fff; text-decoration: none; }
.brand .mark { font-weight: 800; letter-spacing: .08em; font-size: 1.15rem; }
.brand .sub { color: #b9c8da; font-size: .9rem; }
.brand:hover { color: #fff; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #d6e1ee; text-decoration: none; padding: 8px 12px; border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; }
.signout { display: flex; align-items: center; gap: 10px; margin: 0; }
.signout .who { color: #b9c8da; font-size: .9rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 6px 4px; }

main { padding-top: 28px; padding-bottom: 40px; }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 28px; }

/* cards and layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 440px; margin: 24px auto; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 6px; font-size: .9rem; text-decoration: none; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 18px; align-items: start; }
.stack > * + * { margin-top: 14px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.req-note { font-size: .75rem; font-weight: 600; color: var(--err); background: var(--err-bg); border-radius: 999px; padding: 2px 8px; vertical-align: middle; margin-left: 6px; }

/* forms */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .9rem; }
.req { color: var(--err); margin-left: 3px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 11px; min-height: 42px;
}
textarea { resize: vertical; }
input[type="file"] { font: inherit; padding: 8px 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible {
  outline: none; box-shadow: var(--focus); border-color: var(--primary);
}
.has-error input, .has-error select, .has-error textarea { border-color: var(--err); }
.hint { margin: 0; color: var(--muted); font-size: .82rem; }
.inline { display: flex; gap: 8px; align-items: stretch; }
.inline input { flex: 1; min-width: 0; }
.inline .btn { white-space: nowrap; }
.check-result { margin: 0; font-size: .88rem; font-weight: 600; min-height: 0; }
.check-result:empty { display: none; }
.check-result.exists, .check-result.limited, .check-result.error { color: var(--err); }
.check-result.free { color: var(--ok); }
.err { margin: 0; color: var(--err); font-size: .85rem; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 9px 18px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); color: #fff; }
.btn.block { width: 100%; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger:hover { background: #8f1c1c; color: #fff; }
form.answer { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* notices and badges */
.notice { border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid transparent; }
.notice.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe6d3; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: #f1d9a4; }
.notice.error { background: var(--err-bg); color: var(--err); border-color: #f3c2c2; }
.notice.info { background: var(--info-bg); color: var(--info); border-color: #c8dcf1; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.approved { background: var(--ok-bg); color: var(--ok); }
.badge.returned { background: var(--err-bg); color: var(--err); }
.badge.change { background: var(--info-bg); color: var(--info); }

/* tabs and tables */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; border: 1px solid transparent; }
.tabs a:hover { background: var(--surface); color: var(--text); }
.tabs a[aria-current="page"] { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; }
.count { display: inline-block; min-width: 22px; text-align: center; background: var(--bg); border-radius: 999px; font-size: .78rem; padding: 0 6px; margin-left: 2px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list thead th { background: var(--surface-2); color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--surface-2); }
table.list td a { font-weight: 600; text-decoration: none; }
table.compact th, table.compact td { padding: 8px 10px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* details and follow-ups */
dl.details { margin: 0; display: grid; gap: 10px; }
dl.details > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; }
dt { color: var(--muted); font-size: .88rem; }
dd { margin: 0; }
.addfu { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.fu { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.fu:last-child { border-bottom: 0; }
.fu-date { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.fu-body p { margin: 0 0 6px; }
.files { margin: 0 0 6px; padding-left: 18px; }

@media (max-width: 860px) {
  .columns { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .inline { flex-direction: column; }
  .card { padding: 16px; }
  .topbar-inner { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .signout .who { display: none; }
  dl.details > div { grid-template-columns: 1fr; gap: 2px; }
  .fu { grid-template-columns: 1fr; gap: 4px; }
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
  table.list td { border: 0; padding: 3px 16px; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: baseline; }
  table.list td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; }
  table.list td[data-label="Company"] { font-size: 1.02rem; }
  table.list td[data-label="Status"] { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
  table.list td[data-label="Status"]::before { width: 112px; flex: none; }
  table.list.compact td::before { content: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
