:root {
  color-scheme: light;
  --ink: #18201c;
  --muted: #66736c;
  --paper: #f7f8f5;
  --panel: #ffffff;
  --line: #dfe7df;
  --green: #24745a;
  --green-dark: #155640;
  --coral: #d96545;
  --gold: #e2b84b;
  --sky: #d7edf0;
  --danger: #9f351d;
  --shadow: 0 18px 50px rgba(24, 32, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

code,
pre {
  border-radius: 8px;
  background: #eff5ef;
}

code {
  padding: 2px 5px;
}

pre {
  overflow-x: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.loading-screen,
.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-layout {
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.6fr);
  gap: 24px;
}

.compact-auth {
  grid-template-columns: minmax(320px, 520px);
}

.auth-art,
.auth-card,
.panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(24, 32, 28, 0.06);
}

.auth-art {
  position: relative;
  min-height: min(760px, calc(100vh - 48px));
  overflow: hidden;
}

.auth-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) contrast(0.96) brightness(0.58);
}

.auth-art div {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 28px;
  color: white;
}

.auth-art h1 {
  max-width: 760px;
  font-size: clamp(34px, 5vw, 72px);
  line-height: 1;
}

.auth-card {
  width: 100%;
  display: grid;
  gap: 18px;
  padding: 24px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-copy,
.helper-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.success-message,
.error-message {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  font-weight: 800;
}

.success-message {
  background: #e7f7ed;
  color: var(--green-dark);
}

.error-message {
  background: #ffe9e4;
  color: var(--danger);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: #fdfefd;
  border-right: 1px solid var(--line);
  overflow: auto;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-size: 26px;
  font-weight: 900;
}

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

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

h1 {
  font-size: 22px;
}

h2 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

h3 {
  font-size: 20px;
}

.input,
.cell-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.input {
  padding: 12px 13px;
}

.cell-input {
  min-width: 120px;
  padding: 10px;
}

.cell-input.number {
  min-width: 82px;
}

.input:focus,
.cell-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(36, 116, 90, 0.14);
}

.compact {
  max-width: 160px;
}

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

textarea {
  resize: vertical;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn,
.link-btn {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  border: 0;
}

.primary-btn {
  padding: 12px 16px;
  background: var(--green);
  color: white;
  box-shadow: 0 10px 24px rgba(36, 116, 90, 0.25);
}

.ghost-btn {
  padding: 11px 14px;
  background: #eef6ef;
  color: var(--green-dark);
  border: 1px solid #cfe2d2;
}

.danger-btn {
  padding: 12px 16px;
  background: #ffe9e4;
  color: var(--danger);
  border: 1px solid #ffc5b7;
}

.link-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green-dark);
  text-align: left;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.icon-btn {
  width: 34px;
  height: 34px;
  background: #f2f4f0;
  color: var(--muted);
}

.full {
  width: 100%;
}

.project-list {
  display: grid;
  gap: 10px;
}

.project-card {
  display: grid;
  gap: 5px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.project-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(36, 116, 90, 0.12);
}

.project-card strong,
.project-card span,
.account-panel strong {
  overflow-wrap: anywhere;
}

.project-card span,
.account-panel span {
  color: var(--muted);
  font-size: 12px;
}

.account-panel {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border-radius: 8px;
  background: var(--sky);
}

.workspace {
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 28px;
}

.topbar,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-strip {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.hero-strip img {
  width: 100%;
  height: 100%;
  min-height: 210px;
  object-fit: cover;
  filter: saturate(0.9) contrast(0.96) brightness(0.72);
}

.hero-copy {
  position: absolute;
  left: 24px;
  bottom: 24px;
  max-width: min(620px, calc(100% - 48px));
  color: white;
}

.hero-copy strong {
  display: block;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.05;
}

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

.stat-card {
  display: grid;
  gap: 8px;
  padding: 17px;
}

.stat-card span,
.quote-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong,
.quote-box strong {
  font-size: clamp(22px, 3vw, 32px);
}

.stat-card.accent {
  background: #fff7df;
  border-color: #f0d684;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

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

.project-form {
  gap: 17px;
}

.quote-box {
  display: grid;
  gap: 12px;
}

.quote-box div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.mfa-panel {
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
}

.qr-code {
  width: 176px;
  height: 176px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.inline-form {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 10px;
}

.empty-state {
  max-width: 620px;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  padding: 9px 7px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.row-total {
  min-width: 95px;
  font-weight: 800;
}

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

  .auth-art {
    min-height: 360px;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

@media (max-width: 620px) {
  .workspace,
  .sidebar,
  .auth-layout {
    padding: 18px;
  }

  .topbar,
  .panel-heading,
  .mfa-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .top-actions,
  .field-grid,
  .stats-grid,
  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: white;
  }

  .sidebar,
  .topbar,
  .hero-strip,
  .stats-grid,
  .project-form,
  .quick-panel,
  .mfa-panel,
  #addMaterialBtn,
  #addCutBtn,
  .icon-btn {
    display: none !important;
  }

  .app-shell,
  .workspace {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
  }

  .cell-input {
    border: 0;
    padding: 0;
  }
}
