:root {
  --ink: #1d2430;
  --muted: #697386;
  --line: #dbe3ee;
  --panel: #ffffff;
  --page: #f4f7fb;
  --green: #6fb643;
  --blue: #407fb7;
  --yellow: #ecc735;
  --red: #e14617;
  --focus: 0 0 0 4px rgba(64, 127, 183, .18);
}

* { box-sizing: border-box; }

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

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

.app-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

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

.brand img {
  width: 104px;
  height: auto;
}

.brand p,
.hero p {
  margin: 0 0 4px;
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .08em;
}

.brand h1,
.hero h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.top-nav {
  display: flex;
  gap: 8px;
}

.top-nav button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.top-nav button.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  max-width: 1480px;
  margin: 0 auto;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 100px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.side-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  margin: 4px 0 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 22px;
}

.segmented button,
.form-switch button,
.submit-row button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}

.segmented button {
  min-height: 42px;
  font-weight: 700;
}

.segmented button.is-active,
.form-switch button.is-active {
  border-color: var(--blue);
  color: var(--blue);
  background: #eef6ff;
}

.form-switch {
  display: grid;
  gap: 8px;
}

.form-switch button {
  text-align: left;
  padding: 13px;
}

.form-switch span {
  display: block;
  font-weight: 800;
  margin-bottom: 4px;
}

.form-switch small {
  color: var(--muted);
  line-height: 1.35;
}

.summary {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.summary h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.summary dl {
  margin: 0;
  display: grid;
  gap: 10px;
}

.summary dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.summary dt {
  color: var(--muted);
  font-size: 13px;
}

.summary dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.workspace {
  min-width: 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 20px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}

.hero h2 {
  font-size: 32px;
}

.hero span {
  color: var(--muted);
  display: block;
  margin-top: 8px;
}

.hero img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
}

.form-shell {
  display: grid;
  gap: 18px;
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.section-header h3 {
  margin: 0;
  font-size: 17px;
}

.section-header span {
  color: var(--muted);
  font-size: 13px;
}

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

.field {
  min-width: 0;
}

.field.wide { grid-column: span 2; }
.field.full { grid-column: 1 / -1; }
.is-hidden,
.field.is-hidden { display: none !important; }

label,
.group-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 7px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--blue);
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  position: relative;
}

.choice input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.choice span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  font-size: 13px;
}

.choice input:checked + span {
  border-color: var(--green);
  color: #315f1d;
  background: #eef9e9;
}

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

.upload-box {
  display: grid;
  place-items: center;
  min-height: 112px;
  border: 1px dashed #9fb0c4;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.submit-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.submit-row button {
  min-height: 44px;
  padding: 0 18px;
  font-weight: 800;
}

.submit-row .primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

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

  .sidebar {
    position: static;
  }

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

@media (max-width: 680px) {
  .app-header,
  .hero {
    grid-template-columns: 1fr;
  }

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

  .layout {
    padding: 14px;
  }

  .hero {
    display: block;
  }

  .hero img {
    margin-top: 16px;
  }

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

  .field.wide,
  .field.full {
    grid-column: auto;
  }
}

.admin-layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  min-height: calc(100vh - 124px);
  align-items: center;
}

.login-copy {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
}

.login-copy p,
.admin-title p,
.admin-sidebar p {
  margin: 0 0 6px;
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .08em;
}

.login-copy h2,
.admin-title h2,
.admin-sidebar h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-copy h2 {
  font-size: 42px;
  max-width: 660px;
}

.login-copy span {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.login-card {
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-card button {
  margin-top: 4px;
  min-height: 46px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

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

.dashboard {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
}

.admin-sidebar {
  position: sticky;
  top: 100px;
  align-self: start;
  display: grid;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.admin-sidebar div {
  padding: 4px 4px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.admin-sidebar button {
  text-align: left;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 0 12px;
  font-weight: 800;
  cursor: pointer;
}

.admin-sidebar button.is-active {
  background: #eef6ff;
  border-color: var(--blue);
  color: var(--blue);
}

#logoutButton {
  color: var(--red);
  margin-top: 8px;
}

.admin-content {
  min-width: 0;
}

.admin-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}

.admin-filters {
  display: flex;
  gap: 10px;
}

.admin-filters select {
  min-width: 180px;
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 18px;
}

.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.admin-card-header h3 {
  margin: 0;
  font-size: 16px;
}

.admin-card-header span {
  color: var(--muted);
  font-size: 13px;
}

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

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

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

th {
  color: var(--muted);
  background: #fbfdff;
  font-size: 12px;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f7;
}

.pill.green { color: #315f1d; background: #eef9e9; }
.pill.yellow { color: #765d00; background: #fff8d8; }
.pill.blue { color: #245b8a; background: #eaf5ff; }
.pill.red { color: #9d2c0d; background: #ffece6; }

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

.table-action {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.pipeline {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.pipeline-step {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 9px;
  border-radius: 999px;
  background: #e9eef5;
  overflow: hidden;
  margin-top: 6px;
}

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

.capacity-list,
.message-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.capacity-item,
.message-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.capacity-item header,
.message-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.message-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

@media (max-width: 1080px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-grid,
  .dashboard,
  .login-panel {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
  }
}

@media (max-width: 680px) {
  .admin-title,
  .admin-filters {
    display: grid;
  }

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