:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --line: #d6ded9;
  --text: #17201c;
  --muted: #64736c;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --warn: #92400e;
  --ok: #166534;
  --shadow: 0 14px 35px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: var(--brand-dark);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.1), rgba(180, 83, 9, 0.08)),
    var(--bg);
}

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

.login-panel h1,
.page-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.login-panel p,
.page-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  font-weight: 800;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--brand);
  border-radius: 6px;
  font-weight: 900;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.nav button,
.ghost-button,
.primary-button,
.small-button,
.danger-button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 13px;
  white-space: nowrap;
}

.nav button {
  background: transparent;
  color: var(--muted);
}

.nav button.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button {
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}

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

.ghost-button,
.small-button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-button {
  background: #fff5f5;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.panel,
.metric,
.table-panel,
.form-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.04);
}

.panel,
.form-section {
  padding: 16px;
}

.metric {
  padding: 15px;
}

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  background: #f8faf9;
  color: #374151;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover td {
  background: #f5faf8;
}

.muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f5f2;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.warning,
.error,
.success,
.notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.45;
}

.warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: var(--warn);
}

.error {
  background: #fff5f5;
  border: 1px solid #fecaca;
  color: var(--danger);
}

.success {
  background: #ecfdf3;
  border: 1px solid #bbf7d0;
  color: var(--ok);
}

.notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #34423b;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.inline-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5d1;
  border-radius: 7px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  border-color: var(--brand);
}

.form-section h2,
.panel h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.key-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.kv {
  display: grid;
  gap: 3px;
  min-width: 0;
}

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

.kv strong {
  overflow-wrap: anywhere;
}

.drawings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.drawing-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.drawing-box svg {
  display: block;
  width: 100%;
  height: auto;
}

.model3d-box {
  background: #ffffff;
  overflow: auto;
}

.model3d-box svg {
  min-width: 760px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.price-input {
  width: 110px;
}

.wide-input {
  min-width: 190px;
}

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

.loodsbon {
  white-space: pre-wrap;
}

.mobile-only {
  display: none;
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand,
  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .split,
  .drawings {
    grid-template-columns: 1fr;
  }

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

  .page-title {
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 18px 12px 40px;
  }

  .form-grid,
  .key-values {
    grid-template-columns: 1fr;
  }

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

  .form-actions button,
  .page-title button {
    width: 100%;
  }

  th,
  td {
    padding: 9px 8px;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: initial;
  }
}

.tabbar {
  display: flex;
  gap: 6px;
  margin: 18px 0 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.tabbar button {
  min-height: 40px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tabbar button.active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.danger-inline {
  margin-left: 6px;
  color: var(--danger);
}

.table-heading {
  border: 0;
  box-shadow: none;
  padding-bottom: 0;
}

.nesting-drawing {
  margin-top: 12px;
}
