:root {
  --bg: #f3ead9;
  --panel: #fffbf3;
  --panel-strong: #ede1c9;
  --line: #ddc9a3;
  --text: #3a2f22;
  --muted: #8c7a5e;
  --olive: #9c6b3e;
  --khaki: #b8672a;
  --amber: #d98c2b;
  --red: #b8483a;
  --green: #5c8a4a;
  --black: #2a2018;
  --field-bg: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-head: "Oswald", var(--font-body);
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(ellipse 1200px 600px at 15% -10%, rgba(184, 103, 42, 0.08), transparent 60%),
    url("./bg-pattern.svg") 0 0/400px 400px repeat,
    var(--bg);
  background-attachment: fixed;
}

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

::selection {
  background: var(--khaki);
  color: #fff;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--panel-strong);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 2px solid var(--panel-strong);
  border-radius: 8px;
}

.app-shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.section-head,
.user-panel,
.filters,
.intel-strip {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 22px;
  border-bottom: 2px solid var(--line);
  position: relative;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--khaki) 0 22px, transparent 22px 34px);
  opacity: 0.45;
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 0 4px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--khaki);
  border-radius: var(--radius);
  color: var(--khaki);
  background: var(--panel);
  box-shadow: 0 3px 8px rgba(58, 47, 34, 0.15);
  flex-shrink: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-family: var(--font-head);
}

h1 {
  font-size: clamp(1.5rem, 3vw, 2.75rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--khaki);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.user-panel {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-dot,
.role-badge {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--panel);
  color: var(--muted);
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(58, 47, 34, 0.06);
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.status-dot.online {
  color: var(--green);
  border-color: rgba(92, 138, 74, 0.5);
}

.status-dot.offline {
  color: var(--red);
  border-color: rgba(184, 72, 58, 0.5);
}

.role-badge {
  color: var(--khaki);
  border-color: rgba(184, 103, 42, 0.4);
}

.date-badge {
  color: var(--muted);
  border-color: var(--line);
  font-variant-numeric: tabular-nums;
}

.auth-grid,
.work-grid {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.auth-grid {
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 420px);
  align-items: stretch;
}

.auth-copy {
  min-height: 340px;
  display: grid;
  align-content: end;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(255, 251, 243, 0.92), rgba(237, 225, 201, 0.75));
  box-shadow: 0 10px 30px rgba(58, 47, 34, 0.1), 0 1px 3px rgba(58, 47, 34, 0.06);
  padding: 28px;
}

.auth-copy h2 {
  font-size: clamp(1.6rem, 3.5vw, 3rem);
  line-height: 0.95;
}

.auth-copy p:last-child {
  max-width: 680px;
  color: var(--muted);
}

.panel,
.metric-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 6px 20px rgba(58, 47, 34, 0.08), 0 1px 3px rgba(58, 47, 34, 0.06);
}

.compact-form,
.entry-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.entry-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
}

.work-grid {
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
}

.work-grid:has(.entry-form.hidden-for-role) {
  grid-template-columns: 1fr;
}

.section-head {
  grid-column: 1 / -1;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
}

.section-head select {
  width: auto;
  min-width: 220px;
  max-width: 320px;
}

.section-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(58, 47, 34, 0.05);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--khaki);
  box-shadow: 0 0 0 3px rgba(184, 103, 42, 0.18);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

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

.field-row {
  display: flex;
  gap: 8px;
}

.field-row select {
  flex: 1;
  min-width: 0;
}

.field-row .icon-button {
  min-height: 42px;
  min-width: 42px;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.primary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: border-color 0.15s ease, transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.primary-button {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent), var(--olive);
  border-color: var(--olive);
  color: #fff;
  box-shadow: 0 3px 8px rgba(156, 107, 62, 0.35);
}

.primary-button:hover {
  box-shadow: 0 5px 14px rgba(156, 107, 62, 0.45);
}

.ghost-button,
.icon-button {
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(58, 47, 34, 0.06);
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: var(--khaki);
}

