:root {
  --brand: #e46701;
  --brand-soft: #fff0e3;
  --brand-strong: #b64e00;
  --ink: #24211f;
  --muted: #817870;
  --line: #eadfd5;
  --surface: #fff7ef;
  --panel: rgb(255 255 255 / 84%);
  --panel-solid: #ffffff;
  --panel-soft: #fffaf5;
  --teal: #147c72;
  --blue: #335c81;
  --danger: #b3261e;
  --shadow: 0 20px 55px rgb(92 56 26 / 12%);
  --soft-shadow: 0 12px 32px rgb(92 56 26 / 8%);
  --radius: 26px;
  --control-radius: 20px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-root {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fffaf6 0%, #fff3e9 48%, #f7eee6 100%);
}

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

button {
  cursor: pointer;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.boot-screen img {
  width: 132px;
  height: 132px;
  object-fit: contain;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.88fr) minmax(320px, 1.12fr);
  background:
    linear-gradient(180deg, rgb(255 252 249 / 92%), rgb(255 242 230 / 92%)),
    var(--surface);
}

.login-brand {
  min-height: 100vh;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  background: rgb(255 255 255 / 46%);
  color: var(--ink);
  backdrop-filter: blur(18px);
}

.brand-block {
  display: grid;
  gap: 24px;
  align-content: start;
}

.brand-logo {
  width: 118px;
  height: 118px;
  padding: 10px;
  object-fit: contain;
  background: white;
  border-radius: 28px;
}

.login-brand h1 {
  margin: 0;
  max-width: 640px;
  font-size: clamp(38px, 8vw, 72px);
  line-height: 0.92;
  letter-spacing: 0;
}

.brand-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-strip span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #f1d4bf;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-weight: 800;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-box {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-box h2,
.section-title h2,
.drawer h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: 0;
}

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

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

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

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.search-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  padding: 12px 16px;
  color: var(--ink);
  background: rgb(255 255 255 / 84%);
  outline: 0;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus {
  border-color: rgb(228 103 1 / 62%);
  box-shadow: 0 0 0 4px rgb(228 103 1 / 12%);
  background: white;
}

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

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--ink);
  background: rgb(255 255 255 / 78%);
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 1px 0 rgb(255 255 255 / 86%) inset;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--soft-shadow);
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  border-color: rgb(179 38 30 / 28%);
  color: var(--danger);
}

.btn.icon {
  width: 40px;
  padding: 0;
}

.error,
.notice {
  border-radius: 18px;
  padding: 12px 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

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

.notice {
  color: #315b32;
  background: #eff8ee;
  border: 1px solid #cae7c7;
}

.install-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #f0c7a5;
  border-radius: 22px;
  padding: 13px 14px;
  background: #fff7f0;
}

.install-panel strong,
.install-panel span {
  display: block;
}

.install-panel strong {
  margin-bottom: 3px;
}

.install-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.install-panel.installed {
  border-color: #b9ddd8;
  background: #edf8f6;
}

.install-status {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #b9ddd8;
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--teal);
  background: #edf8f6;
  font-size: 13px;
  font-weight: 900;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px 1fr;
  background:
    linear-gradient(180deg, rgb(255 252 249 / 94%), rgb(255 243 232 / 94%)),
    var(--surface);
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgb(255 255 255 / 58%);
  color: var(--ink);
  backdrop-filter: blur(18px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.sidebar-head img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  padding: 6px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--soft-shadow);
}

.sidebar-title {
  display: grid;
  gap: 2px;
}

.sidebar-title strong {
  line-height: 1;
}

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

.nav {
  display: grid;
  gap: 7px;
}

.nav button {
  min-height: 48px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 11px 14px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.nav button.active,
.nav button:hover {
  color: var(--ink);
  border-color: #f1d4bf;
  background: var(--brand-soft);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 250 246 / 78%);
  backdrop-filter: blur(16px);
}

