:root {
  --ink: #1c2430;
  --muted: #5b6676;
  --line: #d9dee6;
  --paper: #ffffff;
  --wash: #f4f6f9;
  --brand: #14506e;
  --brand-ink: #ffffff;
  --danger: #a3261f;
  --ok: #1d6b45;
  --radius: 6px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

h1 { font-size: 20px; margin: 0; letter-spacing: 0.01em; }
h2 { font-size: 16px; margin: 24px 0 8px; }
dialog h2 { margin-top: 0; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--brand);
  color: var(--brand-ink);
}
.top .business { display: flex; gap: 8px; align-items: center; }
.top .quiet { color: var(--brand-ink); border-color: rgba(255, 255, 255, 0.5); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  padding: 12px 16px;
  color: var(--muted);
  font-weight: 600;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

main { padding: 20px 24px 48px; max-width: 1200px; margin: 0 auto; }

button, .button, select, input, textarea { font: inherit; }

button, .button {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { border-color: var(--muted); }
button:focus-visible, .button:focus-visible, select:focus-visible,
input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.quiet { background: transparent; }
.link { border: 0; background: none; padding: 2px 6px; color: var(--brand); text-decoration: underline; }
.link.danger-link { color: var(--danger); }

select, input, textarea {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}
textarea { width: 100%; resize: vertical; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.toolbar label { display: flex; gap: 6px; align-items: center; color: var(--muted); }

.table-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); background: var(--wash); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.sub { display: block; color: var(--muted); font-size: 13px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}
.badge.won, .badge.reviewed { color: var(--ok); border-color: var(--ok); }
.badge.lost, .badge.declined { color: var(--danger); border-color: var(--danger); }

.empty, .note { color: var(--muted); }
.empty { padding: 20px 4px; }
.note { font-size: 13px; }

.rule {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: #fff8e1;
  border: 1px solid #e6cf7a;
  border-radius: var(--radius);
}

#message {
  margin: 12px 24px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #e6f2ea;
  border: 1px solid var(--ok);
}
#message.error { background: #fbeae8; border-color: var(--danger); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile .value { display: block; font-size: 24px; font-weight: 700; }
.tile .label { color: var(--muted); font-size: 13px; }

dialog {
  width: min(640px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  color: var(--ink);
}
dialog::backdrop { background: rgba(20, 30, 45, 0.45); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid label, dialog form > label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.grid .wide { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.form-error { color: var(--danger); margin: 12px 0 0; }

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  main, .top, .tabs { padding-left: 12px; padding-right: 12px; }
}

/* Account area in the header */
.top .who { opacity: 0.8; font-size: 13px; }
#business-name { font-weight: 600; }

/* Settings */
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { margin-top: 0; }
.panel label, .card form > label {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px;
  color: var(--muted); font-size: 13px;
}
#link-value { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* Sign-in, setup and customer pages */
body.plain { display: flex; justify-content: center; padding: 32px 12px; }
.card {
  width: min(420px, 100%); align-self: flex-start;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 24px;
}
.card.wide-card { width: min(640px, 100%); }
.card h1 { color: var(--brand); margin-bottom: 8px; }
.card h2 { margin-top: 20px; }
.card section { border-top: 1px solid var(--line); margin-top: 20px; }
.notice {
  padding: 10px 14px; border-radius: var(--radius);
  background: #e6f2ea; border: 1px solid var(--ok);
}
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { color: var(--muted); font-size: 13px; padding: 0; margin-bottom: 4px; }
.ratings { display: flex; flex-direction: column; gap: 6px; }
.ratings label { display: block; color: var(--ink); font-size: 15px; margin: 0; }
.requests { list-style: none; padding: 0; margin: 0; }
.requests li {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.requests li:last-child { border-bottom: 0; }
.request-job { font-weight: 600; flex: 1 1 200px; }
.requests .sub { display: inline; }
