:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #5d6b7a;
  --line: #d8dee6;
  --brand: #125d6b;
  --brand-strong: #0b4654;
  --accent: #c27b2c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 64px;
  justify-content: space-between;
  padding: 0 28px;
}

.brand {
  align-items: center;
  display: inline-flex;
  font-size: 15px;
  font-weight: 700;
  gap: 10px;
}

.brand-mark,
.tool-icon {
  align-items: center;
  background: var(--brand);
  color: #ffffff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.topbar nav a {
  color: var(--muted);
  font-size: 14px;
}

.shell {
  margin: 0 auto;
  max-width: 980px;
  padding: 44px 24px;
}

.shell:has(.kanban-board) {
  max-width: none;
  padding-left: 14px;
  padding-right: 14px;
}

.page-head {
  margin-bottom: 28px;
  max-width: 720px;
}

.page-head.compact {
  max-width: 680px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1 {
  font-size: 36px;
  line-height: 1.1;
  margin: 0 0 12px;
}

p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
}

.tool-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.tool-card {
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 14px;
  min-height: 116px;
  padding: 18px;
  transition: border-color 150ms ease, transform 150ms ease;
}

.tool-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.tool-card strong,
.tool-card small {
  display: block;
}

.tool-card strong {
  font-size: 16px;
  margin-bottom: 6px;
}

.tool-card small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.upload-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.dropzone {
  align-items: center;
  border: 1px dashed #9aa8b6;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  min-height: 180px;
  padding: 24px;
  text-align: center;
}