.topbar-user {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.mobile-view-label {
  display: none;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  font-weight: 900;
}

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

.mobile-tabbar {
  display: none;
}

.section-title {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 20px;
  padding-left: 18px;
}

.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  width: 6px;
  height: 44px;
  border-radius: 999px;
  background: var(--brand);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

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

.metric {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(14px);
}

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

.metric strong {
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  overflow: hidden;
  backdrop-filter: blur(14px);
}

.panel-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: rgb(255 250 246 / 82%);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tr.selected td {
  background: rgb(255 240 227 / 72%);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef4f3;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.pill.blue {
  background: #eef3f8;
  color: var(--blue);
}

.pill.orange {
  background: #fff3e9;
  color: var(--brand-strong);
}

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

.list {
  display: grid;
}

.list-row {
  display: grid;
  gap: 6px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row strong {
  line-height: 1.2;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
}

.empty.compact {
  padding: 12px 0;
}

.empty-detail {
  margin-top: 16px;
}

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

.workorders-view {
  display: grid;
}

.workorder-card-list {
  display: none;
}

.workorder-card {
  width: 100%;
  display: grid;
  gap: 7px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 15px 16px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.workorder-card:last-child {
  border-bottom: 0;
}

.workorder-card.active,
.workorder-card:active {
  background: var(--brand-soft);
}

.workorder-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.workorder-card-head strong,
.workorder-card-client {
  line-height: 1.2;
}

.workorder-card-client {
  display: block;
  font-size: 17px;
  font-weight: 900;
}

.workorder-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.detail-panel {
  padding: 0;
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 250 246 / 72%);
}

.detail-hero h2 {
  margin: 6px 0 4px;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.detail-hero p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.eyebrow {
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.detail-summary > div {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px 16px;
  background: rgb(255 255 255 / 70%);
}

.detail-summary span,
.detail-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-summary strong,
.detail-row strong {
  line-height: 1.2;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.detail-row.wide {
  background: rgb(255 250 246 / 62%);
}

.detail-section {
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
}

.detail-section h3 {
  margin: 0;
  font-size: 16px;
}

.detail-section p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
  white-space: pre-wrap;
}

.detail-list,
.line-list {
  display: grid;
}

.line-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.line-row:last-child {
  border-bottom: 0;
}

.line-row strong,
.line-row span {
  display: block;
}

.line-qty {
  min-width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--brand);
  font-weight: 900;
}

.line-serials {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.line-serials span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  background: rgb(255 255 255 / 72%);
  font-size: 12px;
  font-weight: 800;
}

.detail-edit {
  align-self: start;
  position: sticky;
  top: 96px;
}

.form-actions {
  justify-content: flex-end;
}

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

.action-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.wide-drawer {
  margin-top: 16px;
}

.form-two,
.form-three {
  display: grid;
  gap: 12px;
}

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

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

.check-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  align-self: end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.drawer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(14px);
}

.drawer h2 {
  margin-bottom: 14px;
}

.file-input {
  min-height: 44px;
  display: block;
}

@media (max-width: 980px) {
  .login-page,
  .grid-two,
  .workorder-detail-grid,
  .sync-grid,
  .action-grid,
  .form-two,
  .form-three {
    grid-template-columns: 1fr;
  }

  .layout {
    min-height: 100vh;
    display: block;
    padding-bottom: 84px;
  }

  .login-brand {
    min-height: auto;
    padding: 28px;
    gap: 34px;
  }

  .sidebar {
    display: none;
  }

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

  .detail-edit {
    position: static;
  }

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

  .mobile-tabbar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 10px;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(72px, 1fr);
    gap: 4px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border: 1px solid var(--line);
    border-radius: 26px;
    padding: 7px;
    background: rgb(255 255 255 / 88%);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  .mobile-tabbar button {
    min-width: 72px;
    min-height: 54px;
    display: grid;
    place-items: center;
    gap: 4px;
    border: 0;
    border-radius: 20px;
    padding: 8px 10px;
    color: var(--muted);
    background: transparent;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
    white-space: nowrap;
  }

  .mobile-tabbar button.active {
    color: var(--brand-strong);
    background: var(--brand-soft);
  }

  .tab-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
  }

  .mobile-tabbar button.active .tab-dot {
    background: var(--brand);
  }
}

@media (max-width: 620px) {
  .content,
  .topbar {
    padding: 16px;
  }

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

  .workorders-title {
    margin-bottom: 12px;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar > * {
    flex: 1 1 160px;
  }

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

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

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: stretch;
    min-height: 64px;
    flex-direction: row;
    background: rgb(255 250 246 / 86%);
  }

  .desktop-user-label {
    display: none;
  }

  .mobile-view-label {
    display: block;
    color: var(--ink);
    font-size: 18px;
    font-weight: 900;
  }

  .topbar .toolbar {
    flex: 0 0 auto;
    justify-content: flex-end;
  }

  .topbar .install-status,
  .topbar [data-action="install-app"],
  .topbar [data-action="logout"] {
    display: none;
  }

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

  .detail-summary,
  .detail-row {
    grid-template-columns: 1fr;
  }

  .row-actions .btn,
  .form-actions .btn {
    flex: 1 1 100%;
  }

  .topbar .btn {
    min-height: 40px;
    width: auto;
    padding: 8px 12px;
    font-size: 13px;
  }

  .table-wrap.workorder-table-wrap {
    display: none;
  }

  .workorder-card-list {
    display: grid;
  }

  .workorders-view.detail-open .workorders-title,
  .workorders-view.detail-open .workorder-list-panel,
  .workorders-view.detail-open + .new-workorder-panel,
  .workorders-view.detail-open .empty-detail {
    display: none;
  }

  .workorders-view.list-open .empty-detail {
    display: none;
  }

  .workorder-detail-grid {
    margin-top: 0;
  }

  .detail-panel,
  .detail-edit,
  .drawer,
  .panel,
  .metric {
    border-radius: 22px;
  }

  .new-workorder-panel {
    margin-top: 14px;
  }

  .content {
    padding-bottom: 28px;
  }

  .login-panel {
    padding: 18px;
  }

  .login-box {
    padding: 20px;
  }
}
