:root {
  --ink: #17342f;
  --muted: #6f7d79;
  --green: #123c35;
  --green-2: #235f53;
  --mint: #dcece6;
  --cream: #f4f1e9;
  --paper: #fff;
  --line: #e5e9e6;
  --amber: #dc9f4d;
  --blue: #4f7da3;
  --shadow: 0 18px 45px rgba(31, 55, 49, 0.08);
}

* { box-sizing: border-box; }

html { background: var(--cream); }

body {
  margin: 0;
  padding-top: env(safe-area-inset-top);
  color: var(--ink);
  background: #f8f8f5;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }

.sidebar {
  position: fixed;
  inset: env(safe-area-inset-top) auto 0 0;
  width: 240px;
  display: flex;
  flex-direction: column;
  padding: 30px 18px 22px;
  color: #fff;
  background: var(--green);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 34px;
  color: #fff;
  font: 700 21px/1 Georgia, serif;
  text-decoration: none;
  letter-spacing: .2px;
}

.brand-mark {
  width: 52px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
}

.brand-mark img { width: 100%; height: 100%; display: block; object-fit: contain; }
.main-nav { display: grid; gap: 7px; }

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #c7d6d2;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-icon { width: 22px; font-size: 19px; text-align: center; }
.sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.12); }
.profile { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.profile span:last-child { display: grid; gap: 3px; }
.profile small { color: #a9bfba; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: #cce4dc; font-weight: 800; }
.cloud-button { width: 100%; margin-top: 14px; padding: 9px 10px; border: 1px solid rgba(255,255,255,.18); border-radius: 9px; color: #d7e8e3; background: rgba(255,255,255,.08); cursor: pointer; font-size: 11px; font-weight: 800; }
.cloud-button.connected { color: #123c35; background: #cce4dc; }

main { grid-column: 2; min-width: 0; padding: 0 42px 50px; }
.topbar { min-height: 112px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.topbar h1 { margin: 4px 0 0; font: 600 27px/1.1 Georgia, serif; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.cloud-top-button.connected { color: #fff; background: var(--green-2); }
.eyebrow, .section-label { margin: 0; color: var(--green-2); font-size: 11px; line-height: 1; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 800; }

.primary-button, .secondary-button {
  border: 0;
  border-radius: 10px;
  padding: 12px 17px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .18s ease, box-shadow .18s ease;
}

.primary-button { color: #fff; background: var(--green); box-shadow: 0 8px 18px rgba(18,60,53,.18); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 11px 24px rgba(18,60,53,.24); }
.secondary-button { color: var(--ink); background: #eef1ef; }
.danger-button { margin-right: auto; border: 0; border-radius: 10px; padding: 12px 17px; color: #a13c36; background: #f8e8e6; cursor: pointer; font-weight: 750; }
.hidden { display: none !important; }

.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: .35; transform: translateY(4px); } }

.hero {
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  padding: 34px 45px;
  border-radius: 19px;
  color: #fff;
  background: linear-gradient(118deg, #123c35, #1f584d);
  box-shadow: var(--shadow);
}

.hero-kicker { color: #b9d6cd; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 800; }
.hero h2 { margin: 12px 0 13px; font: 500 clamp(28px, 4vw, 42px)/1.08 Georgia, serif; letter-spacing: -.5px; }
.hero p { max-width: 550px; margin: 0; color: #d1e0dc; line-height: 1.55; font-size: 14px; }
.hero-art { width: 230px; min-width: 230px; height: 190px; position: relative; display: grid; place-items: center; }
.hero-ring { position: absolute; width: 180px; height: 180px; border: 1px solid rgba(255,255,255,.17); border-radius: 50%; box-shadow: 0 0 0 26px rgba(255,255,255,.035), 0 0 0 56px rgba(255,255,255,.025); }
.hero-wrench { transform: rotate(-25deg); font-size: 115px; line-height: 1; color: #c6e0d7; opacity: .9; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 20px 0; }
.stat-card { min-height: 108px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.stat-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; font-size: 20px; }
.stat-icon.green { background: #e5f1ed; color: var(--green-2); }
.stat-icon.amber { background: #f9efde; color: #b87722; }
.stat-icon.blue { background: #e6eef5; color: var(--blue); }
.stat-card div { display: grid; }
.stat-card strong { font: 600 25px/1 Georgia, serif; }
.stat-card span:not(.stat-icon) { margin-top: 5px; color: var(--muted); font-size: 12px; }
.stat-card small { align-self: end; color: #9aa49f; font-size: 10px; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(260px, .8fr); gap: 20px; }
.panel { padding: 23px; border-radius: 15px; border: 1px solid var(--line); background: #fff; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.panel h3, .section-toolbar h2 { margin: 7px 0 0; font: 600 20px/1.1 Georgia, serif; }
.text-button { align-self: end; padding: 0 0 2px; border: 0; color: var(--green-2); background: none; cursor: pointer; font-size: 12px; font-weight: 700; }
.item-list { display: grid; }

.intervention-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  margin: 9px 0;
  padding: 14px 13px;
  border: 1px solid transparent;
  border-left-width: 6px;
  border-radius: 12px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.intervention-item:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(31, 55, 49, .07); }
.intervention-planned { border-color: #d85852; background: #fff1f0; }
.intervention-unscheduled { border-color: #9aa49f; background: #f4f6f5; }
.intervention-progress { border-color: #d8a52f; background: #fff8df; }
.intervention-completed { border-color: #3f976f; background: #eaf7f0; }
.intervention-planned .date-box { color: #9d332f; background: #fbdeda; }
.intervention-unscheduled .date-box { color: #5f6d68; background: #e2e7e5; }
.intervention-progress .date-box { color: #805d0f; background: #f7e8b5; }
.intervention-completed .date-box { color: #28684e; background: #cfe9dc; }

.date-box { width: 47px; height: 47px; display: grid; place-content: center; border-radius: 10px; text-align: center; background: #edf4f1; }
.date-box strong { font: 600 18px/1 Georgia, serif; }
.date-box small { margin-top: 3px; color: var(--green-2); font-size: 9px; text-transform: uppercase; font-weight: 800; }
.item-copy { min-width: 0; display: grid; gap: 4px; }
.item-copy strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.item-copy small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 11px; }
.item-meta { display: flex; align-items: center; gap: 10px; }
.item-actions { display: flex; gap: 6px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--green-2); background: #fff; cursor: pointer; font-size: 15px; }
.icon-button:hover { background: #edf4f1; }
.status { display: inline-flex; padding: 6px 9px; border-radius: 999px; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }
.status.unscheduled { color: #5f6d68; background: #e7ecea; }
.status.planned { color: #9a661f; background: #fbefd9; }
.status.progress { color: #356889; background: #e5f0f8; }
.status.completed { color: #2d6a59; background: #e2f1eb; }
.time { color: var(--muted); font-size: 11px; }
.empty { padding: 30px 10px; color: var(--muted); text-align: center; font-size: 13px; border-top: 1px solid #edf0ee; }

.quick-panel { align-self: start; }
.quick-action { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 13px 0; border: 0; border-top: 1px solid #edf0ee; background: transparent; text-align: left; cursor: pointer; }
.quick-action span:nth-child(2) { display: grid; gap: 4px; }
.quick-action small { color: var(--muted); font-size: 10px; }
.quick-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--green-2); font-size: 21px; }
.quick-icon.pale { color: var(--green); background: #e6f0ec; }

.section-toolbar { min-height: 75px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; }
.search { width: min(330px, 45vw); display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.search input { width: 100%; padding: 11px 0; border: 0; outline: 0; background: transparent; }
.table-panel { padding-top: 10px; }
.clients-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.client-card { min-height: 180px; padding: 21px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.client-card .avatar { margin-bottom: 18px; }
.client-card strong { display: block; margin-bottom: 7px; font-family: Georgia, serif; }
.client-card small { display: block; color: var(--muted); line-height: 1.5; }
.client-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.client-card-actions { display: flex; gap: 6px; }
.client-contact { margin-top: 9px; }
.orders-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.catalog-panel { margin-bottom: 20px; }
.catalog-form { display: grid; grid-template-columns: minmax(180px, 1fr) 130px 190px 130px 130px auto; align-items: end; gap: 10px; }
.tools-panel { margin-bottom: 20px; }
.tool-form { display: grid; grid-template-columns: minmax(180px, 1fr) auto; align-items: end; gap: 10px; }
.catalog-list { display: grid; gap: 8px; margin-top: 16px; }
.catalog-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 34px;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf9;
}
.catalog-item strong { display: block; font-size: 13px; }
.catalog-item small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.catalog-item > span { justify-self: end; color: var(--green); font-weight: 850; }
.tool-item { grid-template-columns: minmax(0, 1fr) 34px; }
.order-panel { align-self: start; }
.order-list { display: grid; gap: 9px; }
.order-item, .order-print-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  align-items: start;
  gap: 14px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf9;
}
.order-item strong, .order-print-item strong { display: block; font-size: 13px; }
.order-item small, .order-print-item small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.45; font-size: 10px; white-space: pre-wrap; }
.order-item > span, .order-print-item > span { justify-self: end; color: var(--green); font-weight: 850; }
.order-print-heading { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 14px; margin: 20px 0 10px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }
.order-print-list { display: grid; gap: 8px; }

dialog { width: min(720px, calc(100% - 32px)); max-height: min(850px, calc(100dvh - 32px)); padding: 0; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 30px 80px rgba(10,35,29,.25); }
.small-dialog { width: min(590px, calc(100% - 32px)); }
.photo-viewer { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: max(56px, calc(env(safe-area-inset-top) + 42px)) 16px max(24px, env(safe-area-inset-bottom)); border-radius: 0; color: #fff; background: rgba(8, 16, 14, .97); }
.photo-viewer[open] { display: grid; place-items: center; grid-template-rows: minmax(0, 1fr) auto; }
.photo-viewer::backdrop { background: #08100e; }
.photo-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.photo-viewer p { max-width: 700px; margin: 14px 0 0; overflow: hidden; color: #dce7e3; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.viewer-close { position: fixed; z-index: 2; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); width: 42px; height: 42px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.15); cursor: pointer; font-size: 28px; }
.report-dialog { width: min(760px, calc(100% - 32px)); }
.report-sheet { padding: 32px; }
.report-heading { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 2px solid var(--green); }
.report-heading h2 { margin: 8px 0 0; font: 600 27px/1.1 Georgia, serif; }
.report-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 24px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.report-meta span { display: grid; gap: 3px; }
.report-meta small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: 1px; }
.report-section { padding: 19px 0; border-bottom: 1px solid var(--line); }
.report-section h3 { margin: 0 0 10px; font: 600 16px/1 Georgia, serif; }
.report-section p { margin: 0; color: #4e5e5a; line-height: 1.55; white-space: pre-wrap; }
.report-costs div { display: flex; justify-content: space-between; gap: 20px; padding: 7px 0; }
.report-total { margin-top: 7px; padding-top: 14px !important; border-top: 2px solid var(--green); font-size: 18px; }
.signature-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.signature-help { margin-top: 4px !important; font-size: 11px; }
.signature-pad { position: relative; height: 190px; overflow: hidden; border: 1px dashed #8ea49e; border-radius: 10px; background: #fff; touch-action: none; }
.signature-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.signature-pad > span { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); color: #a7b2af; pointer-events: none; font: italic 16px/1 Georgia, serif; }
.signature-pad::after { content: ""; position: absolute; right: 9%; bottom: 45px; left: 9%; border-bottom: 1px solid #d8dfdc; pointer-events: none; }
.signature-date { min-height: 18px; margin-top: 9px !important; color: var(--muted) !important; font-size: 10px; text-align: right; }
dialog::backdrop { background: rgba(11,34,29,.55); backdrop-filter: blur(3px); }
dialog form { padding: 28px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 25px; }
.dialog-heading h2 { margin: 7px 0 0; font: 600 25px/1 Georgia, serif; }
.close-button { width: 35px; height: 35px; border: 0; border-radius: 50%; background: #eef1ef; cursor: pointer; font-size: 23px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 7px; color: #40524e; font-size: 11px; font-weight: 750; }
.field.wide { grid-column: 1 / -1; }
.field input, .field textarea, .field select { width: 100%; padding: 11px 12px; border: 1px solid #dfe5e1; border-radius: 9px; color: var(--ink); background: #fbfcfb; outline: none; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #6a9a8d; box-shadow: 0 0 0 3px #e5f0ec; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.client-picker-field select { min-width: 0; }
.scan-field { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 6px; }
.scan-field .icon-button { width: 40px; height: 40px; }
.calendar-option { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border: 1px solid #dbe5e0; border-radius: 10px; background: #f3f8f6; cursor: pointer; }
.calendar-option input { width: 19px; height: 19px; margin: 0; accent-color: var(--green); }
.calendar-option span { display: grid; gap: 3px; }
.calendar-option strong { font-size: 12px; }
.calendar-option small { color: var(--muted); font-size: 10px; }
.no-spinner::-webkit-inner-spin-button, .no-spinner::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
.no-spinner { appearance: textfield; -moz-appearance: textfield; }
.materials-editor, .tools-editor { margin: 0; padding: 18px; border: 1px solid #dbe5e0; border-radius: 12px; background: #fff; }
.materials-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.materials-heading legend { padding: 0; color: var(--green-2); font: 700 14px/1 Georgia, serif; }
.compact-button { padding: 9px 11px; font-size: 11px; }
.materials-list { display: grid; gap: 9px; }
.tools-list { display: grid; gap: 9px; }
.material-row { display: grid; grid-template-columns: minmax(170px, 1fr) 112px 170px 126px 82px 112px 100px 34px; align-items: end; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #f8faf9; }
.tool-row { display: grid; grid-template-columns: minmax(170px, 1fr) 34px; align-items: end; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #f8faf9; }
.material-row .field { min-width: 0; }
.tool-row .field { min-width: 0; }
.material-category { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 0; padding: 0; border: 0; }
.material-category legend { grid-column: 1 / -1; padding: 0; color: #40524e; font-size: 11px; font-weight: 750; }
.material-category label { display: grid; }
.material-category input { position: absolute; opacity: 0; pointer-events: none; }
.material-category span { display: grid; place-items: center; min-height: 40px; border: 1px solid #dfe5e1; border-radius: 9px; color: var(--muted); background: #fff; font-size: 10px; font-weight: 850; cursor: pointer; }
.material-category input:checked + span { border-color: #6a9a8d; color: #fff; background: var(--green-2); }
.material-subtotal { height: 40px; display: flex; align-items: center; padding: 0 9px; border-radius: 9px; color: var(--green); background: #e5f1ed; font-weight: 800; font-size: 12px; white-space: nowrap; }
.remove-material { margin-bottom: 3px; color: #a13c36; background: #fff0ee; }
.materials-empty { margin: 0; padding: 12px; color: var(--muted); text-align: center; font-size: 11px; }
.report-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0; padding: 18px; border: 1px solid #dbe5e0; border-radius: 12px; background: #f7faf8; }
.report-fields legend { padding: 0 8px; color: var(--green-2); font: 700 14px/1 Georgia, serif; }
.cost-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.cost-preview > span { display: grid; gap: 5px; padding: 12px; border-radius: 9px; background: #fff; }
.cost-preview small { color: var(--muted); font-size: 10px; }
.cost-preview strong { font-family: Georgia, serif; }
.cost-preview .cost-total { color: #fff; background: var(--green); }
.cost-preview .cost-total small { color: #c9dbd6; }
.materials-total-output { min-height: 40px; display: flex; align-items: center; padding: 11px 12px; border: 1px solid #dfe5e1; border-radius: 9px; color: var(--green); background: #eef6f2; font-size: 15px; font-weight: 800; }
.upload-field { position: relative; }
.upload-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-box { display: grid; place-items: center; gap: 4px; min-height: 80px; padding: 15px; border: 1px dashed #aabdb7; border-radius: 10px; color: var(--green-2); background: #f7faf8; cursor: pointer; }
.upload-box small { color: var(--muted); font-weight: 400; }
.photo-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.photo-gallery:empty { display: none; }
.photo-card { position: relative; overflow: hidden; aspect-ratio: 1; margin: 0; border: 1px solid var(--line); border-radius: 11px; background: #edf1ef; }
.photo-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.open-photo { width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.remove-photo { position: absolute; top: 6px; right: 6px; width: 29px; height: 29px; display: grid; place-items: center; border: 0; border-radius: 50%; color: #fff; background: rgba(25,38,35,.78); cursor: pointer; font-size: 18px; line-height: 1; }
.photo-badge { position: absolute; left: 6px; bottom: 6px; padding: 4px 7px; border-radius: 999px; color: #fff; background: rgba(25,38,35,.72); font-size: 9px; font-weight: 700; }
.photo-count { color: var(--green-2); font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 30px; z-index: 30; transform: translate(-50%, 20px); padding: 12px 18px; border-radius: 10px; color: #fff; background: var(--green); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s ease; font-size: 13px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.scanner-box { padding: 28px; }
.scanner-box video { width: 100%; min-height: 260px; display: block; border-radius: 12px; background: #101816; object-fit: cover; }
.scanner-box p { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { inset: auto 0 0; width: auto; height: calc(73px + env(safe-area-inset-bottom)); padding: 8px max(14px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); flex-direction: row; align-items: flex-start; box-shadow: 0 -4px 22px rgba(12,40,33,.14); }
  .brand, .sidebar-footer { display: none; }
  .main-nav { width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
  .nav-item { justify-content: center; flex-direction: column; gap: 2px; padding: 6px; font-size: 10px; }
  .nav-icon { font-size: 18px; }
  main { padding: 0 22px calc(100px + env(safe-area-inset-bottom)); }
  .hero-art { width: 170px; min-width: 170px; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 88px; }
  .content-grid { grid-template-columns: 1fr; }
  .clients-grid { grid-template-columns: repeat(2, 1fr); }
  .orders-grid { grid-template-columns: 1fr; }
  .catalog-form { grid-template-columns: 1fr 1fr; }
  .tool-form { grid-template-columns: 1fr auto; }
  .catalog-form .primary-button { grid-column: 1 / -1; }
  .material-row { grid-template-columns: minmax(170px, 1fr) 112px 170px 126px 82px 112px 100px 34px; overflow-x: auto; }
}

@media (max-width: 600px) {
  main { padding-inline: 15px; }
  .topbar { min-height: 112px; padding-top: 12px; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; gap: 7px; }
  .topbar h1 { font-size: 22px; }
  .primary-button { padding: 11px 13px; font-size: 12px; }
  .hero { min-height: 230px; padding: 28px 25px; }
  .hero p { font-size: 12px; }
  .hero-art { display: none; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { min-height: 120px; display: flex; align-items: flex-start; flex-direction: column; gap: 8px; padding: 13px; }
  .stat-card small { display: none; }
  .stat-card strong { font-size: 21px; }
  .stat-card span:not(.stat-icon) { font-size: 10px; }
  .stat-icon { width: 34px; height: 34px; font-size: 16px; }
  .panel { padding: 18px; }
  .intervention-item { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; }
  .item-meta { grid-column: 2; justify-content: space-between; }
  .item-actions { grid-column: 3; grid-row: 1 / span 2; align-self: center; flex-direction: column; }
  .date-box { width: 42px; height: 42px; }
  .section-toolbar { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .clients-grid { grid-template-columns: 1fr; }
  dialog { width: 100%; max-width: none; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  dialog form { padding: 23px 18px calc(22px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .report-fields { grid-template-columns: 1fr; }
  .material-row { grid-template-columns: minmax(0, 1fr) 78px; overflow-x: visible; }
  .material-row .material-description { grid-column: 1 / -1; }
  .material-row .material-code, .material-row .material-barcode { grid-column: 1 / -1; }
  .material-category { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .material-row .material-price { grid-column: 1; }
  .material-subtotal { grid-column: 1; grid-row: auto; }
  .remove-material { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; }
  .orders-grid { grid-template-columns: 1fr; }
  .catalog-form { grid-template-columns: 1fr; }
  .tool-form { grid-template-columns: 1fr; }
  .tool-row { grid-template-columns: minmax(0, 1fr) 34px; }
  .catalog-item { grid-template-columns: minmax(0, 1fr) 34px; }
  .catalog-item > span { grid-column: 1; justify-self: start; }
  .order-item, .order-print-item { grid-template-columns: minmax(0, 1fr) 64px; }
  .report-fields.wide, .cost-preview.wide { grid-column: auto; }
  .cost-preview { grid-template-columns: 1fr 1fr; }
  .cost-preview .cost-total { grid-column: 1 / -1; }
  .report-dialog { width: 100%; max-width: none; }
  .report-sheet { padding: 23px 18px calc(22px + env(safe-area-inset-bottom)); }
  .report-meta { grid-template-columns: 1fr; }
  .signature-pad { height: 170px; }
  .signature-heading { align-items: stretch; flex-direction: column; }
  .photo-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media print {
  @page { margin: 13mm; }
  body * { visibility: hidden; }
  #reportDialog[open], #reportDialog[open] *,
  #orderDialog[open], #orderDialog[open] * { visibility: visible; }
  #reportDialog[open], #orderDialog[open] { position: absolute; inset: 0; width: 100%; max-height: none; margin: 0; box-shadow: none; }
  .report-sheet { padding: 0; }
  .no-print { display: none !important; }
  .report-section, .report-costs, .signature-section, .order-print-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .order-print-item { border-color: #cfd8d4; background: #fff; }
  .signature-section {
    padding-top: 10px;
    padding-bottom: 0;
  }
  .signature-section h3 { margin-bottom: 5px; }
  .signature-pad {
    width: var(--signature-print-width, 287px);
    max-width: 100%;
    height: auto;
    margin-right: auto;
    margin-left: auto;
    aspect-ratio: var(--signature-aspect, 3.5);
    border-style: solid;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .signature-pad > span { bottom: 13px; font-size: 12px; }
  .signature-pad::after { bottom: 27px; }
  .signature-date { margin-top: 4px !important; }
}
