:root {
  color-scheme: light;
  --ink: #1c2923;
  --muted: #78847c;
  --line: #e6ebe7;
  --page: #f5f7f5;
  --green: #28674f;
  --green-light: #eaf4ee;
  --blue-light: #edf3f8;
  --amber-light: #fff5e5;
  --shadow: 0 7px 24px #24372b0b;
}

* { box-sizing: border-box; }

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

button, input, select { font: inherit; }
button { cursor: pointer; }

.layout { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { padding: 18px 13px; background: #fbfcfb; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 9px; padding: 0 9px 22px; font-size: 14px; font-weight: 760; }
.brand-icon { width: 27px; height: 27px; border-radius: 8px; background: #315e7a; color: white; display: grid; place-items: center; }
.agency { display: flex; align-items: center; gap: 8px; margin: 0 3px 21px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.agency-mark { width: 27px; height: 27px; border-radius: 7px; background: #e7eee9; color: #456e57; display: grid; place-items: center; font-size: 10px; font-weight: 750; }
.agency b, .agency small { display: block; }
.agency b { font-size: 10px; }
.agency small { color: var(--muted); font-size: 9px; }
.nav-label { padding: 0 10px 7px; color: #9aa49d; font-size: 9px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.nav { display: grid; gap: 3px; }
.nav button { padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: #69766e; text-align: left; font-size: 11px; }
.nav button.selected { background: #edf2ef; color: #354d3f; font-weight: 700; }
.glyph { display: inline-block; width: 23px; }
.side-footer { margin-top: auto; padding: 13px 9px 0; border-top: 1px solid var(--line); color: #98a29b; font-size: 9px; line-height: 1.5; }

.main { min-width: 0; }
.topbar { height: 52px; padding: 0 23px; border-bottom: 1px solid var(--line); background: white; display: flex; align-items: center; justify-content: space-between; }
.crumb { color: var(--muted); font-size: 10px; }
.crumb strong { color: #425047; }
.connected, .demo-badge { padding: 5px 8px; border-radius: 12px; background: var(--green-light); color: var(--green); font-size: 9px; font-weight: 700; }
.main-inner { max-width: 1600px; margin: 0 auto; padding: 23px 22px; }
.heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.heading h1 { margin: 0 0 3px; font-size: 21px; letter-spacing: -.6px; }
.heading p { margin: 0; color: var(--muted); font-size: 10px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-bottom: 14px; }
.stat, .card { border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); }
.stat { padding: 11px 13px; }
.stat-label { color: #87938b; font-size: 9px; }
.stat strong { display: block; margin-top: 3px; font-size: 18px; }
.workspace { display: grid; grid-template-columns: minmax(550px, 1.7fr) minmax(300px, .8fr); gap: 13px; align-items: start; }
.card { min-width: 0; overflow: hidden; }
.card-head { min-height: 53px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 12px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }

.filters { padding: 12px; border-bottom: 1px solid var(--line); background: #fcfdfc; display: grid; grid-template-columns: 1.15fr 1fr 1fr 1.3fr .9fr; gap: 8px; }
.filters label, .field-wrap { display: grid; gap: 4px; color: #65736a; font-size: 8px; font-weight: 700; }
.filters input, .filters select, .field-control { min-width: 0; width: 100%; height: 32px; padding: 0 8px; border: 1px solid #dfe7e1; border-radius: 6px; background: white; color: #39483f; font-size: 10px; }
.table-scroll { overflow: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
thead th { padding: 9px 10px; background: #fafbfa; color: #89958d; font-size: 8px; letter-spacing: .5px; text-align: left; text-transform: uppercase; }
tbody td { padding: 10px; border-top: 1px solid #eff2ef; font-size: 9px; vertical-align: middle; }
tbody tr:hover { background: #fafcfb; }
.select-column { width: 58px; }
.visit-checkbox { width: 16px; height: 16px; accent-color: var(--green); }
.client { font-size: 10px; font-weight: 700; }
.sub { margin-top: 2px; color: #929d95; font-size: 8px; }
.type { color: #526057; }
.pill { display: inline-flex; padding: 3px 7px; border-radius: 10px; font-size: 8px; font-weight: 700; white-space: nowrap; }
.pill.scheduled { background: var(--blue-light); color: #62788e; }
.pill.in-progress { background: #edf3f8; color: #58779a; }
.pill.completed { background: var(--green-light); color: var(--green); }
.table-foot { padding: 9px 12px; border-top: 1px solid var(--line); color: #929d95; display: flex; justify-content: space-between; gap: 8px; font-size: 8px; }

.action-content { padding: 13px; }
.instructions { display: grid; gap: 6px; margin: 0 0 13px; padding-left: 20px; color: #536158; font-size: 9px; }
.selection-summary { margin-bottom: 12px; padding: 10px; border: 1px solid #e5ece6; border-radius: 8px; background: #fafcfa; color: #65736a; font-size: 9px; }
.field-wrap { margin-bottom: 11px; }
.change-preview { display: grid; gap: 5px; margin: 10px 0; }
.change-row { padding: 7px 8px; border: 1px solid #edf1ed; border-radius: 6px; background: #fafbf9; font-size: 8px; }
.change-row strong { display: block; margin-bottom: 3px; font-size: 9px; }
.change-row span { color: #78847c; }
.primary { width: 100%; padding: 9px 10px; border: 0; border-radius: 7px; background: var(--green); color: white; font-size: 10px; font-weight: 700; }
.primary:disabled { cursor: not-allowed; background: #9eafa4; }
.notice { min-height: 26px; margin: 9px 0 0; color: #68766d; font-size: 8px; }
.agent-panel { margin-top: 13px; padding: 11px; border: 1px solid #cfded3; border-radius: 8px; background: #fbfdfb; }
.agent-panel[hidden], .agent-output[hidden], .agent-screenshot[hidden], .agent-buttons [hidden] { display: none; }
.agent-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.agent-panel-head h3 { margin: 0; font-size: 10px; }
.agent-panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 8px; }
.agent-badge { padding: 3px 6px; border-radius: 10px; background: var(--green-light); color: var(--green); font-size: 7px; white-space: nowrap; }
.agent-panel .field-wrap { margin-bottom: 8px; }
.agent-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.agent-buttons button { width: auto; padding: 7px 8px; font-size: 8px; }
.secondary { border: 1px solid #dfe7e1; border-radius: 7px; background: white; color: var(--green); font-size: 8px; font-weight: 700; }
.agent-status { margin: 8px 0 0; color: #65736a; font-size: 8px; }
.origin-approval { margin-top: 8px; padding: 8px; border: 1px solid #e4d5b5; border-radius: 6px; background: var(--amber-light); color: #77571f; font-size: 8px; }
.origin-approval button { width: auto; margin: 7px 5px 0 0; padding: 6px 8px; font-size: 8px; }
.agent-output { margin-top: 8px; padding: 8px; border-radius: 6px; background: #f1f6f2; color: #44544a; font-size: 8px; white-space: pre-wrap; }
.agent-screenshot { display: block; width: 100%; max-height: 280px; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; object-fit: contain; background: white; }
.agent-events { display: grid; gap: 4px; margin-top: 7px; color: #78847c; font-size: 7px; }
.agent-event { padding-top: 4px; border-top: 1px solid #e9eeea; }
.activity { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.activity h3 { margin: 0 0 7px; color: #65736a; font-size: 9px; }
.log { display: grid; gap: 6px; }
.log-line, .empty-log { margin: 0; color: #69766d; font-size: 8px; }
.log-line::before { content: "✓ "; color: var(--green); font-weight: 800; }
.fineprint { margin: 10px 0 0; color: #9aa49d; font-size: 7px; line-height: 1.5; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 5; padding: 10px 13px; border-radius: 8px; background: #193e30; color: white; font-size: 10px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1.3fr) minmax(280px, .8fr); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 62px minmax(0, 1fr); }
  .sidebar { padding: 15px 8px; }
  .brand { justify-content: center; padding: 0 0 20px; }
  .brand > span:last-child, .agency, .nav-label, .side-footer { display: none; }
  .nav button { padding: 10px 8px; text-align: center; font-size: 0; }
  .glyph { font-size: 14px; }
  .workspace { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .layout { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 0 12px; }
  .main-inner { padding: 15px 10px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-label { grid-column: span 2; }
  .table-foot { align-items: flex-start; flex-direction: column; }
}
