:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #e3e6ea;
  --text: #16191d;
  --muted: #667085;
  --accent: #2f6df6;
  --accent-dark: #1f52c9;
  --green: #0f8a52;
  --green-bg: #e6f6ee;
  --amber: #a76a00;
  --amber-bg: #fdf3e0;
  --red: #c0392b;
  --red-bg: #fdecea;
  --blue-bg: #e8f0fe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 20px; height: 58px;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -.02em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }

.nav { display: flex; align-items: center; gap: 16px; flex: 1; }
.nav a { color: var(--muted); font-weight: 500; font-size: 14px; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); }
.nav a.btn { color: #fff; }

.nav-right { display: flex; align-items: center; gap: 14px; }
.menu { display: flex; align-items: center; gap: 10px; }
.who { display: flex; flex-direction: column; line-height: 1.15; color: var(--text); font-size: 14px; font-weight: 500; }
.who small { color: var(--muted); font-weight: 400; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.who:hover { text-decoration: none; }

.bell { position: relative; font-size: 17px; text-decoration: none; }
.bell .dot {
  position: absolute; top: -6px; right: -9px; background: var(--red); color: #fff;
  border-radius: 10px; font-size: 10px; font-weight: 700; padding: 1px 5px; line-height: 1.4;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit; line-height: 1.3;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: #f0f2f5; color: var(--text); border-color: #d0d5dd; }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #a33025; border-color: #a33025; }
.btn-green { background: var(--green); border-color: var(--green); }
.btn-green:hover { background: #0b6e41; border-color: #0b6e41; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ---------- cards & layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-tight { padding: 14px 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.split { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  background: #eef0f3; color: var(--muted);
}
.badge-open, .badge-approved, .badge-assigned { background: var(--green-bg); color: var(--green); }
.badge-in_progress, .badge-submitted, .badge-interested { background: var(--blue-bg); color: var(--accent-dark); }
.badge-pending, .badge-closed { background: var(--amber-bg); color: var(--amber); }
.badge-rejected, .badge-cancelled, .badge-withdrawn { background: var(--red-bg); color: var(--red); }
.badge-completed { background: #ede9fe; color: #6d28d9; }
.badge-verified { background: var(--green-bg); color: var(--green); }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-brand { background: var(--blue-bg); color: var(--accent-dark); }
.badge-mediator { background: #f4f6f8; color: var(--muted); }

.pill {
  display: inline-block; background: var(--red); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; padding: 1px 6px; line-height: 1.5; vertical-align: 1px;
}

/* ---------- deal photos ---------- */
/* The cover fills the card width; a fixed aspect ratio keeps the board tidy
   whatever shape the brand uploads. */
.item-photo { padding-top: 0; overflow: hidden; }
.deal-cover {
  display: block; position: relative; margin: -16px -16px 14px;
  background: #eef0f3; aspect-ratio: 16 / 7;
}
.deal-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.deal-cover:hover img { opacity: .93; }
.deal-cover-count {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(16, 24, 40, .72); color: #fff;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}

.deal-hero { width: 100%; max-height: 380px; object-fit: cover; display: block; background: #eef0f3; }
.deal-thumbs { display: flex; gap: 8px; padding: 10px; flex-wrap: wrap; }
.deal-thumbs img {
  width: 84px; height: 62px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--line); display: block;
}
.deal-thumbs a:hover img { border-color: var(--accent); }

.photo-manage { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.photo-manage-item { margin: 0; width: 150px; }
.photo-manage-item img {
  width: 150px; height: 105px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); display: block;
}
.photo-manage-item figcaption {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px;
}

@media (max-width: 700px) {
  .deal-cover { aspect-ratio: 16 / 9; }
  .photo-manage-item, .photo-manage-item img { width: 120px; }
  .photo-manage-item img { height: 84px; }
}

.card.danger { border-color: #f0c7c2; background: #fffbfb; }
.card.danger h3 { color: var(--red); }

/* one-time credentials panel */
.creds {
  background: #fffdf5; border: 1px solid #f0e0b0; border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.creds code {
  display: inline-block; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; font-size: 15px; font-weight: 600;
  letter-spacing: .02em; user-select: all;
}

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 109, 246, .25); border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }

.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-pick label {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer;
  background: #fff; font-weight: 600; margin: 0;
}
.role-pick label:has(input:checked) { border-color: var(--accent); background: var(--blue-bg); }
.role-pick input { margin-right: 6px; }
.role-pick span { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.auth { max-width: 420px; margin: 40px auto; }
.auth-wide { max-width: 520px; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.item h3 { margin: 0 0 4px; font-size: 16px; }
.item h3 a { color: var(--text); }
.meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 8px; }
.meta b { color: var(--text); font-weight: 600; }

.applicant { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; background: #fff; }
.applicant.is-assigned { border-color: #a7e0c3; background: #fbfffd; }
.applicant.is-rejected { opacity: .6; }
.applicant .quote { background: #f7f8fa; border-left: 3px solid var(--line); padding: 8px 12px; border-radius: 0 6px 6px 0; margin: 8px 0 0; font-size: 13.5px; color: #3c4149; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 0 0 14px; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); }

.notice { background: var(--blue-bg); color: var(--accent-dark); padding: 10px 13px; border-radius: 8px; font-size: 13.5px; }
.notice-warn { background: var(--amber-bg); color: var(--amber); }
.notice-ok { background: var(--green-bg); color: var(--green); }

hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.pre-wrap { white-space: pre-wrap; margin: 0; font: inherit; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); background: #fff; border: 1px solid var(--line); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on { background: var(--text); color: #fff; border-color: var(--text); }

.step { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.step:first-of-type { border-top: 0; }
.step .n { flex: 0 0 24px; height: 24px; border-radius: 50%; background: #eef0f3; color: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.step.done .n { background: var(--green); color: #fff; }
.step .body { flex: 1; }

.notif { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 8px; }
.notif.unread { border-left: 3px solid var(--accent); background: #fbfcff; }
.notif .t { font-weight: 600; font-size: 14px; }

/* ---------- the sheet ---------- */
/* 19 columns will never fit; the table scrolls inside its own box so the page
   itself never scrolls sideways. */
.sheet-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.sheet { border-collapse: collapse; font-size: 13px; white-space: nowrap; min-width: 100%; }
.sheet th, .sheet td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  vertical-align: middle;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f4f6f8;
  font-weight: 600;
  font-size: 12px;
  border-bottom: 2px solid var(--line);
}
.sheet thead th.owner-brand { background: #eef3ff; color: var(--accent-dark); }
.sheet tbody tr:hover td { background: #fafbfc; }
.sheet td.brand-cell { color: var(--muted); background: #fcfdff; }
.sheet .rownum {
  position: sticky; left: 0; z-index: 1;
  background: #f4f6f8; color: var(--muted);
  font-variant-numeric: tabular-nums; text-align: right;
  width: 40px; min-width: 40px;
}
.sheet thead .rownum { z-index: 3; }
.sheet .nowrap { white-space: nowrap; }
.sheet .shot img {
  height: 34px; width: 52px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--line); display: block;
}
.sheet .shot:hover img { border-color: var(--accent); }

.legend-key {
  display: inline-block; width: 11px; height: 11px; border-radius: 3px;
  border: 1px solid var(--line); vertical-align: -1px; margin-right: 3px;
}
.legend-key.owner-brand { background: #eef3ff; border-color: #c7d8ff; }
.legend-key.owner-mediator { background: #f4f6f8; }

.hero { text-align: center; padding: 48px 20px 32px; }
.hero h1 { font-size: 38px; line-height: 1.15; margin-bottom: 12px; }
.hero p { font-size: 17px; color: var(--muted); max-width: 620px; margin: 0 auto 24px; }

.footer { border-top: 1px solid var(--line); background: var(--surface); padding: 20px 0; font-size: 13px; }
.footer .container { display: flex; gap: 16px; justify-content: space-between; padding: 0 20px; flex-wrap: wrap; }

.checkline { display: flex; gap: 10px; align-items: flex-start; }
.checkline input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; flex: 0 0 16px; }

@media (max-width: 700px) {
  .topbar-inner { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .nav-right { margin-left: auto; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .hero h1 { font-size: 28px; }
}
