:root {
  --navy-950: #071d34;
  --navy-900: #092b4d;
  --navy-800: #0d3a66;
  --navy-700: #174d7c;
  --blue-700: #0d57cf;
  --blue-600: #1468e8;
  --blue-500: #287cf3;
  --blue-100: #eaf2ff;
  --aqua-600: #149d90;
  --aqua-500: #20b8a8;
  --aqua-100: #e7f8f5;
  --ink: #102a43;
  --muted: #64788b;
  --muted-2: #8495a5;
  --canvas: #f3f6f9;
  --panel: #ffffff;
  --line: #dce5ed;
  --line-soft: #eaf0f4;
  --danger: #a83f45;
  --danger-bg: #fceded;
  --warning: #8a6418;
  --warning-bg: #fff4d8;
  --success: #147a69;
  --success-bg: #e5f7f2;
  --radius-sm: 10px;
  --radius: 15px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(7, 29, 52, 0.04), 0 8px 22px rgba(7, 29, 52, 0.045);
  --shadow: 0 18px 48px rgba(7, 29, 52, 0.1);
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.menu-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(40, 124, 243, 0.25);
  outline-offset: 2px;
}

img,
svg {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue-600);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1.2;
  text-transform: uppercase;
}

.primary {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: var(--blue-600);
  box-shadow: 0 7px 18px rgba(20, 104, 232, 0.18);
  color: #fff;
  font-weight: 750;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.primary:hover {
  background: var(--blue-700);
  box-shadow: 0 9px 22px rgba(20, 104, 232, 0.24);
  transform: translateY(-1px);
}

.icon-btn {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--navy-900);
  font-size: 1.05rem;
}

.icon-btn:hover {
  border-color: var(--line);
  background: #f7fafc;
}

/* Brand lockups */
.product-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.product-lockup > img {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 14px rgba(8, 74, 160, 0.2));
}

.product-lockup strong,
.product-lockup span {
  display: block;
}

.product-lockup strong {
  color: currentColor;
  font-size: 1.11rem;
  font-weight: 820;
  letter-spacing: -0.035em;
  line-height: 1.08;
  white-space: nowrap;
}

.product-lockup strong b {
  background: linear-gradient(115deg, #59eadb, #2a8cff);
  background-clip: text;
  color: var(--aqua-500);
  font-weight: 850;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.product-lockup span {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Sign in */
.login-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(390px, 560px) 1fr;
  background: var(--navy-950);
}

.login-panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(34px, 6vw, 78px);
  background: #fff;
}

.login-product {
  align-self: flex-start;
  margin-bottom: 28px;
  color: var(--navy-900);
}

.login-product > img {
  width: min(100%, 365px);
  height: auto;
}

.login-product.product-lockup {
  width: 100%;
}

.tenant-lockup {
  display: flex;
  align-self: flex-start;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 13px 8px 8px;
  background: #f8fafc;
}

.tenant-lockup img {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  object-fit: contain;
}

.tenant-lockup strong,
.tenant-lockup span {
  display: block;
}

.tenant-lockup strong {
  color: var(--navy-900);
  font-size: 0.85rem;
}

.tenant-lockup span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.71rem;
}

.login-panel h1 {
  max-width: 520px;
  margin: 10px 0 20px;
  color: var(--navy-900);
  font-size: clamp(2.65rem, 5.2vw, 4.65rem);
  font-weight: 820;
  letter-spacing: -0.06em;
  line-height: 0.98;
}

.login-panel h1 span {
  color: var(--blue-600);
}

.login-copy {
  max-width: 505px;
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.stack {
  display: grid;
  max-width: 505px;
  gap: 15px;
  margin-top: 28px;
}

.stack label,
.form-grid label {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: #304b63;
  font-size: 0.79rem;
  font-weight: 750;
}

.stack input,
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #c8d5df;
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.stack input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(20, 104, 232, 0.08);
  outline: 0;
}

.form-grid textarea {
  min-height: 108px;
  resize: vertical;
}

.stack .primary {
  min-height: 48px;
  font-size: 0.95rem;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.secure-note {
  margin: 17px 0 0;
  color: var(--muted-2);
  font-size: 0.74rem;
}

.login-art {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 76% 24%, rgba(40, 124, 243, 0.2), transparent 34%),
    linear-gradient(145deg, var(--navy-950), #0a2f56 58%, #0b3f68);
}

.login-art::before,
.login-art::after {
  position: absolute;
  border: 1px solid rgba(77, 146, 244, 0.18);
  border-radius: 50%;
  content: "";
}

.login-art::before {
  top: -150px;
  right: -120px;
  width: 560px;
  height: 560px;
  box-shadow: 0 0 0 90px rgba(40, 124, 243, 0.03), 0 0 0 180px rgba(40, 124, 243, 0.018);
}

.login-art::after {
  bottom: -130px;
  left: -120px;
  width: 360px;
  height: 360px;
}

.login-art-copy {
  position: absolute;
  z-index: 2;
  top: 9%;
  right: 9%;
  left: 9%;
  max-width: 650px;
}

.login-art-copy h2 {
  margin: 20px 0 15px;
  color: #fff;
  font-size: clamp(2rem, 3.7vw, 3.9rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.04;
}

.login-art-copy p {
  max-width: 560px;
  margin: 0;
  color: #b9ccdb;
  font-size: 1.01rem;
  line-height: 1.65;
}

.live-pill,
.hero-signal {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(65, 212, 195, 0.22);
  border-radius: 999px;
  background: rgba(32, 184, 168, 0.1);
  color: #e2faf7;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.live-pill {
  padding: 8px 12px;
}

.live-pill i,
.sidebar-status i,
.signal-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #56d9ca;
  box-shadow: 0 0 0 5px rgba(86, 217, 202, 0.12);
}

.hero-card {
  position: absolute;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  padding: 20px 22px;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: 0 24px 60px rgba(3, 18, 33, 0.22);
  color: #fff;
  backdrop-filter: blur(16px);
}

.hero-card span,
.hero-card small {
  display: block;
  color: #b9ccdb;
}

.hero-card strong {
  display: block;
  margin: 6px 0;
  font-size: 1.18rem;
  font-weight: 790;
}

.hero-card-main {
  bottom: 24%;
  left: 10%;
  width: min(430px, 58%);
  transform: rotate(-1.5deg);
}

.hero-card-ai {
  right: 7%;
  bottom: 9%;
  width: min(360px, 47%);
  transform: rotate(2deg);
}

.hero-card-cash {
  top: 45%;
  right: 8%;
  width: min(295px, 42%);
  transform: rotate(1deg);
}

/* App shell */
.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 252px minmax(0, 1fr);
}