.ghost-button:hover,
.icon-button:hover {
  box-shadow: 0 3px 8px rgba(184, 103, 42, 0.2);
}

.primary-button:active,
.ghost-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.icon-button {
  min-height: 34px;
  min-width: 34px;
  padding: 0 8px;
  font-size: 0.95rem;
  line-height: 1;
}

.icon-button.danger:hover {
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 3px 8px rgba(184, 72, 58, 0.25);
}

.message {
  min-height: 20px;
  color: var(--khaki);
  font-size: 0.84rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metric-card {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 16px;
  border-left: 4px solid var(--olive);
}

.metric-card span,
.intel-strip span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.metric-card strong {
  font-family: var(--font-head);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--text);
}

.metric-card small {
  color: var(--muted);
}

.metric-card.alert {
  border-color: rgba(217, 140, 43, 0.5);
  border-left-color: var(--amber);
  background: linear-gradient(180deg, rgba(217, 140, 43, 0.12), var(--panel) 60%);
}

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

.filters {
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.filters > label {
  flex: 1 1 160px;
}

.filters input,
.filters select {
  flex: 1 1 160px;
}

.filters input[type="search"] {
  flex-basis: 300px;
}

.intel-strip {
  gap: 10px;
  margin-bottom: 14px;
}

.intel-strip div {
  flex: 1;
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 10px 12px;
}

.intel-strip strong {
  overflow: hidden;
  font-family: var(--font-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(58, 47, 34, 0.06);
}

.table-wrap-compact {
  max-height: 300px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-strong);
  color: var(--olive);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--line);
}

td {
  color: var(--text);
  font-size: 0.9rem;
  max-width: 320px;
  overflow-wrap: break-word;
  background: var(--panel);
}

td.note-cell {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
}

tbody tr:hover td {
  background: rgba(184, 103, 42, 0.07);
}

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

.action-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.action-pill.deploy {
  color: var(--green);
  background: rgba(92, 138, 74, 0.1);
}

.action-pill.recover {
  color: var(--amber);
  background: rgba(217, 140, 43, 0.12);
}

.action-pill.relocate {
  color: var(--muted);
  background: rgba(140, 122, 94, 0.1);
}

.action-pill.repair {
  color: var(--olive);
  background: rgba(156, 107, 62, 0.12);
}

.action-pill.destroyed {
  color: var(--red);
  background: rgba(184, 72, 58, 0.1);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-pill.in_formation {
  color: var(--green);
  background: rgba(92, 138, 74, 0.1);
}

.status-pill.company_storage {
  color: var(--muted);
  background: rgba(140, 122, 94, 0.1);
}

.status-pill.logistics_storage {
  color: var(--olive);
  background: rgba(156, 107, 62, 0.12);
}

.status-pill.repair {
  color: var(--amber);
  background: rgba(217, 140, 43, 0.12);
}

.status-pill.destroyed {
  color: var(--red);
  background: rgba(184, 72, 58, 0.1);
}

.breadcrumb-link {
  color: inherit;
  text-decoration: none;
}

.breadcrumb-link:hover {
  color: var(--khaki);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(42, 32, 24, 0.4);
}

.modal-panel {
  width: min(420px, 100%);
  box-shadow: 0 20px 50px rgba(42, 32, 24, 0.3), 0 1px 3px rgba(58, 47, 34, 0.08);
}

.checkbox-option {
  display: flex !important;
  align-items: center;
  gap: 8px;
  text-transform: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: normal;
  color: var(--text);
}

.checkbox-option input[type="checkbox"] {
  width: auto;
  min-height: auto;
  accent-color: var(--khaki);
  box-shadow: none;
}

.report-categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.modal-divider {
  height: 0;
  border-top: 1px dashed var(--line);
  margin: 2px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.hidden-for-role {
  display: none !important;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

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

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar,
  .auth-grid {
    grid-template-columns: 1fr;
  }

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

  .auth-grid,
  .metric-grid,
  .entry-form {
    grid-template-columns: 1fr;
  }

  .wide,
  .section-head {
    grid-column: auto;
  }

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