@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;600&display=swap");

:root {
  --bg-a: #f2f6f8;
  --bg-b: #e8eef3;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --ink: #13212b;
  --muted: #5a6e7e;
  --line: #d7e0e7;
  --line-strong: #c7d2db;
  --accent: #0f6ea8;
  --accent-strong: #09527f;
  --accent-soft: #e8f2f9;
  --ok: #1c8a57;
  --ok-soft: #e6f6ee;
  --warn: #b56421;
  --warn-soft: #fdf2e8;
  --danger: #aa3a30;
  --danger-soft: #f9e9e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: linear-gradient(145deg, var(--bg-a), var(--bg-b));
  min-height: 100vh;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 18%, rgba(15, 110, 168, 0.1), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(28, 138, 87, 0.08), transparent 24%),
    radial-gradient(circle at 78% 82%, rgba(181, 100, 33, 0.08), transparent 24%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  backdrop-filter: blur(10px);
  background: rgba(248, 251, 253, 0.84);
  border-bottom: 1px solid rgba(19, 33, 43, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.64rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-logo-stack {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.brand-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.46rem;
  border-radius: 10px;
  border: 1px solid transparent;
}

.brand-logo-badge--powerhouse {
  background: #121212;
  border-color: rgba(255, 255, 255, 0.1);
}

.brand-logo-badge--convoy {
  background: #fff;
  border-color: rgba(15, 110, 168, 0.28);
}

.brand-logo {
  display: block;
  height: 18px;
  width: auto;
}

.brand-logo--convoy {
  height: 20px;
}

.brand-text {
  display: grid;
  line-height: 1.05;
}

.brand-app {
  font-size: 0.98rem;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  flex-wrap: wrap;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  border-radius: 9px;
  padding: 0.42rem 0.62rem;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1;
}

.top-links a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.18rem 0;
  border-bottom: 2px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
}

.top-links a:hover {
  color: var(--ink);
}

.top-links a.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.layout {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.4rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: 0 14px 34px rgba(15, 40, 60, 0.06);
  margin-bottom: 1rem;
}

h1,
h2,
h3 {
  margin-top: 0;
  margin-bottom: 0.48rem;
  line-height: 1.2;
}

h1 {
  font-size: 1.62rem;
}

h3 {
  font-size: 1rem;
}

.kicker {
  margin: 0 0 0.35rem;
  color: var(--accent-strong);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.lead {
  margin: 0.1rem 0 0.9rem;
  color: var(--ink);
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-inline,
.form-shell {
  display: grid;
  gap: 0.85rem;
}

.form-shell {
  margin-top: 0.55rem;
}

.quick-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0.9rem 0;
}

.flow-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.78rem;
  display: grid;
  gap: 0.55rem;
  align-content: start;
}

.flow-card p {
  margin: 0;
}

.kpi-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0.8rem 0 1rem;
}

.kpi-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}

.kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  margin: 0.28rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(200px, 1.5fr) auto;
  gap: 0.75rem;
  align-items: end;
  margin: 0.7rem 0 0.95rem;
}

.filter-bar-wide {
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.78rem;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.78rem;
}

.four-col {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.78rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.56rem 0.65rem;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 110, 168, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 110, 168, 0.14);
}

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

fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.86rem;
  margin: 0.9rem 0;
  background: rgba(255, 255, 255, 0.62);
}

