:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #607080;
  --line: #d8dee6;
  --panel: #ffffff;
  --page: #f5f7f9;
  --accent: #176b87;
  --accent-strong: #0f4c5c;
  --alert: #b45309;
  --green: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--accent-strong);
  border-radius: 6px;
  padding: 9px 14px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.secondary {
  color: var(--accent-strong);
  background: #fff;
}

.hidden {
  display: none !important;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.signed-in {
  color: var(--muted);
  font-size: 13px;
}

main {
  padding: 16px 20px 28px;
}

.auth-view {
  display: grid;
  min-height: calc(100vh - 83px);
  place-items: center;
  padding: 24px;
}

.auth-box {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.auth-box h2,
.admin-panel h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.form-error {
  margin: 0;
  color: #b91c1c;
  font-size: 13px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 220px;
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics article {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metrics strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.metrics span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  max-height: calc(100vh - 245px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-head,
.invite-form,
.invite-row {
  display: flex;
  align-items: end;
  gap: 12px;
}

.admin-head {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.invite-form {
  flex-wrap: wrap;
}

.invite-form label {
  min-width: 220px;
}

.invite-result {
  margin: 12px 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.invite-list {
  display: grid;
  gap: 8px;
}

.invite-row {
  justify-content: space-between;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-size: 13px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  width: 140px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #394a59;
  background: #eef3f6;
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  height: 42px;
  max-width: 260px;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

tr:last-child td {
  border-bottom: 0;
}

.row-new-blue td,
.row-new-blue .col-subject {
  background: #eff6ff;
}

.row-live-green td,
.row-live-green .col-subject {
  background: #ecfdf3;
}

.row-two-day-yellow td,
.row-two-day-yellow .col-subject {
  background: #fefce8;
}

.row-week-orange td,
.row-week-orange .col-subject {
  background: #fff7ed;
}

.row-priority-red td,
.row-priority-red .col-subject {
  background: #fef2f2;
}

.row-color:hover td,
.row-color:hover .col-subject {
  filter: brightness(0.985);
}

.subject {
  display: block;
  font-weight: 700;
}

.meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  max-width: 100%;
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--accent-strong);
  background: #e6f4f1;
  font-size: 11px;
  font-weight: 700;
}

.pill-new-blue {
  color: #1e3a8a;
  background: #dbeafe;
}

.pill-live-green {
  color: #166534;
  background: #dcfce7;
}

.pill-two-day-yellow {
  color: #854d0e;
  background: #fef3c7;
}

.pill-week-orange {
  color: #9a3412;
  background: #ffedd5;
}

.pill-priority-red {
  color: #991b1b;
  background: #fee2e2;
}

.vendor {
  color: var(--alert);
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  max-width: 100%;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 750;
}

.status-good {
  color: #166534;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.status-active {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.status-waiting {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.status-danger {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fecaca;
}

.status-bad {
  color: #7f1d1d;
  background: #f3e8e8;
  border-color: #e7c6c6;
}

.status-neutral {
  color: #475569;
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.cell-text,
.clamp-2,
.clamp-3 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
}

.cell-text {
  -webkit-line-clamp: 1;
}

.clamp-2 {
  -webkit-line-clamp: 2;
}

.clamp-3 {
  -webkit-line-clamp: 3;
}

.col-id {
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  text-align: right;
}

.col-subject {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background: var(--panel);
}

th.col-subject {
  z-index: 3;
  background: #eef3f6;
}

.col-customer-project {
  width: 160px;
  min-width: 160px;
}

.col-tracker-stage {
  width: 170px;
  min-width: 170px;
}

.col-next-action {
  width: 300px;
  min-width: 300px;
}

.col-owner {
  width: 135px;
  min-width: 135px;
}

.col-status {
  width: 145px;
  min-width: 145px;
}

.col-linked-vendor-subject {
  width: 220px;
  min-width: 220px;
}

.col-conversation-id {
  width: 190px;
  min-width: 190px;
}

.col-due-follow-up,
.col-last-updated,
.col-priority,
.col-user-update9,
.col-source {
  width: 120px;
  min-width: 120px;
}

.col-rowcolor-newblue,
.col-rowcolor-livegreen,
.col-rowcolor-twodayyellow,
.col-rowcolor-weekorange,
.col-rowcolor-priorityred {
  width: 82px;
  min-width: 82px;
  max-width: 82px;
  text-align: center;
}

.bool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 20px;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 750;
}

.bool-yes {
  color: #166534;
  background: #dcfce7;
}

.bool-no {
  color: #64748b;
  background: #f1f5f9;
}

.empty,
.error {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.error {
  color: #b91c1c;
}

@media (max-width: 760px) {
  .topbar,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .invite-form,
  .invite-row {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .toolbar,
  .metrics {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}
