:root {
  --bg: #f7f5f1;
  --panel: #fff;
  --ink: #25231f;
  --muted: #77736c;
  --line: #e8e3da;
  --accent: #d86c3c;
  --accent-soft: #fff0e7;
  --gold: #d7aa67;
  --good: #2f8a64;
  --good-soft: #e7f5ee;
  --warn: #a16a18;
  --warn-soft: #fff5d9;
  --danger: #b44c48;
  --danger-soft: #fcecea;
  --shadow: 0 12px 38px rgba(61, 48, 31, .07);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  background:
    radial-gradient(circle at 85% -5%, rgba(216, 108, 60, .11), transparent 27rem),
    var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  padding: 28px 18px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; margin: 0 8px 34px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 13px; color: #fff; font: 700 19px Georgia, serif;
  background: linear-gradient(145deg, var(--gold), var(--accent));
  box-shadow: 0 8px 20px rgba(216, 108, 60, .2);
}
.brand b, .brand small, .sidebar-foot b, .sidebar-foot small { display: block; }
.brand b { letter-spacing: .01em; }
.brand small, .sidebar-foot small { color: var(--muted); font-size: 11px; }
.sidebar nav { display: grid; gap: 7px; }
.sidebar nav a {
  padding: 12px 13px; border-radius: 12px; color: #65615a;
  display: flex; align-items: center; gap: 11px; font-weight: 600;
}
.sidebar nav a:hover { background: #f6f1eb; }
.sidebar nav a.active { color: var(--accent); background: var(--accent-soft); }
.nav-icon { width: 21px; text-align: center; font-size: 19px; }
.sidebar-foot {
  margin-top: auto; padding: 13px; border: 1px solid var(--line);
  border-radius: 14px; display: flex; gap: 9px; align-items: center;
}
.logout-form { margin: 9px 5px 0; }
.logout-form button {
  width: 100%; padding: 8px; border: 0; color: var(--muted);
  background: transparent; cursor: pointer; font-size: 12px;
}
.logout-form button:hover { color: var(--accent); }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 4px var(--good-soft);
}