legend {
  padding: 0 0.4rem;
  font-weight: 700;
  color: var(--ink);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.48rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

.check-item input {
  width: auto;
}

.submit-row {
  display: flex;
  justify-content: flex-start;
  margin-top: 0.2rem;
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.62rem 0.98rem;
  font-weight: 700;
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  color: #fff;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-logout {
  margin: 0;
}

.ok {
  border-left: 4px solid var(--ok);
  background: var(--ok-soft);
  padding: 0.56rem 0.7rem;
  border-radius: 8px;
}

.error {
  border-left: 4px solid var(--danger);
  background: var(--danger-soft);
  padding: 0.56rem 0.7rem;
  border-radius: 8px;
  margin-bottom: 0.65rem;
}

.codeblock {
  font-family: "IBM Plex Mono", monospace;
  background: rgba(19, 33, 43, 0.05);
  border: 1px dashed rgba(19, 33, 43, 0.18);
  border-radius: 10px;
  padding: 0.76rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.timeline {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.45rem;
}

.timeline li {
  line-height: 1.42;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
}

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

table.mobile-stack-table {
  min-width: 760px;
}

th,
td {
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(19, 33, 43, 0.09);
  padding: 0.68rem 0.62rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fafc;
}

tbody tr:nth-child(even) {
  background: rgba(15, 110, 168, 0.02);
}

tbody tr:hover {
  background: rgba(15, 110, 168, 0.06);
}

th {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.copy-wrap {
  display: flex;
  gap: 0.5rem;
}

.copy-wrap input {
  flex: 1 1 auto;
}

.action-stack {
  display: grid;
  gap: 0.45rem;
  min-width: 10rem;
}

.action-stack form {
  margin: 0;
}

.action-stack .mini-link,
.action-stack button {
  width: 100%;
  min-height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.action-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mini-link {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 9px;
  padding: 0.37rem 0.58rem;
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 600;
}

.mini-link:hover {
  border-color: var(--accent);
}

.mini-link.primary {
  background: var(--accent-soft);
  border-color: rgba(15, 110, 168, 0.33);
  color: var(--accent-strong);
}

.stats-grid {
  display: grid;
  gap: 0.58rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin: 0.9rem 0;
}

.stat-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.66rem 0.74rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.22rem;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.16rem 0.53rem;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pill--neutral {
  background: #eef3f7;
  border-color: #d7e0e8;
  color: #4f6271;
}

.pill--accent {
  background: var(--accent-soft);
  border-color: rgba(15, 110, 168, 0.25);
  color: var(--accent-strong);
}

.pill--ok {
  background: var(--ok-soft);
  border-color: rgba(28, 138, 87, 0.28);
  color: #116741;
}

.pill--warn {
  background: var(--warn-soft);
  border-color: rgba(181, 100, 33, 0.25);
  color: #8f4d17;
}

.pill--danger {
  background: var(--danger-soft);
  border-color: rgba(170, 58, 48, 0.24);
  color: #8a2d26;
}

.unit-workspace-grid {
  display: grid;
  gap: 0.72rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 0.85rem 0;
}

.workspace-tabs {
  display: flex;
  gap: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  padding: 0.26rem;
  margin: 0.8rem 0 1rem;
}

.workspace-tab {
  text-decoration: none;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0.46rem 0.76rem;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.14s ease, background-color 0.14s ease, border-color 0.14s ease;
}

.workspace-tab:hover {
  color: var(--ink);
  background: rgba(15, 110, 168, 0.08);
}

.workspace-tab.active {
  background: var(--surface-strong);
  border-color: rgba(15, 110, 168, 0.25);
  color: var(--accent-strong);
  box-shadow: 0 1px 0 rgba(15, 110, 168, 0.08);
}

.unit-board-card {
  align-content: start;
  justify-items: center;
  text-align: center;
}

.qr-preview {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.qr-block {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  text-align: center;
}

.qr-link {
  display: inline-flex;
  border-radius: 12px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.qr-link:hover {
  border-color: rgba(15, 110, 168, 0.35);
  box-shadow: 0 6px 14px rgba(15, 40, 60, 0.09);
  transform: translateY(-1px);
}

.login-panel {
  max-width: 460px;
  margin: 3.2rem auto 1rem;
}

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

  .filter-bar-wide {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 880px) {
  .two-col,
  .three-col,
  .four-col,
  .quick-grid,
  .action-grid,
  .kpi-grid,
  .filter-bar,
  .filter-bar-wide {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: center;
    flex-wrap: wrap;
    flex-direction: row;
  }

  .brand {
    flex: 1 1 auto;
    order: 1;
  }

  .nav-toggle {
    display: inline-flex;
    order: 2;
    margin-left: auto;
  }

  .top-links {
    display: none;
    width: 100%;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-top: 0.2rem;
    order: 3;
  }

  .top-links.open {
    display: flex;
  }

  .top-links {
    gap: 0.5rem;
  }

  .top-links a {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 9px;
    padding: 0.48rem 0.58rem;
  }

  .nav-logout {
    width: 100%;
  }

  .nav-logout button {
    width: 100%;
  }

  .brand-logo {
    height: 16px;
  }

  .brand-logo--convoy {
    height: 17px;
  }

  .brand-sub {
    font-size: 0.65rem;
  }

  .layout {
    padding: 1rem;
  }

  .qr-preview {
    width: 146px;
    height: 146px;
  }

  .workspace-tabs {
    flex-wrap: wrap;
    gap: 0.34rem;
  }

  .workspace-tab {
    flex: 1 1 calc(50% - 0.34rem);
    text-align: center;
    white-space: normal;
  }

  .unit-board-card .action-row {
    justify-content: center;
  }

  .table-wrap {
    overflow: visible;
    border: none;
    background: transparent;
  }

  table.mobile-stack-table {
    min-width: 0;
  }

  table.mobile-stack-table thead {
    display: none;
  }

  table.mobile-stack-table,
  table.mobile-stack-table tbody,
  table.mobile-stack-table tr,
  table.mobile-stack-table td {
    display: block;
    width: 100%;
  }

  table.mobile-stack-table tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-strong);
    margin-bottom: 0.62rem;
    padding: 0.2rem 0.58rem;
  }

  table.mobile-stack-table td {
    display: grid;
    grid-template-columns: minmax(104px, 40%) 1fr;
    gap: 0.48rem;
    align-items: start;
    border-bottom: 1px dashed var(--line);
    padding: 0.56rem 0.16rem;
    overflow-wrap: anywhere;
    min-width: 0;
  }

  table.mobile-stack-table td:last-child {
    border-bottom: none;
  }

  table.mobile-stack-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
  }

  table.mobile-stack-table td[colspan] {
    display: block;
    padding: 0.65rem 0.18rem;
  }

  table.mobile-stack-table td[colspan]::before {
    content: none;
  }
}
