:root {
  --ink: #1c252a;
  --muted: #65757d;
  --line: #d8e1e4;
  --soft: #f3f7f7;
  --panel: #ffffff;
  --brand: #0c4f6b;
  --brand-dark: #17252b;
  --red: #9b2f2d;
  --green: #28724f;
  --amber: #95650d;
  --blue-soft: #e8f2f6;
  --green-soft: #e8f5ef;
  --amber-soft: #fbf0d8;
  --red-soft: #f8e7e5;
  --shadow: 0 12px 28px rgba(28, 37, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: #eef2f2;
  color: var(--ink);
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.boot,
.login-screen {
  align-items: center;
  display: flex;
  gap: 18px;
  min-height: 100vh;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-width: 440px;
  padding: 24px;
  width: 100%;
}

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

.brand-mark {
  align-items: center;
  background: var(--brand);
  color: white;
  display: inline-flex;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  width: 78px;
}

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

.sidebar {
  background: var(--brand-dark);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}

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

.brand small,
.sidebar-footer {
  color: #b8c8cd;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav button {
  align-items: center;
  background: transparent;
  border-radius: 6px;
  color: #d8e5e8;
  display: grid;
  gap: 10px;
  grid-template-columns: 22px 1fr auto;
  min-height: 42px;
  padding: 9px 11px;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  line-height: 1.45;
  margin-top: auto;
  padding-top: 16px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 22px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.login-card h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
}

.topbar p,
.login-card p {
  color: var(--muted);
  margin: 3px 0 0;
}

.content {
  padding: 18px 22px 34px;
}

.panel,
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section {
  margin-bottom: 16px;
}

.section-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: 54px;
  padding: 12px 14px;
}

.section-header h2,
.section-header h3 {
  font-size: 15px;
  margin: 0;
}

.section-body {
  padding: 14px;
}

.grid-kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.kpi {
  padding: 14px;
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
}

.kpi .value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 5px;
}

.kpi .hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.layout-two {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.4fr) minmax(330px, 0.8fr);
}

.layout-three {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.toolbar {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

input,
select,
textarea {
  background: white;
  border: 1px solid #c8d2d6;
  border-radius: 6px;
  color: var(--ink);
  min-height: 36px;
  padding: 7px 9px;
}

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

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

.search {
  min-width: 280px;
}

.actions,
.row-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  align-items: center;
  background: var(--brand);
  border-radius: 6px;
  color: white;
  display: inline-flex;
  gap: 7px;
  justify-content: center;
  min-height: 36px;
  padding: 8px 11px;
}

.btn.secondary {
  background: #e8eef0;
  color: var(--ink);
}

.btn.danger {
  background: var(--red);
}

.icon-btn {
  align-items: center;
  background: #edf3f4;
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.relation-field {
  position: relative;
}

.lookup-control {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) 34px;
}

.lookup-control input {
  min-width: 0;
}

.lookup-status {
  color: var(--red);
  display: none;
  font-size: 12px;
}

.lookup-unresolved .lookup-control input {
  border-color: var(--red);
}

.lookup-unresolved .lookup-status {
  display: block;
}

.lookup-results {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  left: 0;
  max-height: 260px;
  overflow: auto;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 70;
}

.lookup-results:empty {
  display: none;
}

.lookup-option {
  background: white;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  gap: 4px;
  padding: 10px;
  text-align: left;
}

.lookup-option:hover {
  background: #f4f8f8;
}

.lookup-option span,
.lookup-empty {
  color: var(--muted);
  font-size: 12px;
}

.lookup-empty {
  padding: 10px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  padding: 10px 11px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafb;
  color: #4e5d64;
  font-size: 12px;
}

tr:hover td {
  background: #f8fbfb;
}

.linkish {
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  padding: 0;
  text-align: left;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.pill {
  background: #edf2f3;
  border-radius: 999px;
  color: #35464e;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 8px;
}

.pill.hot {
  background: var(--red-soft);
  color: var(--red);
}

.pill.warm {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.good {
  background: var(--green-soft);
  color: var(--green);
}

.pill.blue {
  background: var(--blue-soft);
  color: var(--brand);
}

.drawer {
  background: white;
  border-left: 1px solid var(--line);
  bottom: 0;
  box-shadow: -18px 0 30px rgba(28, 37, 42, 0.12);
  max-width: 620px;
  overflow: auto;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  width: min(620px, 100vw);
  z-index: 50;
}

.drawer-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.drawer-head h2 {
  font-size: 20px;
  margin: 0 0 3px;
}

.overlay {
  background: rgba(23, 37, 43, 0.28);
  bottom: 0;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 40;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.empty,
.notice {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.contact-card {
  background: #f8fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 10px;
}

.contact-card strong {
  font-size: 13px;
}

.notice {
  background: #fff8e9;
  border: 1px solid #ecd69d;
  border-radius: 8px;
  color: #684a0b;
  text-align: left;
}

.rep-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rep-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.rep-card.good {
  border-left-color: var(--green);
}

.rep-card.risk {
  border-left-color: var(--red);
}

.rep-card-head,
.rep-card-foot,
.pipeline-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.rep-mini-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rep-mini-grid span,
.rep-card-foot,
.metric-row {
  color: var(--muted);
  font-size: 12px;
}

.meter {
  background: #e8eef0;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  width: 100%;
}

.meter div {
  background: var(--brand);
  height: 100%;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px;
}

.hygiene-grid,
.activity-mix {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.hygiene-grid div,
.activity-mix div {
  background: #f8fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px;
}

.hygiene-grid strong,
.activity-mix strong {
  font-size: 22px;
}

.hygiene-grid span,
.activity-mix span {
  color: var(--muted);
  font-size: 12px;
}

.pipeline-list,
.metric-row {
  display: grid;
  gap: 12px;
}

.pipeline-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(140px, 1fr) auto;
}

.pipeline-row > div:first-child {
  display: grid;
  gap: 2px;
}

.pipeline-bar {
  background: #e8eef0;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.pipeline-bar span {
  background: var(--green);
  display: block;
  height: 100%;
}

.metric-row {
  grid-template-columns: 110px minmax(0, 1fr);
}

.toast {
  background: var(--brand-dark);
  border-radius: 8px;
  bottom: 20px;
  color: white;
  left: 50%;
  padding: 11px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 80;
}

@media (max-width: 1180px) {
  .grid-kpis,
  .rep-grid,
  .layout-three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .shell,
  .layout-two,
  .layout-three,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

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

@media (max-width: 620px) {
  .content,
  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .nav,
  .grid-kpis,
  .rep-grid,
  .hygiene-grid,
  .activity-mix {
    grid-template-columns: 1fr;
  }

  .toolbar > *,
  .search,
  .actions > * {
    width: 100%;
  }
}