.app-shell > main {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  width: 252px;
  height: 100vh;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 13px;
  background: var(--navy-950);
  color: #fff;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.brand {
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 7px 15px;
}

.sidebar .product-lockup {
  color: #fff;
}

.sidebar .product-lockup > img {
  width: 39px;
  height: 39px;
  filter: drop-shadow(0 7px 13px rgba(19, 120, 255, 0.32));
}

.sidebar .product-lockup strong {
  font-size: 1.04rem;
}

.workspace-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.05);
}

.workspace-brand img {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 50%;
  padding: 2px;
  background: #fff;
  object-fit: contain;
}

.workspace-brand div {
  min-width: 0;
}

.workspace-brand strong,
.workspace-brand span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-brand strong {
  font-size: 0.77rem;
}

.workspace-brand span {
  margin-top: 2px;
  color: #8fa8bc;
  font-size: 0.64rem;
}

.nav-label {
  padding: 9px 11px 5px;
  color: #7693aa;
  font-size: 0.59rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar nav {
  display: grid;
  gap: 2px;
  margin-bottom: 5px;
}

.sidebar button {
  min-width: 0;
  border: 0;
  border-radius: 9px;
  padding: 9px 11px;
  background: transparent;
  color: #bed0dd;
  font-size: 0.81rem;
  font-weight: 690;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.sidebar nav button {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
}

.sidebar nav button span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar nav button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar nav button.active {
  background: linear-gradient(90deg, rgba(40, 124, 243, 0.28), rgba(40, 124, 243, 0.13));
  box-shadow: inset 3px 0 0 #4a91f6;
  color: #fff;
}

.badge {
  min-width: 20px;
  border-radius: 999px;
  padding: 2px 6px;
  background: var(--blue-500);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 850;
  text-align: center;
}

.badge:empty {
  display: none;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: auto;
  border: 1px solid rgba(65, 212, 195, 0.15);
  border-radius: 11px;
  padding: 11px;
  background: rgba(32, 184, 168, 0.07);
}

.sidebar-status strong,
.sidebar-status span {
  display: block;
}

.sidebar-status strong {
  color: #fff;
  font-size: 0.7rem;
}

.sidebar-status span {
  margin-top: 2px;
  color: #8ea8bb;
  font-size: 0.63rem;
}

.sidebar-bottom {
  display: grid;
  gap: 2px;
  margin-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 9px;
}

.sidebar-backdrop {
  display: none;
}

.topbar {
  position: sticky;
  z-index: 8;
  top: 0;
  display: flex;
  height: 76px;
  min-width: 0;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar > div:first-of-type {
  min-width: 0;
}

.topbar h2 {
  margin: 0;
  overflow: hidden;
  color: var(--navy-900);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-left: auto;
}

.avatar {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #cfe0f1;
  border-radius: 50%;
  background: var(--blue-100);
  color: var(--navy-900);
  font-size: 0.83rem;
  font-weight: 850;
}

.topbar #menu-btn {
  display: none;
}

.content {
  width: 100%;
  max-width: 1580px;
  margin: 0 auto;
  padding: 26px 28px 42px;
}

.content > * {
  min-width: 0;
}

/* Dashboard */
.command-hero {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  padding: 25px 27px;
  background:
    radial-gradient(circle at 88% 25%, rgba(40, 124, 243, 0.28), transparent 28%),
    linear-gradient(132deg, var(--navy-950), var(--navy-800));
  box-shadow: var(--shadow-sm);
  color: #fff;
}

.command-hero::after {
  position: absolute;
  top: -130px;
  right: -90px;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(87, 153, 244, 0.22);
  border-radius: 50%;
  box-shadow: 0 0 0 52px rgba(87, 153, 244, 0.035);
  content: "";
}

.command-hero > div {
  min-width: 0;
}

.command-hero h3 {
  position: relative;
  z-index: 1;
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 2.5vw, 2.35rem);
  font-weight: 810;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.command-hero p:not(.eyebrow) {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0;
  color: #c3d3df;
  line-height: 1.55;
}

.command-hero .eyebrow {
  position: relative;
  z-index: 1;
  margin-bottom: 7px;
  color: #74adfb;
}

.hero-signal {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  padding: 9px 12px;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 17px 16px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.metric::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--blue-600);
  content: "";
}

.metric span,
.metric strong,
.metric small {
  display: block;
}

.metric span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.metric strong {
  margin-top: 7px;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: clamp(1.4rem, 2vw, 1.72rem);
  font-variant-numeric: tabular-nums;
  font-weight: 810;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.metric small {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(300px, 0.72fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.dashboard-main,
.dashboard-rail {
  display: grid;
  min-width: 0;
  gap: 18px;
  align-content: start;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  min-width: 0;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line-soft);
  padding: 14px 17px;
}

.panel-head > * {
  min-width: 0;
}

.panel-head h3 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: 0.93rem;
  font-weight: 790;
  letter-spacing: -0.015em;
}

.panel-head p {
  margin: 4px 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
}

.panel-head button,
.table-actions button,
.dialog-actions button,
.import-actions button {
  flex: 0 0 auto;
  border: 1px solid #d2dee8;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--navy-900);
  font-size: 0.75rem;
  font-weight: 760;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.panel-head button:hover,
.table-actions button:hover,
.dialog-actions button:hover,
.import-actions button:hover {
  border-color: #b7c9d8;
  background: #f5f8fb;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.quick-action {
  position: relative;
  min-width: 0;
  min-height: 86px;
  border: 1px solid #d6e4f1;
  border-radius: 12px;
  padding: 14px 34px 13px 13px;
  background: #f2f7fd;
  color: var(--navy-900);
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.quick-action::after {
  position: absolute;
  top: 13px;
  right: 12px;
  color: var(--blue-600);
  content: "↗";
  font-size: 0.9rem;
  font-weight: 900;
}

.quick-action:hover {
  border-color: #a9caed;
  background: #eaf3ff;
  transform: translateY(-1px);
}

.quick-action strong,
.quick-action span {
  display: block;
  overflow-wrap: anywhere;
}

.quick-action strong {
  font-size: 0.8rem;
  font-weight: 780;
}

.quick-action span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.35;
}

.ai-priority {
  padding: 18px;
  background: linear-gradient(145deg, var(--aqua-100), #f0fbf9);
}

.ai-priority .status-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  color: var(--navy-900);
  font-size: 0.86rem;
  font-weight: 800;
}

.ai-priority p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.58;
}

.ai-priority .primary {
  box-shadow: none;
  font-size: 0.78rem;
}

.activity-list,
.import-history {
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-list li,
.import-history li {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 16px;
}

.activity-list li:last-child,
.import-history li:last-child {
  border-bottom: 0;
}

.activity-list strong,
.import-history strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: 0.77rem;
  line-height: 1.4;
}

.activity-list time,
.import-history span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.67rem;
}

/* Data tables */
.table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: #c2d1dc transparent;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.dashboard-main table {
  min-width: 660px;
}

