:root {
  --ink: #151515;
  --muted: #68645f;
  --line: #ddd8d1;
  --surface: #fffdf9;
  --panel: #f4f0ea;
  --navy: #1b3a4b;
  --purple: #534ab7;
  --green: #3f7f2a;
  --amber: #b96c12;
  --red: #b53634;
  --mt: #d85a30;
  --eg: #378add;
  --bw: #1d9e75;
  --shadow: 0 12px 30px rgba(35, 31, 26, 0.08);
}

* { box-sizing: border-box; }
html { background: #f8f6f2; }
body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fffaf2;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--navy);
  font-weight: 800;
}
.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
}
.brand-title { font-weight: 750; }
.brand-subtitle { color: var(--muted); font-size: 12px; }
.nav {
  display: grid;
  gap: 4px;
}
.nav button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 8px 10px;
  background: transparent;
  color: #3b3936;
  text-align: left;
}
.nav button.active {
  background: #ebe7ff;
  color: #24205f;
  font-weight: 700;
}
.nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.sidebar-footer {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 16px;
  display: grid;
  gap: 8px;
}
.user-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fff;
}
.mode-pill {
  border: 1px solid #d7d1ca;
  border-radius: 7px;
  padding: 7px 8px;
  color: var(--muted);
  font-size: 12px;
  background: #fff;
}

.main {
  min-width: 0;
  padding: 22px 28px 36px;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-title { margin: 0; font-size: 24px; line-height: 1.1; }
.page-kicker { margin-top: 5px; color: var(--muted); font-size: 13px; }
.flash {
  border: 1px solid #cfe3bd;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #f4fbef;
  color: #285d1b;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  padding: 10px 12px;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filters .field {
  min-width: 145px;
}
.field {
  display: grid;
  gap: 5px;
}
.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(83, 74, 183, 0.12);
}

.grid { display: grid; gap: 12px; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-title {
  margin: 0 0 12px;
  font-size: 15px;
}
.metric {
  min-width: 0;
  background: var(--panel);
  border: 1px solid #e8e0d7;
  border-radius: 8px;
  padding: 13px 14px;
}
.interactive {
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.interactive:hover {
  border-color: #bcb3aa;
  background: #fffaf2;
  transform: translateY(-1px);
}
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 2px; font-size: 27px; font-weight: 760; letter-spacing: 0; }
.metric-sub { margin-top: 2px; color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fbf8f3;
}
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #faf6ee; }
tr.selected-row { background: #f0edff; }
td input[type="checkbox"] { width: auto; }
.detail-row td { background: #fff; }
.detail-panel {
  display: grid;
  gap: 12px;
}
.active-issue-card {
  background: #fff;
  border: 1px solid #cfc7bd;
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(35, 31, 26, 0.12);
  padding: 14px;
}
.contact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.contact-card {
  min-width: 0;
  border: 1px solid #e3dcd3;
  border-radius: 8px;
  background: #fbf8f3;
  padding: 10px 12px;
}
.contact-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.contact-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}
.issue-comment-card {
  border: 1px solid #e3dcd3;
  border-left: 4px solid var(--purple);
  border-radius: 8px;
  background: #fffaf2;
  padding: 12px 14px;
}
.issue-comment-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}
.issue-comment-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.open, .badge.high { background: #fae5e3; color: var(--red); }
.badge.in_progress, .badge.medium { background: #f8ecd9; color: var(--amber); }
.badge.resolved, .badge.low { background: #e6f1df; color: var(--green); }
.badge.closed { background: #e7e3dc; color: #4f4b45; }
.badge.critical { background: #5a1414; color: #fff; }
.badge.movietowne, .badge.mt { background: #f4e7df; color: #9a3718; }
.badge.east_gates, .badge.eg { background: #e4eef8; color: #165f9f; }
.badge.brentwood, .badge.bw { background: #e2f2ea; color: #0f694e; }
.badge.positive { background: #e6f1df; color: var(--green); }
.badge.negative { background: #fae5e3; color: var(--red); }
.badge.mixed { background: #f8ecd9; color: var(--amber); }
.badge.compensation { background: #f8ecd9; color: var(--amber); }
.badge.corrective_action { background: #e4eef8; color: #165f9f; }
.badge.apology, .badge.customer_followup, .badge.internal_followup { background: #ebe7ff; color: #24205f; }
.badge.no_action { background: #e7e3dc; color: #4f4b45; }
.mini-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.action-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  font-size: 13px;
}
.action-card input { width: auto; }

.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
  margin-top: 12px;
  padding: 10px 12px;
}
.btn {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 36px;
  padding: 7px 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 650;
}
.btn.primary {
  border-color: var(--purple);
  background: var(--purple);
  color: #fff;
}
.btn.danger {
  border-color: #e7bbb8;
  background: #fff6f5;
  color: var(--red);
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.notice {
  border: 1px solid #dfd6cb;
  border-left: 4px solid var(--purple);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffaf2;
  color: #49443f;
  font-size: 13px;
}
.archive-notice {
  border-left-color: var(--muted);
  background: #f3efe8;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(21, 21, 21, 0.36);
  padding: 22px;
}
.issue-modal {
  width: min(1100px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  border: 1px solid #cfc7bd;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(21, 21, 21, 0.28);
  padding: 16px;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-header h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.dropzone {
  display: grid;
  place-items: center;
  min-height: 148px;
  border: 2px dashed #c9c0b6;
  border-radius: 8px;
  background: #fffaf3;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}
.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.progress-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e9e2d9;
}
.progress-bar span {
  display: block;
  height: 100%;
  background: var(--purple);
}
.chart-list {
  display: grid;
  gap: 10px;
}
.svg-chart {
  min-height: 260px;
}
.svg-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-grid {
  stroke: #e4ded6;
  stroke-width: 1;
}
.chart-axis {
  fill: #66615b;
  font-size: 12px;
}
.chart-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: -4px;
  color: #56514c;
  font-size: 12px;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-legend i {
  width: 11px;
  height: 11px;
  display: inline-block;
  border: 2px solid;
  background: #fff;
}
.highlight-columns {
  column-count: 2;
  column-gap: 12px;
}
.highlight-card {
  break-inside: avoid;
  margin-bottom: 10px;
}
.bar-row {
  display: grid;
  grid-template-columns: 95px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.bar-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e9e2d9;
}
.bar-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
}
.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sidebar-footer { position: static; margin-top: 12px; }
  .main { padding: 18px 14px 28px; }
  .grid.metrics, .grid.two, .grid.three, .form-grid, .contact-grid { grid-template-columns: 1fr; }
  .highlight-columns { column-count: 1; }
  .modal-backdrop { padding: 8px; place-items: stretch; }
  .issue-modal { max-height: calc(100vh - 16px); }
  .bulk-bar { align-items: stretch; flex-direction: column; }
  .action-grid { grid-template-columns: 1fr; }
  .topbar, .toolbar { align-items: stretch; flex-direction: column; }
}
