:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #06142b;
  --muted: #64748b;
  --line: #dbe3ef;
  --brand: #2563eb;
  --brand-2: #8b5cf6;
  --warn: #b45309;
  --danger: #dc2626;
  --ok: #047857;
  --shadow: 0 10px 22px rgba(15, 23, 42, .08);
  font-family: Arial, sans-serif;
}

* { box-sizing: border-box; font-weight: 400 !important; }
[hidden] { display: none !important; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
b, strong, h1, h2, h3, h4, h5, h6 { font-weight: 400 !important; }
button { cursor: pointer; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(125deg, rgba(11,111,133,.92), rgba(19,163,127,.86)),
    url("data:image/svg+xml,%3Csvg width='1200' height='800' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23fff' stroke-opacity='.16' stroke-width='2'%3E%3Cpath d='M0 120h1200M0 260h1200M0 420h1200M0 600h1200M160 0v800M360 0v800M620 0v800M920 0v800'/%3E%3C/g%3E%3C/svg%3E");
}
.login-card { width: min(440px, 100%); background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 32px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; }
.mark { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 900; }
.logo-mark { background: #eef2ff; overflow: hidden; }
.logo-mark img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.login-card h1 { margin: 24px 0 8px; font-size: 28px; }
.login-card p { margin: 0 0 24px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }
.sidebar { background: #1f2329; color: #e5e7eb; padding: 20px; display: flex; flex-direction: column; gap: 18px; border-right: 1px solid #2b3139; }
.sidebar-backdrop { display: none; }
.sidebar .brand { font-size: 19px; }
.sidebar .mark { background: #eef2ff; color: var(--brand); }
.nav { display: grid; gap: 6px; }
.nav button {
  border: 0; background: transparent; color: #d1d5db; text-align: left; padding: 11px 12px;
  border-radius: 8px; display: flex; gap: 10px; align-items: center;
  font-weight: 700 !important;
}
.nav button.active, .nav button:hover { background: #2b3139; color: #ffffff; }
.sidebar-footer { margin-top: auto; color: #9ca3af; font-size: 13px; }

.main { min-width: 0; }
.topbar {
  height: 72px; background: rgba(248,250,252,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 2;
}
.search { position: relative; flex: 1; max-width: 560px; }
.search input { width: 100%; padding-left: 42px; }
.search .icon { position: absolute; left: 14px; top: 10px; color: var(--muted); }
.search-results { position: absolute; top: 48px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 10px; display: none; z-index: 5; }
.search-results.show { display: block; }
.search-results a { display: block; padding: 8px; color: var(--ink); text-decoration: none; border-radius: 6px; }
.search-results a:hover { background: #edf7f4; }
.userbox { display: flex; align-items: center; gap: 12px; white-space: nowrap; }

.content { padding: 24px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head.compact-head { margin-bottom: 12px; }
h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 18px; }
.sub { color: var(--muted); margin-top: 5px; }
.period-control { width: 150px; text-align: left; }
.period-control input { min-height: 38px; }

.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.two { grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: 0 1px 1px rgba(16,24,39,.03);
}
.metric { display: flex; justify-content: space-between; gap: 10px; min-height: 88px; padding: 12px 14px; }
.metric-link { width: 100%; border: 1px solid var(--line); text-align: left; }
.metric-link:hover { border-color: #bfdbfe; box-shadow: 0 8px 20px rgba(37,99,235,.10); }
.metric b { font-size: 20px; display: block; margin-top: 6px; line-height: 1.15; }
.metric span { color: var(--muted); font-size: 12px; }
.metric .badge-icon { width: 30px; height: 30px; border-radius: 8px; background: #e6f6f1; color: var(--brand); display: grid; place-items: center; font-size: 13px; }
.cards .metric span,
.cards .metric b { font-weight: 700 !important; }
.urgent-alert {
  border: 2px solid #f59e0b;
  border-radius: 10px;
  overflow: hidden;
  background: #fffbeb;
}
.urgent-alert-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fef3c7;
  color: #7c2d12;
}
.urgent-alert-head b {
  flex: 1;
}
.urgent-toggle {
  border: 1px solid #f59e0b;
  background: #fff7ed;
  color: #9a3412;
  min-height: 30px;
  border-radius: 8px;
  padding: 5px 10px;
  box-shadow: none;
}
.urgent-alert.collapsed .urgent-alert-list {
  display: none;
}
.urgent-alert-list { display: grid; }
.urgent-alert-row {
  border: 0;
  border-top: 1px solid #fde68a;
  background: #fffbeb;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  text-align: left;
  color: var(--ink);
}
.urgent-alert-row:hover { background: #fef3c7; }
.urgent-clock { color: #f59e0b; font-size: 18px; }
.urgent-info b { display: block; margin-bottom: 2px; }
.urgent-info small { color: #9a3412; }

input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 42px; padding: 10px 12px; color: var(--ink);
  font-weight: 400;
}
select, option { font-weight: 400; }
.money-input-wrap {
  position: relative;
}
.money-input-wrap span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
}
.money-input-wrap input {
  padding-left: 42px;
}
.measure-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
}
.tier-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
textarea { min-height: 90px; resize: vertical; }
label { display: grid; gap: 6px; font-weight: 650; font-size: 13px; color: #344054; }
.form-grid { display: grid; column-gap: 16px; row-gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid + .form-grid { margin-top: 18px; }
.form-grid.form-top-3 { grid-template-columns: 2fr 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .discount-field {
  grid-column: 1 / -1;
  max-width: 180px;
}
.form-grid .final-total-field {
  grid-column: 1 / -1;
  max-width: 180px;
}
.order-item {
  display: grid;
  gap: 12px;
}
.order-item-summary {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
}
.order-item-summary-title {
  display: block;
  color: var(--ink);
}
.order-item-summary-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}
.order-item.compact {
  padding: 12px 14px;
}
.order-item.compact .order-item-summary {
  display: flex;
}
.order-item.compact .order-item-fields {
  display: none;
}
.order-item-delete {
  flex: 0 0 auto;
}
.edit-order-item {
  display: grid;
  gap: 12px;
}
.edit-order-item + .edit-order-item {
  margin-top: 12px;
}
.edit-order-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.service-picker {
  position: relative;
}
.service-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 236px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.service-suggestions.show {
  display: grid;
  gap: 4px;
}
.service-suggestions button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
}
.service-suggestions button:hover {
  background: #eef5ff;
}
.service-suggestions button.active {
  background: #eff6ff;
  color: var(--brand);
}
.service-suggestions small,
.service-suggestion-empty {
  color: var(--muted);
  font-size: 12px;
}
.service-suggestion-empty {
  padding: 10px;
}
.company-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.company-logo-box { display: grid; gap: 12px; align-content: start; }
.company-logo-preview {
  width: 180px;
  height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.company-logo-preview img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.company-logo-preview span { width: 64px; height: 64px; border-radius: 8px; display: grid; place-items: center; background: var(--brand); color: #fff; font-size: 24px; font-weight: 900; }
.logo-upload { font-size: 13px; }
.company-fields { min-width: 0; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.btn {
  border: 0; border-radius: 8px; padding: 10px 14px; background: var(--brand); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; min-height: 40px; text-decoration: none;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .18);
}
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: 0 3px 10px rgba(15,23,42,.05); }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--line); box-shadow: 0 3px 10px rgba(15,23,42,.05); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 7px 10px; min-height: 34px; font-size: 13px; }
.btn.whatsapp { background: #16a34a; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #edf2f7; color: #344054; box-shadow: 0 2px 7px rgba(15,23,42,.06); }
.pill.ok { background: #dcfce7; color: var(--ok); }
.pill.warn { background: #fef3c7; color: var(--warn); }
.pill.danger { background: #fee2e2; color: var(--danger); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.overdue { border-left: 4px solid var(--danger); }
.list { display: grid; gap: 10px; }
.list-item { padding: 12px; border: 1px solid var(--line); border-radius: 8px; display: flex; justify-content: space-between; gap: 12px; }
.header-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.segmented { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.segmented button { border: 0; border-radius: 7px; background: transparent; min-height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px; }
.segmented button.active { background: #f1f5f9; }
.order-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.order-summary-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; box-shadow: 0 3px 10px rgba(15,23,42,.05); }
.order-summary-card span { color: var(--muted); font-size: 13px; }
.order-summary-card b { display: block; margin-top: 6px; font-size: 24px; }
.order-summary-card.ok { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.order-summary-card.warn { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.order-summary-card.danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.entity-summary { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.order-filters { display: grid; grid-template-columns: minmax(0, 1fr) 176px; gap: 12px; margin-bottom: 22px; }
.order-search { position: relative; }
.order-search span { position: absolute; left: 13px; top: 11px; color: var(--muted); }
.order-search input { padding-left: 40px; }
.order-list { display: grid; gap: 12px; }
.service-order-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(15,23,42,.08);
  cursor: pointer;
}
.service-order-card:hover { border-color: #bfdbfe; box-shadow: 0 8px 20px rgba(37,99,235,.10); }
.order-card-main, .order-card-side { display: flex; align-items: center; gap: 12px; }
.order-card-main { min-width: 240px; }
.order-card-main b { display: block; margin-bottom: 3px; }
.order-card-main span { color: #475569; font-size: 13px; }
.order-card-main small { display: block; max-width: 620px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-card-description {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
}
.order-card-description span:last-child { overflow: hidden; text-overflow: ellipsis; }
.order-card-separator { width: 1px; height: 34px; background: var(--line); flex: 0 0 auto; }
.order-card-icon { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; background: #f1f5f9; color: #64748b; font-weight: 800; }
.order-clipboard-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.order-card-side strong { min-width: 94px; text-align: right; }
.entity-card { align-items: flex-start; }
.entity-card-side { justify-content: flex-end; flex-wrap: wrap; max-width: 58%; }
.icon-button,
.trash-button {
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #64748b;
  display: inline-grid;
  place-items: center;
  padding: 0;
  box-shadow: none;
}
.icon-button:hover,
.trash-button:hover { background: #f1f5f9; color: var(--danger); }
.whatsapp-status-line { display: flex; align-items: center; gap: 10px; margin: 10px 0 16px; flex-wrap: wrap; }
.qr-box { width: min(280px, 100%); padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.qr-box img { width: 100%; display: block; }
.template-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.template-row { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.template-row label { margin: 0; }
.template-row label span { display: block; margin-bottom: 8px; color: var(--ink); }
.template-row textarea { min-height: 118px; resize: vertical; }
.template-actions { justify-content: flex-end; margin-top: 14px; }
.pagination { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pagination-info {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  margin-right: 4px;
}
.page-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-width: 36px;
  min-height: 34px;
  padding: 6px 10px;
  box-shadow: none;
}
.page-button.active,
.page-button:hover {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}
.danger-text { color: var(--danger); }
.trash-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.order-detail-head { align-items: center; }
.order-detail-card { padding: 24px; }
.order-detail-top { display: flex; justify-content: space-between; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; }
.detail-status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-actions { justify-content: flex-end; }
.order-detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.order-detail-grid span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.order-detail-grid b { font-size: 16px; }
.detail-total { color: var(--brand); font-size: 20px !important; }
.detail-payment { margin-bottom: 18px; }
.detail-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.detail-table { min-width: 760px; }
.detail-table th { background: #f1f5f9; color: #020617; text-transform: none; font-size: 14px; letter-spacing: 0; }
.detail-table td:last-child, .detail-table th:last-child { text-align: right; }
.field-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.reference-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title-row h2 { margin: 0; }
.reference-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.reference-thumb {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.reference-thumb a { display: block; aspect-ratio: 4 / 3; background: #f8fafc; }
.reference-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.reference-thumb figcaption { display: grid; gap: 3px; padding: 9px 10px; }
.reference-thumb figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 13px; }
.reference-thumb figcaption small { color: var(--muted); font-size: 12px; }
.reference-delete { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.94); }
.reference-empty { border: 1px dashed var(--line); border-radius: 8px; padding: 16px; color: var(--muted); background: #f8fafc; }
.canvas-box { height: 280px; }
.dashboard-chart { padding: 24px; }
.dashboard-chart h2 { margin-bottom: 8px; font-size: 16px; }
.combo-chart { height: 270px; }
.dashboard-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
canvas { width: 100%; height: 100%; }
.chart-tooltip {
  position: fixed;
  z-index: 50;
  display: none;
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 12px;
}
.chart-tooltip.show { display: grid; gap: 4px; }
.chart-tooltip b { font-size: 13px; }
.chart-tooltip span { color: var(--muted); }
.reports-filter-grid {
  display: grid;
  grid-template-columns: 220px repeat(2, minmax(180px, 1fr)) minmax(240px, 1fr);
  gap: 12px;
  align-items: end;
}
.report-range { margin: 0; padding-bottom: 10px; }
.report-empty { padding: 24px 10px; text-align: center; }
.report-bars { display: grid; gap: 10px; }
.report-bar-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 110px;
  align-items: center;
  gap: 10px;
}
.report-bar-row span { color: var(--muted); font-size: 13px; }
.report-bar-track {
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.report-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #14b8a6);
}
.report-bar-row b { text-align: right; font-size: 13px; }
.report-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.report-status-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.report-status-item span { color: #334155; font-size: 13px; }
.report-status-item b { font-size: 20px; }
.report-finance-list { display: grid; gap: 8px; }
.report-finance-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}
.report-finance-list div:last-child { border-bottom: 0; padding-bottom: 0; }
.report-finance-list span { color: #64748b; font-size: 14px; }
.report-finance-list b.ok { color: var(--ok); }
.report-finance-list b.warn { color: var(--warn); }

dialog { width: min(860px, calc(100vw - 28px)); border: 0; border-radius: 8px; padding: 0; box-shadow: var(--shadow); }
dialog.confirm-dialog { width: min(430px, calc(100vw - 28px)); }
dialog::backdrop { background: rgba(16,24,39,.5); }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; max-height: 78vh; overflow: auto; }
.confirm-body p { margin: 0 0 18px; color: var(--text); line-height: 1.5; }
.close { border: 0; background: #eef2f7; border-radius: 8px; width: 36px; height: 36px; }

.mobile-menu { display: none; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 84vw); transform: translateX(-105%); transition: .2s; z-index: 20; overflow-y: auto; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; border: 0; background: rgba(15,23,42,.42); z-index: 15; }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .mobile-menu { display: inline-flex; }
  .cards, .two, .three, .four, .dashboard-charts, .order-summary, .order-detail-grid, .template-list { grid-template-columns: 1fr; }
  .reports-filter-grid,
  .report-status-grid,
  .report-bar-row { grid-template-columns: 1fr; }
  .report-range { padding-bottom: 0; }
  .report-bar-row b { text-align: left; }
  .period-control { width: 100%; }
  .topbar { height: auto; min-height: 64px; padding: 10px 14px; align-items: stretch; flex-wrap: wrap; gap: 10px; }
  .topbar .mobile-menu { flex: 0 0 auto; }
  .topbar .search { order: 3; flex: 1 0 100%; max-width: none; }
  .search-results { top: 46px; }
  .userbox { margin-left: auto; }
  .content { padding: 18px 14px; }
  .userbox span { display: none; }
  .order-filters { grid-template-columns: 1fr; }
  .company-layout { grid-template-columns: 1fr; }
  .company-logo-preview { width: 100%; max-width: 220px; }
  .service-order-card, .order-card-side, .order-detail-top { align-items: flex-start; }
  .service-order-card { display: grid; gap: 12px; padding: 14px; }
  .order-card-main { min-width: 0; }
  .order-card-description { white-space: normal; width: 100%; }
  .order-card-description span:last-child { white-space: normal; }
  .order-card-separator { display: none; }
  .order-card-side, .entity-card-side { flex-wrap: wrap; max-width: none; justify-content: flex-start; width: 100%; }
  .order-card-side strong { min-width: 0; width: 100%; text-align: left; }
  .order-card-main small { max-width: calc(100vw - 120px); }
  .detail-actions { justify-content: flex-start; width: 100%; }
  .detail-actions .btn { flex: 1 1 150px; }
  .pagination { justify-content: flex-start; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.form-top-3 { grid-template-columns: 1fr; }
  .measure-fields { grid-template-columns: 1fr; }
  .tier-row { grid-template-columns: 1fr; }
  .page-head { display: grid; }
  .page-head > div:last-child,
  .page-head .header-actions,
  .header-actions .btn { width: 100%; }
  .page-head .btn,
  .actions .btn { flex: 1 1 100%; }
  .actions { justify-content: stretch; }
  .btn { width: auto; }
  .order-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 76px; }
  .metric b { font-size: 18px; }
  .card, .panel { padding: 14px; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px; max-height: calc(100dvh - 84px); }
  dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  table { min-width: 680px; }
  th, td { padding: 10px; }
  .login-card { padding: 24px; }
  h1 { font-size: 24px; }
}
