:root {
  color-scheme: dark;
  --bg: #10181c;
  --surface: #17242a;
  --surface-strong: #223239;
  --input-bg: #132026;
  --table-head: #1c2b31;
  --row-muted: #1a292f;
  --text: #edf5f6;
  --muted: #aabdc5;
  --border: #38505a;
  --accent: #0f8b8d;
  --accent-dark: #32b9bb;
  --green: #52bf7d;
  --amber: #f0b95b;
  --red: #ee7d7d;
  --secondary-bg: #2a3b43;
  --secondary-text: #d9e7eb;
  --secondary-hover: #38505a;
  --link-bg: #193a3d;
  --link-hover: #215257;
  --warning-bg: #3d3219;
  --warning-border: #82642b;
  --info-bg: #18323d;
  --info-border: #2f6980;
  --priority-row: #19352f;
  --priority-badge: #245843;
  --priority-text: #a7e3c3;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f9fb;
  --surface: #ffffff;
  --surface-strong: #f1f5f7;
  --input-bg: #ffffff;
  --table-head: #fafcfd;
  --row-muted: #fbfcfc;
  --text: #1d252b;
  --muted: #66737d;
  --border: #dfe6ea;
  --accent: #0f8b8d;
  --accent-dark: #0b6d70;
  --green: #268a52;
  --amber: #b7791f;
  --red: #b54747;
  --secondary-bg: #eef1f3;
  --secondary-text: #40505a;
  --secondary-hover: #dfe6ea;
  --link-bg: #edf7f7;
  --link-hover: #d9eeee;
  --warning-bg: #fff8e6;
  --warning-border: #f0d9a8;
  --info-bg: #e6f6ff;
  --info-border: #b3d9ff;
  --priority-row: #f3fbf8;
  --priority-badge: #d9f0e7;
  --priority-text: #216748;
  --shadow: 0 16px 40px rgba(29, 37, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.theme-toggle {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #d6e0e5;
  font-size: 13px;
  text-align: left;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.13);
  color: #ffffff;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  cursor: pointer;
}

.table-sort-button span { color: var(--muted); font-size: 12px; }
.table-sort-button:hover { color: var(--accent); }
.table-sort-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

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

.app-shell.is-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app-shell.is-collapsed .sidebar {
  padding: 0;
  overflow: hidden;
}

.login-panel,
.signup-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
  width: auto;
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.login-brand .brand-mark {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.login-brand strong {
  font-size: 22px;
  display: block;
}

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

.login-environment-note {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 20px;
}

.login-header {
  text-align: center;
  margin-bottom: 20px;
}

.login-header h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.login-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form .field-control {
  margin-bottom: 16px;
}

.bootstrap-banner {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 18px;
  text-align: center;
}

.bootstrap-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.bootstrap-password {
  display: inline-block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-dark);
  background: var(--input-bg);
  border: 1px dashed var(--accent);
  border-radius: 4px;
  padding: 6px 12px;
  margin-bottom: 8px;
}

.bootstrap-banner small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.login-footer {
  text-align: center;
  margin: 18px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.login-footer a {
  color: var(--accent);
  text-decoration: underline;
}

.sidebar {
  background: #172126;
  color: #ffffff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand div > span {
  color: #9fb0ba;
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  color: #d6e0e5;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.nav-list a.active,
.nav-list a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-note span,
.sidebar-note small,
.metric span {
  color: var(--muted);
  font-size: 12px;
}

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

.sidebar-note strong {
  margin: 5px 0 2px;
}

.sidebar-note small {
  color: #aebbc2;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 16px;
  line-height: 1.25;
}

.topbar p,
.panel-header p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.panel-header .new-jobs-summary {
  color: var(--accent-dark);
  font-weight: 700;
}

.priority-company-row {
  background: var(--priority-row);
}

.priority-company-row .job-title::after {
  content: "Prioritaria";
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--priority-badge);
  color: var(--priority-text);
  font-size: 11px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.field-control {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.field-control select {
  height: 38px;
  min-width: 128px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  min-height: 40px;
  padding: 0 15px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  background: var(--secondary-bg);
  color: var(--muted);
  cursor: not-allowed;
}

.secondary-button {
  min-height: 38px;
  background: var(--secondary-bg);
  color: var(--secondary-text);
}

.secondary-button:hover {
  background: var(--secondary-hover);
}

.button-icon {
  font-size: 12px;
  margin-right: 6px;
}

.metrics-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

.metric {
  padding: 16px;
  min-height: 92px;
}

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

.metric strong {
  font-size: 32px;
  margin-top: 8px;
  letter-spacing: 0;
}

.panel {
  box-shadow: var(--shadow);
}

.panel-header {
  min-height: 68px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.idle {
  color: var(--secondary-text);
  background: var(--surface-strong);
}

.badge.running {
  color: #ffffff;
  background: var(--accent);
}

.badge.error {
  color: #ffffff;
  background: var(--red);
}

.badge.warning {
  color: #5f3b00;
  background: #f6c453;
}

.log-list {
  height: 176px;
  overflow: auto;
  margin: 0;
  padding: 12px 16px 16px 32px;
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.log-list li + li {
  margin-top: 4px;
}

.jobs-panel {
  margin-top: 0;
}

.all-jobs-panel {
  margin-top: 0;
}

.execution-log {
  margin-top: 14px;
  overflow: hidden;
}

.execution-log .log-list {
  height: min(360px, calc(100vh - 330px));
  min-height: 176px;
}

.cvs-panel {
  margin-top: 0;
}

.companies-panel {
  margin-top: 0;
}

.table-header {
  align-items: end;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.filters input,
.filters select {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}

.filters input {
  width: 280px;
  padding: 0 12px;
}

.filters select {
  width: 170px;
  padding: 0 10px;
}

.filters select[multiple] {
  height: 78px;
  padding: 7px 10px;
}


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

.filters .filter-actions button {
  min-height: 38px;
  white-space: nowrap;
}

#companyFilter {
  width: 220px;
}

#applyJobFilters {
  min-width: 132px;
}

#jobFiltersForm[aria-busy="true"] #applyJobFilters {
  cursor: wait;
}

.table-wrap {
  overflow: auto;
}

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

table th:last-child,
table td:last-child {
  position: static;
  right: auto;
  z-index: auto;
  background: inherit;
  box-shadow: none;
}

tr.opened-row td:last-child { background: var(--row-muted); }
tr.applied-row td:last-child { background: rgba(38, 138, 82, 0.06); }
tr.new-job-row td:last-child { background: rgba(15, 139, 141, 0.07); }
tr.new-job-row.opened-row td:last-child { background: rgba(15, 139, 141, 0.045); }

.cvs-table {
  min-width: 1080px;
}

.companies-table {
  min-width: 1260px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: var(--table-head);
}

td.score-cell {
  font-weight: 800;
}

.date-cell {
  color: var(--muted);
  white-space: nowrap;
}

tr.opened-row {
  background: var(--row-muted);
}

tr.opened-row .job-title {
  color: var(--muted);
}

tr.applied-row {
  background: rgba(38, 138, 82, 0.06);
}

tr.new-job-row {
  background: rgba(15, 139, 141, 0.07);
  box-shadow: inset 3px 0 0 var(--accent);
}

tr.new-job-row.opened-row {
  background: rgba(15, 139, 141, 0.045);
}

.section-divider-row td {
  padding: 10px 14px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.new-job-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 8px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(15, 139, 141, 0.14);
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.priority {
  display: inline-flex;
  align-items: center;
  min-width: 74px;
  justify-content: center;
  height: 26px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.priority.alta {
  background: rgba(38, 138, 82, 0.12);
  color: var(--green);
}

.priority.media {
  background: rgba(15, 139, 141, 0.12);
  color: var(--accent-dark);
}

.priority.baixa {
  background: rgba(183, 121, 31, 0.14);
  color: var(--amber);
}

.priority.revisar {
  background: rgba(72, 92, 126, 0.12);
  color: #485c7e;
}

.priority.descartar {
  background: rgba(181, 71, 71, 0.12);
  color: var(--red);
}

.priority.sem-avaliacao {
  background: var(--secondary-bg);
  color: var(--secondary-text);
}

.provisional-badge {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.source-priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.source-priority.source-alta {
  background: rgba(38, 138, 82, 0.12);
  color: var(--green);
}

.source-priority.source-media {
  background: rgba(15, 139, 141, 0.12);
  color: var(--accent-dark);
}

.source-priority.source-monitoramento {
  background: rgba(183, 121, 31, 0.14);
  color: var(--amber);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 360px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--secondary-bg);
  color: var(--secondary-text);
  font-size: 12px;
  font-weight: 700;
}

.company-counts {
  display: grid;
  gap: 4px;
  min-width: 110px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.company-counts span:last-child {
  color: var(--muted);
}

.company-load-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.company-load-cell {
  vertical-align: top;
  min-width: 230px;
}

.company-load-cell .company-load-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.inline-result {
  display: block;
  max-width: 220px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.job-title {
  font-weight: 750;
  max-width: 360px;
}

.duplicate-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  margin-left: 8px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--secondary-bg);
  color: var(--secondary-text);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--link-bg);
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.link-button:hover {
  background: var(--link-hover);
}

.link-button.opened {
  background: var(--secondary-bg);
  color: var(--secondary-text);
}

.link-button.opened::before {
  content: "✓";
  margin-right: 5px;
}

.applied-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--secondary-text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.applied-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.status-select {
  height: 30px;
  min-width: 118px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.detail-button {
  min-height: 30px;
  padding: 0 11px;
  background: var(--secondary-bg);
  color: var(--secondary-text);
  font-size: 12px;
}

.detail-button:hover {
  background: var(--secondary-hover);
}

.detail-row td {
  background: var(--row-muted);
  padding: 0;
}

.detail-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.detail-panel section {
  min-width: 0;
}

.detail-panel h3 {
  margin: 0 0 8px;
  color: var(--secondary-text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.detail-panel ul {
  margin: 0;
  padding-left: 17px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.detail-panel li + li {
  margin-top: 5px;
}

.all-job-detail-panel {
  grid-template-columns: 2fr 1.4fr 1fr 1fr;
}

.all-job-detail-panel section:first-child {
  min-width: 320px;
}

.cv-action {
  display: grid;
  align-content: start;
  gap: 9px;
}

.cv-button {
  min-height: 32px;
  width: fit-content;
  padding: 0 12px;
  font-size: 12px;
}

.cv-result {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.file-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--link-bg);
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 800;
}

.file-action-link:hover {
  background: var(--link-hover);
}

.cv-path {
  flex-basis: 100%;
}

.context-strip {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--secondary-text);
  font-size: 13px;
  font-weight: 700;
}

.file-name-cell {
  max-width: 320px;
  overflow-wrap: anywhere;
  color: var(--secondary-text);
}

.table-actions {
  vertical-align: middle;
}

.table-actions > * + * {
  margin-left: 6px;
}

.muted-link {
  background: var(--secondary-bg);
  color: var(--secondary-text);
}

.muted-link:hover {
  background: var(--secondary-hover);
}

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.source-observability-row {
  cursor: pointer;
}

.source-observability-row:hover,
.source-observability-row:focus {
  background: var(--surface-strong);
  outline: 2px solid transparent;
}

.source-item-list {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

@media (max-width: 980px) {
  .app-shell,
  .app-shell.is-collapsed {
    grid-template-columns: 1fr;
  }

  .app-shell.is-collapsed .sidebar {
    padding: 24px 18px;
    overflow: visible;
  }

  .sidebar {
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .nav-list {
    grid-auto-flow: column;
    overflow: auto;
  }

  .sidebar-note {
    margin: 0 0 0 auto;
  }

  .topbar,
  .table-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .filters {
    flex-direction: column;
  }

  .filters input,
  .filters select {
    width: 100%;
  }

  .filters .filter-actions {
    width: 100%;
  }

  .filters .filter-actions button {
    flex: 1;
  }

  .detail-panel {
    grid-template-columns: 1fr 1fr;
  }

  .all-job-detail-panel {
    grid-template-columns: 1fr;
  }
}

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

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

  button {
    width: 100%;
  }

  #sidebarToggle {
    width: auto;
    align-self: flex-start;
  }

  .sidebar-note {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  table th:last-child,
  table td:last-child {
    position: static;
    box-shadow: none;
    background: transparent;
  }

  tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px;
    border: 0;
    padding: 6px 0;
    align-items: center;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .job-title {
    max-width: none;
  }

  .link-button {
    width: fit-content;
  }

  .detail-row td {
    display: block;
  }

  .detail-row td::before {
    content: none;
  }

  .detail-panel {
    grid-template-columns: 1fr;
  }
}

.favorite-star {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  margin-right: 6px;
  padding: 0;
  vertical-align: middle;
}

.favorite-star.is-favorite,
.favorite-row .favorite-star {
  color: #c59b25;
}

.favorite-star:hover {
  color: #a07e1e;
}

.user-state-block {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.user-state-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.user-state-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.user-state-field span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.user-state-select {
  min-height: 34px;
}

.user-state-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-state-notes label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.user-state-textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  padding: 8px;
  resize: vertical;
  width: 100%;
}

.user-state-textarea.is-dirty {
  border-color: var(--amber);
}

.favorite-row {
  background: var(--warning-bg);
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 980px;
}

.profile-form textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}

.profile-form .field-hint {
  color: var(--muted);
  font-size: 12px;
}

.profile-form .form-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.profile-form .form-message {
  color: var(--muted);
  font-size: 14px;
}

/* Account page */
.account header,
header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 20px;
}

header nav a {
  color: var(--accent);
  font-size: 14px;
  margin-left: 12px;
  text-decoration: none;
}

header nav a.active,
header nav a:hover {
  text-decoration: underline;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 16px;
}

.pref-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.error {
  color: var(--red);
  font-size: 14px;
}

.form-row {
  margin-bottom: 10px;
}

.admin-nav {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
  padding: 10px;
}

.admin-nav summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}

.admin-nav .nav-list {
  margin-top: 8px;
}

.profile-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 14px;
}

.profile-fieldset legend {
  font-size: 14px;
  font-weight: 600;
  padding: 0 6px;
}

.admin-only-debug {
  background: var(--surface-strong);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 10px;
}

.admin-only-debug summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .workspace {
    padding: 14px;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
  }
  .profile-fieldset {
    padding: 10px;
  }
}

/* Admin page styles (moved from inline <style> to satisfy CSP) */
.admin-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.admin-card { background: var(--surface); border: 1px solid var(--border); border-radius: 0.5rem; padding: 1rem; }
.admin-card h3 { margin-top: 0; }
#admin-section table { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: fixed; }
#admin-section th, #admin-section td { text-align: left; padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--border); word-break: break-all; overflow-wrap: anywhere; }
#admin-section input, #admin-section select, #admin-section button { font: inherit; padding: 0.35rem 0.6rem; }
#admin-section .row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
#invite-result { white-space: pre-wrap; word-break: break-all; }

/* Prevent page-level horizontal scroll in visual QA; admin content scrolls its own container. */
html, body { overflow-x: hidden; }
#admin-section { overflow-x: auto; }

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

.error-state {
  color: var(--red);
  background: rgba(181, 71, 71, 0.06);
  border-radius: var(--radius);
}

.warning-state {
  color: var(--amber);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.warning-state p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.form-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.dynamic-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.dynamic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.dynamic-row input,
.dynamic-row select {
  flex: 1 1 160px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
  background: var(--input-bg);
}

.dynamic-row .field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 160px;
  min-width: 140px;
}

.field-group input,
.field-group select {
  width: 100%;
}

.dynamic-row .field-group-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.dynamic-row .checkbox-group {
  flex: 1 1 100%;
  margin-top: 4px;
}

.dynamic-row .switch {
  font-size: 12px;
}

.tag-editor {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.tag-editor input {
  flex: 1 1 auto;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
}

.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--secondary-bg);
  color: var(--secondary-text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.chip-remove:hover {
  background: var(--secondary-hover);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 0;
}

.checkbox-group .switch {
  color: var(--text);
  font-weight: 600;
}

.job-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  max-width: 420px;
}

.company-cell {
  min-width: 120px;
  max-width: 200px;
}

.job-company {
  font-weight: 650;
  word-break: break-word;
}

.company-priority-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--warning-bg);
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.job-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

#admin-section .table-wrap {
  margin-bottom: 0.5rem;
}

#admin-section .form-message {
  min-height: 1.4em;
  margin-bottom: 0.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.account-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.account-panel .card {
  padding: 16px;
  margin-bottom: 16px;
}

.account-panel .card + .card {
  margin-top: 16px;
}

.account-panel .metric {
  min-height: auto;
  padding: 12px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.account-panel .metric span {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
}

.account-panel .metric strong {
  font-size: 15px;
  font-weight: 650;
  margin-top: 4px;
  color: var(--text);
}

.account-panel .form-actions,
#contaActions {
  margin: 16px 0;
  padding: 0 16px;
}

.account-panel .profile-form,
.account-panel .danger {
  margin-top: 8px;
}

.cv-base-textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  margin-bottom: 16px;
}

.cv-base-editor-container {
  margin-top: 16px;
}

.cv-save-actions {
  margin-top: 8px;
}

.cv-import-area {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 16px 0;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.cv-import-area .field-control {
  flex: 1 1 280px;
  margin: 0;
}

.cv-import-preview {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.cv-import-preview h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.cv-import-preview textarea {
  min-height: 160px;
  margin: 12px 0;
}

.cv-base-summary.card,
.cvs-panel .card {
  margin-bottom: 20px;
  padding: 16px;
}

.cv-base-summary h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

@media (max-width: 640px) {
  .jobs-panel table,
  .all-jobs-panel table,
  .jobs-panel thead,
  .all-jobs-panel thead,
  .jobs-panel tbody,
  .all-jobs-panel tbody,
  .jobs-panel tr,
  .all-jobs-panel tr,
  .jobs-panel th,
  .all-jobs-panel th,
  .jobs-panel td,
  .all-jobs-panel td {
    display: block;
  }

  .jobs-panel thead,
  .all-jobs-panel thead {
    display: none;
  }

  .jobs-panel tr,
  .all-jobs-panel tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .jobs-panel td,
  .all-jobs-panel td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px;
    border: 0;
    padding: 6px 0;
    align-items: start;
  }

  .jobs-panel td::before,
  .all-jobs-panel td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .jobs-panel .table-actions,
  .all-jobs-panel .table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .jobs-panel .detail-row td,
  .all-jobs-panel .detail-row td {
    display: block;
  }

  .jobs-panel .detail-row td::before,
  .all-jobs-panel .detail-row td::before {
    content: none;
  }

  .job-title {
    max-width: none;
  }

  .job-meta {
    max-width: none;
  }

  .link-button {
    width: fit-content;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  #admin-section .row {
    flex-direction: column;
    align-items: stretch;
  }

  #admin-section table {
    min-width: 520px;
  }
}