.main { margin-left: 232px; padding: 42px clamp(24px, 4vw, 58px) 60px; max-width: 1700px; }
.topbar, .section-heading {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
}
.topbar { margin-bottom: 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font: 600 clamp(27px, 3vw, 38px)/1.1 Georgia, serif; }
h2 { margin-bottom: 0; font: 600 25px/1.2 Georgia, serif; }
h3 { margin-bottom: 5px; font-size: 17px; }
.eyebrow {
  margin-bottom: 7px; color: var(--accent); font-size: 11px;
  font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
}
.button {
  border: 0; border-radius: 11px; padding: 11px 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; transition: transform .15s, background .15s;
}
.button:active { transform: translateY(1px); }
.button.primary { color: #fff; background: var(--accent); box-shadow: 0 8px 19px rgba(216,108,60,.18); }
.button.primary:hover { background: #c95f33; }
.button.ghost { color: #625d55; background: #f3f0eb; }
.button.ghost:hover { background: #ebe6de; }

.metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.metrics article {
  padding: 19px 21px; border: 1px solid var(--line);
  border-radius: 16px; background: rgba(255, 255, 255, .88);
  box-shadow: 0 5px 20px rgba(61, 48, 31, .035);
}
.metrics article.accent { border-color: #f1cab5; background: linear-gradient(140deg, #fff, var(--accent-soft)); }
.metrics span { display: block; color: var(--muted); font-size: 12px; }
.metrics strong { display: block; margin-top: 3px; font: 600 29px/1.2 Georgia, serif; }

.panel {
  border: 1px solid var(--line); border-radius: 18px;
  background: rgba(255,255,255,.92); box-shadow: var(--shadow);
}
.filters {
  padding: 16px; display: grid;
  grid-template-columns: minmax(230px, 1.7fr) repeat(4, minmax(140px, 1fr)) auto;
  gap: 9px; border-bottom: 1px solid var(--line);
}
select, input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); background: #fff; outline: 0;
}
select, input { min-height: 42px; padding: 0 12px; }
textarea { padding: 12px; resize: vertical; }
select:focus, input:focus, textarea:focus {
  border-color: #e2a486; box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-field { position: relative; }
.search-field span { position: absolute; left: 13px; top: 9px; color: var(--muted); font-size: 20px; }
.search-field input { padding-left: 40px; }
.table-toolbar {
  min-height: 53px; padding: 8px 17px; display: flex;
  justify-content: space-between; align-items: center; color: var(--muted);
}
.table-toolbar label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.table-toolbar select { min-height: 35px; width: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th {
  padding: 10px 15px; border-block: 1px solid var(--line);
  background: #faf9f7; color: var(--muted); font-size: 11px;
  letter-spacing: .04em; text-align: left; text-transform: uppercase;
}
.sort-button {
  min-height: 32px; margin: -6px -9px; padding: 6px 9px; border: 0;
  border-radius: 8px; color: inherit; background: transparent; cursor: pointer;
  font: inherit; font-weight: 700; letter-spacing: inherit; text-transform: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.sort-button:hover { color: var(--ink); background: #f0ece6; }
.sort-button:focus-visible {
  outline: 2px solid #e2a486; outline-offset: 1px;
}
.sort-button span {
  color: #aaa49b; font-size: 14px; line-height: 1;
}
.sort-button.active { color: var(--accent); background: var(--accent-soft); }
.sort-button.active span { color: var(--accent); }
.sort-hint { font-size: 12px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
td { padding: 15px; border-bottom: 1px solid #f0ece6; vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .13s; }
tbody tr:hover { background: #fffaf6; }
.company-cell { min-width: 240px; max-width: 340px; white-space: normal; }
.company-cell b { display: block; }
.company-cell small { display: block; margin-top: 3px; color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
}
.badge.good { color: var(--good); background: var(--good-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge.neutral { color: #666159; background: #f1efeb; }
.rating.low { color: var(--danger); font-weight: 800; }
.row-open { border: 0; background: none; color: var(--accent); font-size: 20px; cursor: pointer; }
.empty { padding: 55px 20px; text-align: center; color: var(--muted); }
.empty b, .empty span { display: block; }
.empty b { color: var(--ink); font-size: 17px; margin-bottom: 4px; }

dialog {
  width: min(680px, calc(100% - 28px)); max-height: calc(100vh - 28px);
  margin: auto 0 auto auto; border: 0; border-left: 1px solid var(--line);
  padding: 0; border-radius: 20px 0 0 20px; color: var(--ink);
  box-shadow: -20px 0 60px rgba(38, 29, 20, .16);
}
dialog::backdrop { background: rgba(41, 34, 28, .32); backdrop-filter: blur(2px); }
.dialog-close {
  position: absolute; right: 19px; top: 15px; width: 37px; height: 37px;
  border: 0; border-radius: 50%; background: #f2efea; cursor: pointer; font-size: 22px;
}
.detail { padding: 34px; }
.detail-head { padding-right: 45px; margin-bottom: 23px; }
.detail-head .category { color: var(--accent); font-weight: 700; font-size: 12px; }
.detail-head h2 { margin: 4px 0 8px; }
.detail-head p { color: var(--muted); }
.lead-banner {
  padding: 14px 16px; margin-bottom: 20px; border-radius: 12px;
  color: var(--good); background: var(--good-soft); font-weight: 700;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 24px; }
.detail-grid article { padding: 13px; border: 1px solid var(--line); border-radius: 12px; }
.detail-grid span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.detail-links { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 24px; }
.detail-links a { color: var(--accent); font-weight: 700; }
.detail form { display: grid; gap: 14px; }
.detail label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }

.job-form { padding: 23px; margin-bottom: 22px; scroll-margin-top: 20px; }
.job-form form { display: grid; gap: 14px; margin-top: 22px; }
.job-form form label { display: grid; gap: 7px; font-weight: 700; }
.job-form form .button { justify-self: start; }
.form-note { margin: -5px 0 0; color: var(--muted); font-size: 12px; }
.job-summary {
  margin-top: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.section-heading { margin: 25px 0 14px; }
.jobs-grid { display: grid; gap: 12px; }
.job-card {
  padding: 20px; border: 1px solid var(--line); border-radius: 17px;
  background: rgba(255,255,255,.9); box-shadow: 0 5px 20px rgba(61,48,31,.04);
}
.job-card-head { display: flex; justify-content: space-between; gap: 20px; }
.job-card-head h3 { margin-bottom: 3px; }
.job-meta { color: var(--muted); font-size: 12px; }
.progress-line {
  height: 8px; margin: 17px 0 9px; border-radius: 99px;
  overflow: hidden; background: #eeeae3;
}
.progress-line i {
  height: 100%; display: block; border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--accent));
}
.job-progress-label { display: flex; justify-content: space-between; font-size: 12px; }
.job-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px; margin-top: 15px;
}
.job-stats span { padding: 9px 11px; border-radius: 9px; background: #f7f5f1; color: var(--muted); font-size: 11px; }
.job-stats b { display: block; color: var(--ink); font-size: 15px; }
.job-actions {
  display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px;
  padding-top: 13px; border-top: 1px solid var(--line);
}
.job-action {
  min-height: 34px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 9px; color: #615d56; background: #fff; cursor: pointer;
  font-size: 12px; font-weight: 700;
}
.job-action:hover { border-color: #e2a486; color: var(--accent); }
.job-action:disabled { opacity: .45; cursor: wait; }
.job-action.danger-text { margin-left: auto; color: var(--danger); }
.job-log { padding: 34px; min-height: 260px; }
.job-log h2 { padding-right: 45px; }
.job-log-list { display: grid; margin-top: 24px; }
.job-log-list article {
  position: relative; display: grid; grid-template-columns: 18px 1fr;
  gap: 10px; min-height: 58px;
}
.job-log-list article::before {
  content: ""; position: absolute; left: 5px; top: 14px; bottom: -2px;
  width: 1px; background: var(--line);
}
.job-log-list article:last-child::before { display: none; }
.job-log-list i {
  position: relative; z-index: 1; width: 11px; height: 11px; margin-top: 3px;
  border: 3px solid var(--accent-soft); border-radius: 50%; background: var(--accent);
  box-sizing: content-box;
}
.job-log-list b, .job-log-list span { display: block; }
.job-log-list span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.job-log-list em {
  display: block; margin-top: 5px; color: var(--accent); font-size: 11px;
  font-style: normal; font-weight: 700;
}
.job-log-details {
  margin: 9px 0 17px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 10px; background: #fffaf7;
}
.job-log-details summary {
  color: #6d625b; cursor: pointer; font-size: 12px; font-weight: 800;
}
.job-log-details dl {
  display: grid; gap: 6px; margin: 10px 0 0;
}
.job-log-details dl div {
  display: grid; grid-template-columns: minmax(120px, .65fr) 1.35fr;
  gap: 10px; padding-top: 6px; border-top: 1px dashed var(--line);
}
.job-log-details dt {
  color: var(--muted); font-size: 11px; font-weight: 700;
}
.job-log-details dd {
  min-width: 0; margin: 0; overflow-wrap: anywhere; color: #332f2b;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px; line-height: 1.45;
}
.job-log-copy {
  margin-top: 10px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 8px; color: #615d56; background: #fff; cursor: pointer;
  font-size: 11px; font-weight: 700;
}
.job-log-copy:hover { border-color: #e2a486; color: var(--accent); }
.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.login-card {
  width: min(430px, 100%); padding: 36px; border: 1px solid var(--line);
  border-radius: 22px; background: rgba(255,255,255,.94); box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 34px; }
.login-brand b, .login-brand small { display: block; }
.login-brand small, .login-note { color: var(--muted); }
.login-note { margin: 10px 0 22px; }
.login-card form { display: grid; gap: 15px; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.login-error {
  margin: -7px 0 17px; padding: 10px 12px; border-radius: 10px;
  color: var(--danger); background: var(--danger-soft); font-size: 12px;
}
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 30;
  max-width: 390px; padding: 12px 16px; border-radius: 11px;
  color: #fff; background: #302e2a; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: .2s;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

@media (max-width: 1160px) {
  .filters { grid-template-columns: 1.5fr repeat(2, 1fr); }
  .filters .button { min-height: 42px; }
}
@media (max-width: 780px) {
  .sidebar {
    inset: auto 0 0; width: auto; height: 68px; padding: 8px 14px;
    border: 0; border-top: 1px solid var(--line); flex-direction: row;
  }
  .brand, .sidebar-foot { display: none; }
  .logout-form { display: none; }
  .sidebar nav { width: 100%; grid-template-columns: 1fr 1fr; }
  .sidebar nav a { justify-content: center; padding: 9px; }
  .main { margin-left: 0; padding: 25px 15px 92px; }
  .topbar { align-items: flex-end; }
  .topbar .button { padding: 10px 12px; }
  .metrics, .job-summary { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filters .button { grid-column: 1 / -1; }
  .table-toolbar { align-items: flex-start; gap: 9px; flex-direction: column; }
  .table-toolbar label { width: 100%; }
  .table-toolbar select { flex: 1; }
  dialog { max-height: calc(100vh - 80px); margin: auto 0 68px; border-radius: 18px 18px 0 0; }
  .detail { padding: 27px 19px; }
  .detail-grid, .job-stats { grid-template-columns: 1fr 1fr; }
  .job-log { padding: 27px 19px; }
  .job-log-details dl div { grid-template-columns: 1fr; gap: 3px; }
}
@media (max-width: 430px) {
  h1 { font-size: 27px; }
  .topbar { align-items: flex-start; }
  .topbar .button { font-size: 12px; }
  .metrics article { padding: 15px; }
  .metrics strong { font-size: 25px; }
  .filters { grid-template-columns: 1fr; }
  .filters > * { grid-column: 1 !important; }
  .job-card-head { flex-direction: column; gap: 8px; }
}
