:root {
  --teal: #005D63;
  --teal-dark: #00474c;
  --teal-tint: #e3f0f0;
  --orange: #E65300;
  --orange-tint: #fff0e6;
  --cream: #faf6f4;
  --ink: #1f2324;
  --muted: #6b7273;
  --line: #e4e0dd;
  --card: #ffffff;
  --ok: #1f7a46;
  --ok-tint: #e5f4ea;
  --warn: #9a5b00;
  --warn-tint: #fff4dc;
  --bad: #b3261e;
  --bad-tint: #fde8e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cream); font-size: 14px; line-height: 1.45; }
a { color: var(--teal); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; font-size: 26px; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* Top bar */
.topbar { background: var(--teal); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 54px; position: sticky; top: 0; z-index: 20; }
.brand { font-family: 'DM Serif Display', Georgia, serif; font-size: 22px; color: #fff; text-decoration: none; letter-spacing: .01em; }
.brand span { color: #9fd3d6; font-family: 'Inter', sans-serif; font-size: 12px; margin-left: 6px; letter-spacing: .08em; text-transform: uppercase; }
.topbar nav a { color: #d6ecec; text-decoration: none; font-weight: 550; padding: 6px 10px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar .me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #d6ecec; }

.page { padding: 20px; max-width: 1180px; margin: 0 auto; }
.page.wide { max-width: none; }

/* Buttons & inputs */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 13px; border-radius: 7px; cursor: pointer; font-weight: 550; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #c9c3bf; }
button:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-danger { color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--teal); padding-left: 6px; padding-right: 6px; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; }
.seg button.on { background: var(--teal); color: #fff; }

label.field { display: block; }
label.field > span, .label { display: block; font-size: 12px; font-weight: 600; color: #3d4445; margin-bottom: 4px; }
.req::after { content: ' *'; color: var(--orange); }
input[type=text], input[type=email], input[type=date], input[type=url], input[type=search], select, textarea {
  font: inherit; width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0,93,99,.25); border-color: var(--teal); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; background: #fff; cursor: pointer; user-select: none; font-size: 13px; }
.chip input { display: none; }
.chip.on { background: var(--teal-tint); border-color: var(--teal); color: var(--teal-dark); font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.err { color: var(--bad); font-size: 12px; margin-top: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.section + .section { margin-top: 16px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: #eee; color: #444; white-space: nowrap; }
.badge.teal { background: var(--teal-tint); color: var(--teal-dark); }
.badge.orange { background: var(--orange-tint); color: #a53c00; }
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }

.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--teal-tint); color: var(--teal-dark); font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Kanban */
.board-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.board-tools input[type=search] { width: 260px; }
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: calc(100vh - 150px); }
.col { flex: 0 0 272px; width: 272px; min-width: 0; background: #efebe8; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 150px); }
.col-head { padding: 10px 12px 6px; display: flex; align-items: center; gap: 8px; font-weight: 650; }
.col-head .count { color: var(--muted); font-weight: 500; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.col-body { padding: 4px 8px 10px; overflow-y: auto; flex: 1; min-height: 60px; }
.col.drop .col-body { background: rgba(0,93,99,.07); border-radius: 0 0 var(--radius) var(--radius); }
.kcard { min-width: 0; overflow: hidden; background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 10px; margin-bottom: 8px; cursor: pointer; border: 1px solid transparent; display: block; color: inherit; text-decoration: none; }
.kcard:hover { border-color: #c9d9d9; }
.kcard.dragging { opacity: .4; }
.kcard .top { display: flex; gap: 10px; }
.kcard .thumb { width: 46px; height: 46px; border-radius: 6px; background: #f3f0ee center/cover no-repeat; flex: none; }
.kcard .title { font-weight: 650; line-height: 1.25; word-break: break-word; }
.kcard .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kcard .meta { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.drop-marker { height: 3px; background: var(--teal); border-radius: 2px; margin: -2px 0 6px; }

/* List view */
table.list { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fbfaf9; cursor: pointer; user-select: none; white-space: nowrap; }
table.list td { padding: 10px 12px; border-bottom: 1px solid #f0edeb; vertical-align: middle; }
table.list tr:hover td { background: #fbfaf9; cursor: pointer; }

/* Request detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 960px) { .detail { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.product { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid #f0edeb; }
.product:first-child { border-top: 0; padding-top: 0; }
.product .pimg { width: 84px; height: 84px; border-radius: 8px; background: #f3f0ee center/contain no-repeat; flex: none; border: 1px solid #eee; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); vertical-align: -2px; background-size: cover; }
.files { display: flex; flex-direction: column; gap: 6px; }
.file { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 13px; }
.file .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: #fff; }
.version + .version { margin-top: 10px; }
.version.latest { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal) inset; }
.warnlist { margin: 8px 0 0; padding: 0; list-style: none; }
.warnlist li { font-size: 12.5px; padding: 4px 8px; background: var(--warn-tint); color: #6d4300; border-radius: 6px; margin-top: 4px; }
.callout { padding: 10px 12px; border-radius: 8px; font-size: 13px; white-space: pre-wrap; }
.callout.warn { background: var(--warn-tint); color: #6d4300; }
.callout.ok { background: var(--ok-tint); color: #145a33; }
.callout.bad { background: var(--bad-tint); color: #7d1a14; }
.callout.info { background: var(--teal-tint); color: var(--teal-dark); }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 8px; padding: 8px 0; border-top: 1px solid #f0edeb; font-size: 13px; }
.activity li:first-child { border-top: 0; }
.activity .when { font-size: 11px; color: var(--muted); }
.activity .comment { background: #f6f3f0; border-radius: 8px; padding: 6px 9px; margin-top: 3px; white-space: pre-wrap; }

/* Form */
.item-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: #fcfbfa; position: relative; }
.item-card + .item-card { margin-top: 12px; }
.item-card .remove { position: absolute; top: 8px; right: 8px; }
.ss-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 300px; overflow-y: auto; margin-top: 4px; }
.ss-results .opt { display: flex; gap: 10px; padding: 8px 10px; cursor: pointer; align-items: center; }
.ss-results .opt:hover, .ss-results .opt.active { background: var(--teal-tint); }
.ss-results img { width: 36px; height: 36px; object-fit: contain; flex: none; }
.colors { display: flex; flex-wrap: wrap; gap: 5px; max-height: 150px; overflow-y: auto; padding: 2px; }
.color-opt { width: 26px; height: 26px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 0 0 1px #ccc; cursor: pointer; background-size: cover; }
.color-opt.on { box-shadow: 0 0 0 2px var(--teal); }
.picked { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.picked img { width: 64px; height: 64px; object-fit: contain; }
.dropzone { border: 2px dashed #d5cfcb; border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: #fff; }
.dropzone.over { border-color: var(--teal); background: var(--teal-tint); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: 7px 10px; color: var(--muted); }
.tabs button.on { color: var(--teal); border-bottom-color: var(--teal); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,25,26,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin-bottom: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1f2324; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 200; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(0,0,0,.15); border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Compact mode (Missive sidebar) */
body.compact { font-size: 13px; background: #fff; }
html:has(body.compact) { background: #fff; }
body.compact .page { padding: 12px; }
body.compact .detail { grid-template-columns: 1fr; gap: 12px; }
body.compact .card.pad { padding: 12px; box-shadow: none; }
body.compact .grid2, body.compact .grid3 { grid-template-columns: 1fr; gap: 10px; }
body.compact h1 { font-size: 20px; }
body.compact .product .pimg { width: 60px; height: 60px; }
body.compact .kv { grid-template-columns: 80px 1fr; }