th,
td {
  min-width: 0;
  border-bottom: 1px solid var(--line-soft);
  padding: 13px 15px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: #f7f9fb;
  color: #61768a;
  font-size: 0.63rem;
  font-weight: 820;
  letter-spacing: 0.075em;
  line-height: 1.25;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  max-width: 320px;
  color: #304a61;
  font-size: 0.77rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

tbody tr:hover td {
  background: #fafcff;
}

td strong {
  display: block;
  color: var(--navy-900);
  font-weight: 770;
  line-height: 1.35;
}

.subtext {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.35;
}

td[data-key="status"],
td[data-key="risk"],
td[data-key="priority"],
td[data-key="scheduledAt"],
td[data-key="dueAt"],
td[data-key="receivedAt"],
td[data-key="validUntil"],
td[data-key="invoiceDate"],
td[data-key="dueDate"] {
  white-space: nowrap;
}

th.numeric,
td.numeric {
  text-align: right;
}

.money {
  display: block;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.truncate {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  white-space: normal;
}

.row-actions {
  width: 1%;
  min-width: 120px;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 5px;
}

.table-actions button {
  padding: 6px 8px;
  font-size: 0.67rem;
  white-space: nowrap;
}

.table-actions button[data-action="convert"],
.table-actions button[data-action="paid"] {
  border-color: #b7d8cf;
  color: var(--success);
}

.status {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef2f5;
  color: #3e566c;
  font-size: 0.64rem;
  font-weight: 820;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

.status.high,
.status.emergency,
.status.overdue,
.status.declined {
  background: var(--danger-bg);
  color: var(--danger);
}

.status.medium,
.status.sent,
.status.scheduled,
.status.triaged,
.status.review,
.status.waiting {
  background: var(--warning-bg);
  color: var(--warning);
}

.status.low,
.status.paid,
.status.completed,
.status.converted,
.status.accepted,
.status.connected,
.status.done {
  background: var(--success-bg);
  color: var(--success);
}

.status.not-imported,
.status.draft,
.status.open,
.status.new {
  background: #eef2f5;
  color: #536a7e;
}

.empty {
  padding: 44px 20px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* List views */
.page-head {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-head > div {
  min-width: 0;
}

.page-head h3 {
  margin: 0;
  color: var(--navy-900);
  font-size: 1.42rem;
  font-weight: 810;
  letter-spacing: -0.035em;
  line-height: 1.15;
  white-space: normal;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.page-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.record-count {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  white-space: nowrap;
}

.searchbar {
  display: flex;
  margin-bottom: 12px;
}

.searchbar input {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px 10px 39px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(7, 29, 52, 0.02);
}

.searchbar {
  position: relative;
}

.searchbar::before {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 14px;
  color: var(--muted-2);
  content: "⌕";
  font-size: 1.14rem;
  line-height: 1;
  transform: translateY(-52%);
}

.searchbar input:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(20, 104, 232, 0.08);
  outline: 0;
}

/* Imports */
.import-layout {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.business-profile {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 16px;
  padding: 19px;
}

.business-profile img {
  width: 94px;
  height: 94px;
  flex: 0 0 auto;
  object-fit: contain;
}

.business-profile div {
  min-width: 0;
}

.business-profile h4 {
  margin: 0 0 7px;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: 1.04rem;
}

.business-profile p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.77rem;
  overflow-wrap: anywhere;
}

.import-panel {
  margin-top: 18px;
}

.import-drop {
  padding: 20px;
}

.import-drop input {
  position: absolute;
  left: -9999px;
}

.import-drop label {
  display: grid;
  min-height: 145px;
  place-items: center;
  border: 2px dashed #b8cbdc;
  border-radius: 14px;
  padding: 22px;
  background: #f8fafc;
  text-align: center;
  cursor: pointer;
}

.import-drop label:hover {
  border-color: var(--blue-600);
  background: #f2f7fd;
}

.import-drop strong,
.import-drop span {
  display: block;
  overflow-wrap: anywhere;
}

.import-drop strong {
  color: var(--navy-900);
  font-size: 0.92rem;
}

.import-drop span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.74rem;
}

.import-counts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
  padding: 0 20px 18px;
}

.import-count {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.import-count strong,
.import-count span {
  display: block;
}

.import-count strong {
  color: var(--blue-600);
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.import-count span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.64rem;
  overflow-wrap: anywhere;
  text-transform: capitalize;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 0 20px 20px;
}

.import-actions .primary,
.dialog-actions .primary {
  border: 0;
  background: var(--blue-600);
  color: #fff;
}

.security-note {
  margin: 0;
  border-top: 1px solid var(--line-soft);
  padding: 14px 20px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

/* Quality assurance, standards, and Google Workspace */
.agent-console {
  position: relative;
  min-width: 0;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid #b7d8f6;
  border-radius: var(--radius-lg);
  padding: 20px;
  background:
    radial-gradient(circle at 100% 0, rgba(39, 124, 243, 0.14), transparent 32%),
    linear-gradient(145deg, #fafdff, #eef6ff);
  box-shadow: 0 14px 34px rgba(13, 58, 102, 0.08);
}

.codes-agent-console {
  border-color: #b9ded7;
  background:
    radial-gradient(circle at 100% 0, rgba(32, 184, 168, 0.14), transparent 32%),
    linear-gradient(145deg, #fbfffe, #edf9f7);
}

.agent-intro {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.agent-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--navy-900), var(--blue-600));
  box-shadow: 0 10px 22px rgba(13, 87, 207, 0.2);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 900;
}

.codes-agent-console .agent-mark {
  background: linear-gradient(145deg, var(--navy-900), var(--aqua-600));
}

.agent-intro h3 {
  margin: 1px 0 5px;
  color: var(--navy-900);
  font-size: 1.25rem;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.agent-intro p:not(.eyebrow) {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.agent-state {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.63rem;
  font-weight: 820;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.agent-state.online {
  background: var(--success-bg);
  color: var(--success);
}

.agent-controls {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(180px, 0.36fr) minmax(300px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 17px;
}

.codes-agent-controls {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 10px;
}

.agent-controls label {
  min-width: 0;
  color: #456078;
  font-size: 0.65rem;
  font-weight: 790;
  letter-spacing: 0.03em;
}

.agent-controls select,
.agent-controls textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  border: 1px solid #c7d9e8;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
}

.agent-controls select {
  min-height: 48px;
  padding: 9px 11px;
}

.agent-controls textarea {
  min-height: 74px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.45;
}

.agent-run {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 17px;
  border: 0;
  border-radius: 10px;
  padding: 11px 15px;
  background: var(--navy-900);
  box-shadow: 0 8px 18px rgba(9, 43, 77, 0.16);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.agent-run:hover:not(:disabled) {
  background: var(--blue-700);
}

.agent-run span {
  font-size: 1rem;
}

.agent-privacy,
.agent-setup,
.agent-error {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.67rem;
}

.agent-setup,
.agent-error {
  color: var(--danger);
  font-weight: 700;
}

.agent-source-line {
  margin: 15px 0 0 60px;
  color: var(--muted);
  font-size: 0.69rem;
}

.agent-source-line strong {
  color: var(--navy-900);
}

.agent-quick-prompts {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 0 60px;
}

.agent-quick-prompts button {
  border: 1px solid #bcded7;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.75);
  color: #38675f;
  font-size: 0.66rem;
  font-weight: 740;
}

.agent-quick-prompts button:hover {
  border-color: var(--aqua-500);
  background: #fff;
}

.agent-result {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid rgba(166, 194, 216, 0.78);
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
}

.agent-result-head {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line-soft);
  padding: 16px;
}

.agent-result-head > div:first-child {
  min-width: 0;
}

.agent-result-head h4 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: 0.94rem;
  line-height: 1.5;
}

.agent-verdict {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.agent-score {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 16px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 720;
}

.agent-score progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e6eef4;
}

.agent-score progress::-webkit-progress-bar { background: #e6eef4; }
.agent-score progress::-webkit-progress-value { background: linear-gradient(90deg, var(--aqua-500), var(--blue-600)); }
.agent-score progress::-moz-progress-bar { background: linear-gradient(90deg, var(--aqua-500), var(--blue-600)); }

.agent-score strong {
  color: var(--navy-900);
  font-variant-numeric: tabular-nums;
}

.agent-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.agent-result-grid > section {
  min-width: 0;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 15px 16px;
}

.agent-result-grid > section:nth-child(2n) { border-right: 0; }
.agent-result-grid > section:nth-last-child(-n+2) { border-bottom: 0; }

.agent-result-grid h5 {
  margin: 0 0 10px;
  color: var(--navy-900);
  font-size: 0.7rem;
  font-weight: 820;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.agent-finding {
  border-left: 3px solid #c9d8e5;
  padding: 0 0 0 10px;
}

.agent-finding + .agent-finding {
  margin-top: 13px;
}

.agent-finding > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.agent-finding strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: 0.75rem;
}

.agent-finding p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.45;
}

.agent-list,
.agent-actions {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.agent-list li {
  position: relative;
  padding-left: 13px;
  color: #415a70;
  font-size: 0.7rem;
  line-height: 1.5;
}

.agent-list li::before {
  position: absolute;
  top: 0.58em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--aqua-500);
  content: "";
}

.agent-actions li {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.agent-actions li > span {
  border-radius: 6px;
  padding: 3px 4px;
  background: var(--blue-100);
  color: var(--blue-700);
  font-size: 0.58rem;
  font-weight: 820;
  text-align: center;
  text-transform: uppercase;
}

.agent-actions strong,
.agent-actions small {
  display: block;
  overflow-wrap: anywhere;
}

.agent-actions strong {
  color: #38536b;
  font-size: 0.7rem;
  line-height: 1.4;
}

.agent-actions small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
}

.agent-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.agent-disclaimer,
.agent-escalation {
  margin: 0;
  border-top: 1px solid var(--line-soft);
  padding: 11px 16px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.5;
}

.agent-escalation {
  background: var(--warning-bg);
  color: var(--warning);
}

.agent-citations {
  grid-column: 1 / -1;
  border-right: 0 !important;
}

.agent-citation {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(130px, 0.26fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 9px 10px;
  background: #fbfdfd;
}

.agent-citation + .agent-citation { margin-top: 7px; }
.agent-citation strong,
.agent-citation span,
.agent-citation small { display: block; overflow-wrap: anywhere; }
.agent-citation strong { color: var(--blue-700); font-size: 0.7rem; }
.agent-citation span,
.agent-citation small { color: var(--muted); font-size: 0.61rem; }
.agent-citation p { margin: 0; color: #415a70; font-size: 0.68rem; line-height: 1.45; }
.agent-citation a { color: var(--blue-700); font-size: 0.64rem; font-weight: 780; text-decoration: none; white-space: nowrap; }

.code-source-state {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 11px;
  color: var(--warning);
  font-size: 0.63rem;
  font-weight: 720;
}

.code-source-state span {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #d4a93e;
}

.code-source-state.ready { color: var(--success); }
.code-source-state.ready span { background: var(--aqua-500); }

.workspace-strip,
.standards-notice {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
  border: 1px solid #cddfeb;
  border-radius: 13px;
  padding: 13px 15px;
  background: #f7fafc;
}

.workspace-strip.is-connected {
  border-color: #b8ddd3;
  background: #f0faf7;
}

.workspace-mark,
.provider-logo {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #d8e2ea;
  border-radius: 10px;
  background: #fff;
  color: #4285f4;
  font-weight: 900;
}

.workspace-mark {
  width: 38px;
  height: 38px;
  font-size: 1rem;
}

.workspace-strip > div:nth-child(2),
.standards-notice > div {
  min-width: 0;
}

.workspace-strip strong,
.workspace-strip span,
.standards-notice strong,
.standards-notice span {
  display: block;
  overflow-wrap: anywhere;
}

.workspace-strip strong,
.standards-notice strong {
  color: var(--navy-900);
  font-size: 0.79rem;
}

.workspace-strip span,
.standards-notice span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.workspace-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
  margin-left: auto;
}

.workspace-actions button,
.standards-notice button,
.code-actions button,
.code-actions a,
.provider-actions button,
.provider-actions a,
.table-link {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid #cedbe6;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--navy-900);
  font-size: 0.7rem;
  font-weight: 780;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.workspace-actions button:hover,
.standards-notice button:hover,
.code-actions button:hover,
.code-actions a:hover,
.provider-actions a:hover,
.table-link:hover {
  border-color: #aebfd0;
  background: #f3f7fa;
}

.qa-photo-library {
  margin-bottom: 16px;
  border-color: #b9d7ed;
  background: linear-gradient(180deg, #fff 0%, #f8fbfe 100%);
}

.qa-photo-head {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line-soft);
  padding: 18px;
}

.qa-photo-head > div:first-child { min-width: 0; }
.qa-photo-head h3 { margin: 1px 0 4px; color: var(--navy-900); font-size: 1.08rem; letter-spacing: -0.025em; }
.qa-photo-head p:not(.eyebrow) { max-width: 760px; margin: 0; color: var(--muted); font-size: 0.74rem; line-height: 1.45; }

.qa-photo-count {
  display: flex;
  min-width: 118px;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  border: 1px solid #cce0ef;
  border-radius: 11px;
  padding: 8px 10px;
  background: #f3f9ff;
}

.qa-photo-count strong { color: var(--blue-700); font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.qa-photo-count span { color: var(--muted); font-size: 0.62rem; font-weight: 750; line-height: 1.25; }

.qa-photo-controls {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(230px, 1.15fr) minmax(130px, 0.46fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 15px 18px;
  background: #f5f9fc;
}

.qa-photo-controls label:not(.qa-upload-button) {
  min-width: 0;
  color: #456078;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.025em;
}

.qa-photo-controls select,
.qa-photo-controls input[type="text"] {
  display: block;
  width: 100%;
  min-height: 43px;
  margin-top: 5px;
  border: 1px solid #c8d9e6;
  border-radius: 9px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.72rem;
}

.qa-upload-button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9px;
  padding: 9px 15px;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  box-shadow: 0 8px 18px rgba(13, 87, 207, 0.18);
  color: #fff;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 820;
  white-space: nowrap;
}

.qa-upload-button:hover { background: linear-gradient(135deg, var(--navy-800), var(--blue-600)); }
.qa-upload-button.disabled { cursor: not-allowed; opacity: 0.48; }
.qa-upload-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }

.qa-photo-context {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid #e4edf4;
  border-bottom: 1px solid #e4edf4;
  padding: 11px 18px;
  background: #fff;
}

.qa-photo-context > div { min-width: 0; }
.qa-photo-context strong,
.qa-photo-context span { display: block; overflow-wrap: anywhere; }
.qa-photo-context strong { color: var(--navy-900); font-size: 0.74rem; }
.qa-photo-context span { margin-top: 2px; color: var(--muted); font-size: 0.65rem; }
.qa-photo-context a,
.qa-photo-context button { border: 0; padding: 0; background: transparent; color: var(--blue-700); font-size: 0.68rem; font-weight: 800; text-decoration: none; }
.qa-photo-context a:hover,
.qa-photo-context button:hover { text-decoration: underline; }

.qa-upload-status {
  margin: 0;
  padding: 9px 18px 0;
  color: var(--muted);
  font-size: 0.63rem;
}

.qa-photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 18px 18px;
}

.qa-photo-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d3e0e9;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(7, 29, 52, 0.055);
}

.qa-photo-preview {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #e9f0f5;
}

.qa-photo-preview img { width: 100%; height: 100%; object-fit: cover; transition: transform 180ms ease; }
.qa-photo-preview:hover img { transform: scale(1.025); }
.qa-photo-preview > span { position: absolute; top: 8px; left: 8px; border-radius: 999px; padding: 4px 7px; background: rgba(7, 29, 52, 0.82); color: #fff; font-size: 0.57rem; font-weight: 820; letter-spacing: 0.045em; text-transform: uppercase; backdrop-filter: blur(5px); }

.qa-photo-details { min-width: 0; padding: 10px; }
.qa-photo-details > strong,
.qa-photo-details > small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-photo-details > strong { color: var(--navy-900); font-size: 0.72rem; }
.qa-photo-details > small { margin-top: 3px; color: var(--muted); font-size: 0.6rem; }
.qa-photo-details > div { display: flex; min-width: 0; align-items: center; gap: 8px; margin-top: 9px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.qa-photo-details > div span { min-width: 0; margin-right: auto; overflow: hidden; color: #8193a4; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.55rem; text-overflow: ellipsis; white-space: nowrap; }
.qa-photo-details a,
.qa-photo-details button { border: 0; padding: 0; background: transparent; color: var(--blue-700); font-size: 0.61rem; font-weight: 800; text-decoration: none; }
.qa-photo-details button { color: var(--danger); }
.qa-photo-details a:hover,
.qa-photo-details button:hover { text-decoration: underline; }

.qa-photo-empty {
  display: grid;
  min-height: 160px;
  grid-column: 1 / -1;
  place-items: center;
  align-content: center;
  border: 1px dashed #bed1df;
  border-radius: 12px;
  padding: 22px;
  background: rgba(247, 251, 254, 0.72);
  text-align: center;
}

.qa-photo-empty > span { color: var(--blue-500); font-size: 1.65rem; }
.qa-photo-empty strong { margin-top: 5px; color: var(--navy-900); font-size: 0.8rem; }
.qa-photo-empty p { max-width: 480px; margin: 5px 0 0; color: var(--muted); font-size: 0.68rem; line-height: 1.45; }

.qa-metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.qa-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.qa-metric span,
.qa-metric strong {
  display: block;
}

.qa-metric span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.qa-metric strong {
  margin-top: 5px;
  color: var(--navy-900);
  font-size: 1.38rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.qa-section + .qa-section {
  margin-top: 16px;
}

.compact-search {
  width: min(230px, 42vw);
  min-height: 36px;
  flex: 0 1 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.73rem;
}

.score {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.status.critical,
.status.urgent,
.status.rework-required,
.status.failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.status.approved,
.status.verified,
.status.current,
.status.success {
  background: var(--success-bg);
  color: var(--success);
}

.status.ready-for-review,
.status.ready-for-verification,
.status.in-progress,
.status.under-review,
.status.started {
  background: var(--warning-bg);
  color: var(--warning);
}

.standards-notice {
  justify-content: space-between;
  border-color: #bcded7;
  background: #effaf7;
}

.standards-notice button {
  flex: 0 0 auto;
}

.code-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.code-grid > .empty {
  grid-column: 1 / -1;
}

.code-card {
  display: flex;
  min-width: 0;
  min-height: 315px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 17px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.code-card[hidden] {
  display: none;
}

.code-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.code-number {
  overflow-wrap: anywhere;
  color: var(--blue-600);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.code-card h4 {
  margin: 10px 0 14px;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: 1rem;
  line-height: 1.35;
}

.code-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.code-card dl div {
  min-width: 0;
}

.code-card dt {
  color: var(--muted-2);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.code-card dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.73rem;
  line-height: 1.35;
}

.code-card p {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.code-card .code-clause {
  border-radius: 8px;
  padding: 8px 9px;
  background: #f4f7fa;
  color: #3e566c;
}

.code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  margin-top: auto;
  padding-top: 16px;
}

.provider-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  overflow: hidden;
  border: 1px solid #d0dfeb;
  border-radius: var(--radius-lg);
  padding: 22px;
  background: linear-gradient(135deg, #fff, #f3f8fd);
  box-shadow: var(--shadow-sm);
}

.provider-hero.connected {
  border-color: #b8ddd3;
  background: linear-gradient(135deg, #fff, #effaf7);
}

.provider-logo {
  width: 58px;
  height: 58px;
  border-radius: 15px;
  font-size: 1.5rem;
  box-shadow: 0 8px 25px rgba(7, 29, 52, 0.08);
}

.provider-copy {
  min-width: 0;
}

.provider-copy h3 {
  margin: 3px 0 7px;
  overflow-wrap: anywhere;
  color: var(--navy-900);
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.provider-copy p:not(.eyebrow) {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.provider-actions {
  display: flex;
  min-width: 190px;
  flex-direction: column;
  gap: 8px;
}

.provider-actions .primary {
  border-color: var(--blue-600);
  background: var(--blue-600);
  color: #fff;
}

.provider-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.setup-panel {
  margin-top: 16px;
}

.setup-panel ol {
  margin: 0;
  padding: 18px 24px 8px 42px;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.65;
}

.setup-panel code {
  overflow-wrap: anywhere;
  color: var(--blue-700);
}

.setup-panel > p {
  margin: 0;
  padding: 0 20px 18px;
}

.sheet-setting-panel {
  margin-top: 16px;
}

.sheet-setting {
  display: flex;
  min-width: 0;
  gap: 9px;
  padding: 16px;
}

.sheet-setting input {
  min-width: 0;
  min-height: 40px;
  flex: 1 1 auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  color: var(--ink);
}

.sheet-setting button {
  flex: 0 0 auto;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.integration-card {
  display: flex;
  min-width: 0;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 17px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.integration-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  font-weight: 900;
}

.integration-icon.sheets { background: #188038; }
.integration-icon.docs { background: #1a73e8; }

.integration-card div {
  min-width: 0;
}

.integration-card h4 {
  margin: 0;
  color: var(--navy-900);
  font-size: 0.88rem;
}

.integration-card p,
.integration-card strong {
  display: block;
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.45;
}

.integration-card strong {
  color: var(--success);
}

.integration-history {
  margin-top: 16px;
}

.integration-history ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.integration-history li {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 16px;
}

.integration-history li:last-child {
  border-bottom: 0;
}

.integration-history li > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.integration-history li strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.73rem;
}

.integration-history time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.66rem;
}

/* Dialogs */
dialog {
  width: min(780px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(7, 29, 52, 0.34);
}

dialog::backdrop {
  background: rgba(7, 29, 52, 0.68);
  backdrop-filter: blur(3px);
}

dialog form {
  padding: 22px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h3 {
  margin: 0;
  color: var(--navy-900);
  font-size: 1.26rem;
  letter-spacing: -0.025em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.checkbox-field {
  display: flex !important;
  align-items: center;
  gap: 9px;
  margin-top: 24px;
}

.checkbox-field input {
  width: auto !important;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 17px;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  max-width: min(390px, calc(100vw - 32px));
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background: var(--navy-950);
  box-shadow: var(--shadow);
  color: #fff;
  opacity: 0;
  overflow-wrap: anywhere;
  transform: translateY(110px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1240px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric:nth-child(4),
  .metric:nth-child(5) {
    grid-column: span 1;
  }

  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .qa-metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .qa-photo-controls {
    grid-template-columns: minmax(220px, 1fr) minmax(130px, 0.42fr) minmax(220px, 1fr);
  }

  .qa-upload-button { grid-column: 3; }

  .qa-photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .code-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1060px) {
  .dashboard-grid {
    display: flex;
    flex-direction: column;
  }

  .dashboard-main,
  .dashboard-rail {
    display: contents;
  }

  .dashboard-quick { order: 1; }
  .dashboard-priority { order: 2; }
  .dashboard-jobs { order: 3; }
  .dashboard-activity { order: 4; }
  .dashboard-leads { order: 5; }
  .dashboard-intelligence { order: 6; }

  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .import-counts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .agent-controls {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .qa-agent-console .agent-controls > label:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-art {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 20;
    top: 0;
    left: -270px;
    width: 252px;
    transition: left 200ms ease;
  }

  .sidebar.open {
    left: 0;
    box-shadow: 20px 0 60px rgba(7, 29, 52, 0.34);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 19;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(7, 29, 52, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  .topbar {
    height: 68px;
    padding: 0 14px;
  }

  .topbar #menu-btn {
    display: grid;
  }

  .content {
    padding: 16px 14px 32px;
  }

  .qa-photo-controls {
    grid-template-columns: minmax(0, 1fr) minmax(130px, 0.42fr);
  }

  .qa-photo-caption { grid-column: 1 / -1; }
  .qa-upload-button { grid-column: 1 / -1; }

  .qa-photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .command-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
    padding: 22px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .page-head {
    align-items: flex-start;
  }

  .business-profile {
    align-items: flex-start;
  }

  .provider-hero {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .provider-actions {
    min-width: 0;
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .provider-actions > * {
    min-width: 160px;
    flex: 1 1 160px;
  }
}

@media (max-width: 700px) {
  .top-actions .primary {
    display: none;
  }

  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qa-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .code-grid,
  .integration-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-strip,
  .standards-notice {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .workspace-actions {
    width: 100%;
    margin-left: 0;
    padding-left: 51px;
  }

  .qa-photo-head,
  .qa-photo-context {
    align-items: flex-start;
    flex-direction: column;
  }

  .qa-photo-count { min-width: 0; }

  .qa-photo-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .qa-photo-caption,
  .qa-upload-button { grid-column: auto; }

  .standards-notice button {
    width: 100%;
  }

  .compact-search {
    width: 100%;
    flex-basis: 100%;
  }

  .sheet-setting {
    flex-direction: column;
  }

  .sheet-setting button {
    width: 100%;
  }

  .qa-section .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-console {
    padding: 16px;
  }

  .agent-intro {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .agent-state {
    grid-column: 2;
    justify-self: start;
  }

  .agent-controls,
  .codes-agent-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .qa-agent-console .agent-controls > label:first-child {
    grid-column: auto;
  }

  .agent-run {
    width: 100%;
  }

  .agent-source-line,
  .agent-quick-prompts {
    margin-left: 0;
  }

  .agent-result-head {
    flex-direction: column;
  }

  .agent-verdict {
    justify-content: flex-start;
  }

  .agent-result-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .agent-result-grid > section,
  .agent-result-grid > section:nth-child(2n),
  .agent-result-grid > section:nth-last-child(-n+2) {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .agent-result-grid > section:last-child {
    border-bottom: 0;
  }

  .agent-citation {
    grid-template-columns: minmax(0, 1fr);
  }

  .agent-citation a {
    white-space: normal;
  }

  .table-wrap {
    overflow: visible;
    padding: 10px;
    background: #f7f9fb;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(7, 29, 52, 0.035);
  }

  td,
  td[data-key] {
    display: grid;
    max-width: none;
    grid-template-columns: minmax(88px, 0.38fr) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    border-bottom: 1px solid var(--line-soft);
    padding: 9px 11px;
    font-size: 0.75rem;
    text-align: left;
    white-space: normal;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.61rem;
    font-weight: 820;
    letter-spacing: 0.065em;
    line-height: 1.45;
    text-transform: uppercase;
  }

  td:first-child {
    padding-top: 12px;
    background: #fbfcfe;
  }

  td:last-child {
    border-bottom: 0;
    padding-bottom: 12px;
  }

  tbody tr:hover td {
    background: inherit;
  }

  .money {
    text-align: left;
  }

  .row-actions {
    width: 100%;
    min-width: 0;
  }

  .table-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions {
    justify-content: space-between;
  }

  .import-counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid .wide {
    grid-column: auto;
  }
}

@media (max-width: 470px) {
  .login-panel {
    padding: 25px 20px;
  }

  .login-product {
    margin-bottom: 22px;
  }

  .login-panel h1 {
    font-size: 2.55rem;
  }

  .tenant-lockup {
    align-self: stretch;
  }

  .topbar h2 {
    font-size: 1.12rem;
  }

  .topbar .eyebrow {
    font-size: 0.58rem;
  }

  .avatar {
    width: 36px;
    height: 36px;
  }

  .metric-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric {
    padding: 15px 16px;
  }

  .quick-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .qa-metric-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .qa-photo-grid { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .qa-photo-head,
  .qa-photo-controls,
  .qa-photo-context { padding-right: 13px; padding-left: 13px; }

  .agent-intro {
    grid-template-columns: minmax(0, 1fr);
  }

  .agent-state {
    grid-column: auto;
  }

  .agent-score {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .agent-score > span {
    grid-column: 1 / -1;
  }

  .provider-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .provider-logo {
    width: 48px;
    height: 48px;
  }

  .provider-actions {
    grid-column: auto;
    flex-direction: column;
  }

  .integration-history li,
  .integration-history li > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace-actions {
    padding-left: 0;
  }

  .command-hero h3 {
    font-size: 1.78rem;
  }

  .panel-head {
    align-items: flex-start;
  }

  .panel-head > .muted {
    text-align: right;
  }

  .business-profile {
    flex-direction: column;
  }

  .import-counts {
    grid-template-columns: minmax(0, 1fr);
  }

  .import-actions,
  .dialog-actions {
    flex-direction: column-reverse;
  }

  .import-actions button,
  .dialog-actions button {
    width: 100%;
    min-height: 42px;
  }

  dialog {
    width: calc(100% - 18px);
    max-height: calc(100vh - 18px);
    border-radius: 14px;
  }

  dialog form {
    padding: 18px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
