:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #687385;
  --line: #ddd7ce;
  --primary: #236a68;
  --primary-dark: #174d4c;
  --accent: #c86b4f;
  --ok: #176b43;
  --shadow: 0 18px 45px rgba(28, 34, 43, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #17202a;
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 800;
  font-size: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
}

nav {
  display: grid;
  gap: 8px;
}

.nav-label {
  margin-top: 10px;
  padding: 0 12px;
  color: #93a5a8;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

nav a {
  color: #dfe8e8;
  padding: 11px 12px;
  border-radius: 8px;
}

nav a:hover {
  background: rgba(255,255,255,.08);
}

.user-card {
  margin-top: auto;
  display: grid;
  gap: 5px;
  color: #dfe8e8;
  font-size: 13px;
}

.user-card strong {
  color: white;
}

.app-shell {
  margin-left: 250px;
  padding: 34px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.login-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 22px;
  padding: 30px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 34px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.muted,
.page-header p,
td span,
.timeline span {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.department-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.integration-panel {
  margin-bottom: 22px;
}

.integration-panel p {
  max-width: 760px;
  color: var(--muted);
}

.stats-grid article {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-grid span {
  display: block;
  color: var(--muted);
}

.stats-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 30px;
}

.table-panel,
.panel {
  padding: 20px;
}

.section-title,
.filters,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .06em;
}

td,
th {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8faf9;
}

td span {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.status {
  display: inline-block;
  margin: 0;
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf4f3;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.primary:hover {
  background: var(--primary-dark);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

.stack {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.filters {
  margin-bottom: 18px;
}

.filters input {
  flex: 1;
}

.filters select {
  width: 180px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.pipeline div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
}

.pipeline span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eee7dd;
  color: var(--ink);
  font-weight: 800;
}

.pipeline .active {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.pipeline .active span {
  background: var(--primary);
  color: white;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.facts {
  display: grid;
  gap: 14px;
  margin: 0;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  text-align: right;
}

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.timeline article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.timeline p {
  margin: 8px 0 0;
}

.readonly-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.readonly-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.readonly-field strong {
  text-align: right;
  overflow-wrap: anywhere;
}

.flash-stack {
  position: fixed;
  z-index: 10;
  right: 22px;
  top: 18px;
  display: grid;
  gap: 10px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.flash.error {
  background: #a33b36;
}

.flash.success {
  background: var(--ok);
}

.empty-state {
  padding: 38px;
  text-align: center;
}

@media (max-width: 880px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .app-shell {
    margin-left: 0;
    padding: 20px;
  }

  .stats-grid,
  .pipeline,
  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .filters {
    display: grid;
  }

  .filters select {
    width: 100%;
  }
}
