:root {
  --ink: #172326;
  --muted: #637176;
  --line: #d9e0df;
  --surface: #ffffff;
  --soft: #f4f7f5;
  --nav: #12333b;
  --nav-2: #0e252b;
  --accent: #d56a2a;
  --accent-2: #1f7a68;
  --danger: #b83b3b;
  --warning: #aa7117;
  --ok: #26754f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--soft);
  overflow-x: hidden;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--soft);
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.login-panel h1 {
  font-size: 26px;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  color: white;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #142529;
  background: #f2c56b;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: #b9cbcf;
}

.nav-tabs {
  display: grid;
  gap: 8px;
  max-width: 100%;
}

.nav-tab {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #e9f1f2;
  text-align: left;
  background: transparent;
}

.nav-tab.active,
.nav-tab:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.18);
}

.operator-card {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.user-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.user-badge span {
  color: #e9f1f2;
  font-size: 13px;
  font-weight: 700;
}

.text-button {
  padding: 0;
  border: 0;
  color: #f2c56b;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.operator-card label {
  color: #cddbdd;
  font-size: 13px;
}

.operator-card input {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.operator-card input::placeholder {
  color: #b4c6c9;
}

.workspace {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 28px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  letter-spacing: 0;
}

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

.top-actions,
.panel-header,
.field-grid,
.sync-grid,
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  padding: 0 16px;
  color: white;
  background: var(--accent);
}

.secondary-button {
  padding: 0 14px;
  color: var(--ink);
  background: white;
  border-color: var(--line);
}

.icon-button {
  width: 42px;
  color: var(--ink);
  background: white;
  border-color: var(--line);
  font-size: 20px;
}

.wide {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric-panel {
  padding: 18px;
}

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

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

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.form-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 12px;
}

.filter-row {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-row select {
  width: auto;
  min-width: 180px;
}

.panel-header h2 {
  margin-bottom: 0;
}

.table-wrap {
  overflow: auto;
}

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

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;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.ok {
  color: var(--ok);
  background: #e8f4ee;
}

.status.low {
  color: var(--warning);
  background: #fff2d9;
}

.status.empty {
  color: var(--danger);
  background: #fde7e7;
}

.activity-list,
.catalog-list {
  display: grid;
  gap: 10px;
}

.activity-item,
.catalog-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.activity-item strong,
.catalog-item strong {
  display: block;
  margin-bottom: 4px;
}

.muted,
.activity-item span,
.catalog-item span {
  color: var(--muted);
  font-size: 13px;
}

.form-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.form-panel h2 {
  margin-bottom: 4px;
}

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

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

textarea {
  resize: vertical;
}

.field-grid {
  align-items: start;
}

.field-grid > label {
  flex: 1 1 0;
}

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

.segmented label {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  font-size: 13px;
}

.sync-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.file-input input {
  padding-top: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  color: white;
  background: #172326;
  opacity: 0;
  transform: translateY(14px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 16px;
  }

  .nav-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow-x: auto;
  }

  .nav-tab {
    text-align: center;
  }

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

  .split-layout,
  .form-layout,
  .sync-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .workspace {
    padding: 18px 14px 96px;
  }

  .topbar,
  .panel-header,
  .field-grid,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-row select {
    width: 100%;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions .primary-button {
    flex: 1;
  }

  h1 {
    font-size: 24px;
  }

  .metrics-grid,
  .operator-card {
    grid-template-columns: 1fr;
  }

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

  .nav-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-tab {
    flex: 0 0 132px;
  }
}
