:root {
  --bg: #f5f7f5;
  --surface: #ffffff;
  --ink: #17211c;
  --muted: #64716a;
  --line: #dce4de;
  --brand: #14795b;
  --brand-dark: #0c5742;
  --accent: #c77920;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(28, 43, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(20, 121, 91, 0.10), transparent 38%),
    linear-gradient(315deg, rgba(199, 121, 32, 0.12), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

html {
  scroll-behavior: smooth;
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(20, 121, 91, 0.24);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

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

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-lockup.compact {
  margin-bottom: 22px;
}

.brand-logo {
  display: block;
  object-fit: contain;
  background: #fff;
}

.login-logo {
  width: 190px;
  max-width: 48%;
  border-radius: 6px;
}

.sidebar-logo {
  width: 86px;
  height: 48px;
  border-radius: 4px;
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 6vw, 40px);
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 18px;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 12px 12px;
}

textarea {
  resize: vertical;
}

.primary {
  background: var(--brand);
  color: #fff;
}

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

.secondary {
  background: #e9f1ec;
  color: var(--brand-dark);
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

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

.sidebar {
  min-height: 100vh;
  padding: 22px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.tab {
  text-align: left;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: #e9f1ec;
  color: var(--brand-dark);
}

.manager-chip {
  margin-top: auto;
  display: grid;
  gap: 3px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfb;
}

.manager-chip span {
  font-weight: 800;
}

.manager-chip small {
  color: var(--muted);
}

.sync-chip {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid #c9dfd5;
  border-radius: 8px;
  background: #edf7f2;
}

.sync-chip span {
  color: var(--brand-dark);
  font-weight: 800;
}

.sync-chip small {
  color: var(--muted);
}

.content {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.top-actions,
.form-actions,
.section-head,
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.form-actions button,
.top-actions button {
  flex: 0 0 auto;
}

.view {
  display: none;
}

.active-view {
  display: grid;
  gap: 18px;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(28, 43, 35, 0.05);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 15px;
}

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

.section-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 11px;
  background: #f4efe8;
  color: #7c4a11;
  font-size: 12px;
  font-weight: 800;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-size: 14px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 28px;
}

.danger-link {
  background: transparent;
  color: var(--danger);
  min-height: auto;
  padding: 4px 6px;
}

.inline-link {
  background: transparent;
  color: var(--brand-dark);
  min-height: auto;
  padding: 4px 6px;
}

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

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

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

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

.equipment-list {
  display: grid;
  gap: 12px;
}

.people-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.person-chip {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  background: #fff;
}

.person-chip span {
  font-weight: 800;
}

.person-chip small {
  color: var(--muted);
  font-weight: 700;
}

.empty-copy {
  margin: 0;
  color: var(--muted);
}

.chart-bars {
  display: grid;
  gap: 10px;
  margin: 6px 0 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(130px, 190px) minmax(160px, 1fr) 80px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ee;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.bar-row strong {
  color: var(--ink);
  text-align: right;
}

.equipment-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.equipment-title {
  font-weight: 800;
}

.equipment-meta {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.output-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.output-tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.output-tags .input-tag {
  border-color: #c9dfd5;
  background: #edf7f2;
  color: var(--brand-dark);
}

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

  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .tab {
    text-align: center;
  }

  .manager-chip {
    margin-top: 0;
  }

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

  .form-grid,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 620px) {
  body {
    background: var(--bg);
  }

  button {
    width: 100%;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .login-view {
    min-height: 100svh;
    padding: 14px;
  }

  .login-panel {
    padding: 18px;
    box-shadow: 0 10px 28px rgba(28, 43, 35, 0.10);
  }

  .brand-lockup {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
  }

  .brand-lockup.compact {
    align-items: center;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 22px;
  }

  h3 {
    font-size: 16px;
  }

  .sidebar {
    padding: 14px;
    gap: 10px;
  }

  .sidebar-logo {
    width: 76px;
    height: 40px;
  }

  .manager-chip,
  .sync-chip {
    padding: 10px 12px;
  }

  .content {
    padding: 12px;
  }

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

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .form-grid,
  .metric-grid,
  .nav-tabs {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
    box-shadow: none;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

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

  .metric-grid {
    gap: 10px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 24px;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
  }

  td {
    border: 0;
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  td:last-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  td:last-child::before,
  .empty-state::before {
    content: none;
  }

  td:last-child button {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
  }

  .empty-state {
    display: block;
    border: 0;
    padding: 18px;
  }

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

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-row strong {
    text-align: left;
  }

  .person-chip {
    grid-template-columns: 1fr auto;
    width: 100%;
    border-radius: 8px;
  }

  .login-logo {
    width: 150px;
    max-width: 48%;
  }
}

@media (max-width: 380px) {
  .top-actions {
    grid-template-columns: 1fr;
  }

  td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .login-logo {
    max-width: 100%;
  }
}