.dropzone input {
  height: 1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.drop-title {
  color: var(--brand-strong);
  font-size: 18px;
  font-weight: 700;
}

.drop-subtitle {
  color: var(--muted);
  font-size: 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

button {
  background: var(--brand);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  margin-top: 16px;
  min-height: 44px;
  padding: 0 18px;
}

button:hover {
  background: var(--brand-strong);
}

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

.status {
  color: var(--brand-strong);
  font-size: 14px;
  margin-top: 12px;
  min-height: 22px;
}

.auth-form,
.filters-grid,
.editor-fields {
  display: grid;
  gap: 14px;
}

.auth-form {
  max-width: 420px;
}

label span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

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

textarea {
  min-height: 94px;
  resize: vertical;
}

.market-app {
  display: grid;
  gap: 16px;
}

.market-toolbar,
.action-row,
.dialog-head,
.dialog-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.market-toolbar,
.filters-grid,
.results-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.filters-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.filter-actions {
  align-items: end;
  display: flex;
  gap: 8px;
}

.secondary-button {
  background: #eef3f6;
  color: var(--brand-strong);
}

.secondary-button:hover {
  background: #dde8ed;
}

.results-wrap {
  overflow: auto;
  padding: 0;
}

table {
  border-collapse: collapse;
  min-width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  max-width: 260px;
  overflow: hidden;
  padding: 10px 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  background: #f1f5f7;
  color: var(--brand-strong);
  font-weight: 700;
  position: sticky;
  top: 0;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7fbfc;
}

.market-dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 18px 70px rgba(22, 34, 46, 0.28);
  max-height: 88vh;
  max-width: 1120px;
  padding: 18px;
  width: min(1120px, calc(100vw - 32px));
}

.market-dialog::backdrop {
  background: rgba(20, 29, 38, 0.42);
}

.editor-fields {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  margin: 16px 0;
  max-height: 34vh;
  overflow: auto;
  padding-right: 4px;
}

.structured-box textarea,
.report-dialog textarea {
  font-family: Consolas, "Courier New", monospace;
  min-height: 260px;
}

.large-textarea {
  min-height: 180px;
}

.kanban-head {
  align-items: end;
  display: flex;
  justify-content: space-between;
  max-width: none;
}

.kanban-head button {
  margin-top: 0;
}

.kanban-summary {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.kanban-summary span {
  color: var(--muted);
  font-size: 12px;
}

.kanban-summary #kanban-total {
  color: var(--brand-strong);
  font-weight: 700;
}

.legend-item {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.legend-filter {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  margin-top: 0;
  min-height: 30px;
  padding: 0 10px;
}

.legend-filter:hover,
.legend-filter.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.legend-filter.active .client-badge,
.legend-filter.active .owner-badge,
.legend-filter.active .warning-badge {
  outline: 1px solid rgba(255, 255, 255, 0.7);
}

.kanban-board {
  --kanban-column-count: 1;
  align-items: start;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(var(--kanban-column-count), minmax(0, 1fr));
  overflow: visible;
  padding-bottom: 12px;
  width: 100%;
}

.kanban-column {
  background: #edf2f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 360px;
  min-width: 0;
  overflow: hidden;
  padding: 7px;
}

.kanban-column-head {
  align-items: center;
  cursor: grab;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kanban-column.dragging-column {
  opacity: 0.55;
}

.kanban-column-head strong {
  color: var(--brand-strong);
  font-size: 12px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.kanban-column-head span {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  height: 22px;
  justify-content: center;
  min-width: 22px;
  padding: 0 7px;
}

.kanban-cards {
  display: grid;
  gap: 7px;
}

.kanban-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 8px;
  padding: 7px;
}

.kanban-card.client-action {
  border-left-color: #c73939;
}

.kanban-card.owner-action {
  border-left-color: #23884b;
}

.kanban-card.other-agent-action {
  border-left-color: #d8a900;
}

.kanban-card-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.kanban-card-head a {
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}

.card-flags {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  min-height: 20px;
}

.client-badge,
.owner-badge,
.warning-badge {
  align-items: center;
  border-radius: 50%;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  height: 18px;
  justify-content: center;
  width: 18px;
}

.client-badge {
  background: #e54848;
  color: #ffffff;
}

.owner-badge {
  background: #2f9d58;
  color: #ffffff;
}

.warning-badge {
  background: #f8d256;
  color: #5a4300;
}

.kanban-card h2 {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
  margin: 5px 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.ticket-meta {
  display: grid;
  gap: 2px;
  margin-bottom: 6px;
}

.ticket-meta span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.ticket-urgency {
  color: var(--brand-strong);
  font-weight: 700;
}

.actions-stack {
  display: grid;
  gap: 5px;
}

.kanban-action {
  border-top: 1px solid var(--line);
  padding-top: 5px;
}

.kanban-action strong,
.kanban-action span {
  display: block;
}

.kanban-action strong {
  color: var(--brand-strong);
  font-size: 10px;
  margin-bottom: 2px;
}

.kanban-action span {
  color: var(--muted);
  font-size: 9px;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.kanban-action p {
  color: var(--ink);
  display: -webkit-box;
  font-size: 10px;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
}

.expand-actions-button,
.download-actions-button {
  align-items: center;
  background: #eef3f6;
  border-radius: 6px;
  color: var(--brand-strong);
  display: inline-flex;
  font-size: 12px;
  gap: 5px;
  margin-top: 7px;
  min-height: 30px;
  padding: 0 9px;
}

.expand-actions-button:hover,
.download-actions-button:hover {
  background: #dde8ed;
}

.download-actions-button {
  margin-left: 5px;
}

.expand-actions-button span {
  display: inline-block;
  font-size: 13px;
  line-height: 1;
}

.recent-actions {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 7px;
  margin-top: 7px;
  padding-top: 7px;
}

.recent-actions[hidden] {
  display: none;
}

.recent-action strong,
.recent-action span {
  display: block;
}

.recent-action strong {
  color: var(--brand-strong);
  font-size: 11px;
  margin-bottom: 2px;
}

.recent-action span {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.recent-action p {
  color: var(--ink);
  display: -webkit-box;
  font-size: 11px;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
}

.empty-action span,
.empty-column,
.empty-kanban {
  color: var(--muted);
  font-size: 11px;
}

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

.dialog-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
  }

  .shell {
    padding: 28px 16px;
  }

  h1 {
    font-size: 30px;
  }

  .filters-grid,
  .editor-fields {
    grid-template-columns: 1fr;
  }

  .kanban-head {
    align-items: stretch;
    display: grid;
    gap: 12px;
  }

  .kanban-board {
    grid-template-columns: repeat(var(--kanban-column-count), minmax(0, 1fr));
  }
}
