:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #181c23;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #1769ff;
  --primary-dark: #0f4fd1;
  --danger: #c62828;
  --success: #1d7a43;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }

:focus-visible { outline: 2px solid rgba(23, 105, 255, 0.45); outline-offset: 2px; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; border-radius: 12px; padding: 12px 16px; }
button.primary { background: var(--primary); color: white; }
button.primary:hover { background: var(--primary-dark); }
button.secondary { background: #e8eefc; color: #183b80; }
button.ghost { background: transparent; color: var(--text); }
button.small { padding: 8px 10px; }
button.icon-btn { width: 44px; height: 44px; padding: 0; font-size: 22px; }
.auth-overlay {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(135deg, #dee9ff, #f6f7fb 55%, #e9fff3);
}
.auth-card, .card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-card {
  width: min(420px, 100%); padding: 28px; display: grid; gap: 16px;
}
.auth-card label, .form-grid label, .line-form label, .inline-form label {
  display: grid; gap: 6px; font-size: 14px;
}
input, select, textarea, .input-like {
  border: 1px solid var(--line); border-radius: 12px; background: white; padding: 11px 12px;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\"%3E%3Cpath d=\"M2.25 4.5L6 8.25L9.75 4.5\" stroke=\"%23667085\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}
.form-error { min-height: 20px; color: var(--danger); font-size: 14px; }
.auth-badge { display: inline-flex; width: fit-content; padding: 6px 10px; border-radius: 999px; background: #edf3ff; color: #244a92; font-weight: 600; }
.shell { min-height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 24px; background: white; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 2px 0 0; font-size: 28px; }
.topbar-left, .topbar-actions, .toolbar-actions { display: flex; align-items: center; gap: 12px; }
.user-badge { display: grid; padding: 8px 12px; border-radius: 12px; background: #f7f9fd; font-size: 12px; }
.main-shell { padding: 20px 24px 24px; }
.view-panel { display: block; }
.view-toolbar {
  display: grid; gap: 16px; margin-bottom: 16px;
}
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab { background: #eef2f8; color: #314055; }
.tab.active { background: #dbe8ff; color: #1549ab; font-weight: 700; }
.search-input { min-width: 260px; }
.inline-checkbox, .form-grid label.inline-checkbox, .line-form label.inline-checkbox, .inline-form label.inline-checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.inline-checkbox input { margin: 0; }
.split-layout { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
.estimates-layout { grid-template-columns: 360px 1fr; }
.card { padding: 18px; }
.section-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.section-head.compact h2 { margin: 0 0 6px; font-size: 22px; }
.wrap-between { flex-wrap: wrap; }
.list { display: grid; gap: 10px; max-height: calc(100vh - 220px); overflow: auto; }
.list-item {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: white; display: grid; gap: 6px;
}
.list-item.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(23, 105, 255, 0.12); }
.list-item-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: #eef2f8; font-size: 12px; }
.badge.success { background: #e2f7e9; color: var(--success); }
.badge.warning { background: #fff3d9; color: #8a5600; }
.badge.danger { background: #fee7e7; color: var(--danger); }
.detail-pane { min-height: 600px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.related-block { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.related-block h3 { margin: 0 0 10px; font-size: 16px; }
.stack { display: grid; }
.gap-s { gap: 8px; }
.gap-m { gap: 12px; }
.no-wrap { flex-wrap: nowrap; }
.wrap { flex-wrap: wrap; }
.empty-state {
  min-height: 420px; display: grid; place-content: center; text-align: center; gap: 12px; color: var(--muted);
}
.menu-drawer {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); display: flex; justify-content: flex-end; z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity 0.24s ease;
}
.menu-drawer.is-open { opacity: 1; pointer-events: auto; }
.menu-drawer-card {
  width: min(320px, 92vw); background: white; padding: 18px; display: grid; align-content: start; gap: 14px; box-shadow: var(--shadow);
  transform: translateX(28px); transition: transform 0.24s ease;
}
.menu-drawer.is-open .menu-drawer-card { transform: translateX(0); }
.menu-header { display: flex; justify-content: space-between; align-items: center; }
.menu-link { text-align: left; background: #f3f6fb; width: min(220px, 100%); justify-self: start; padding: 18px 16px; }
.side-panel {
  position: fixed; top: 0; right: 0; width: min(460px, 100vw); height: 100vh; background: white; box-shadow: var(--shadow); z-index: 45;
  display: grid; grid-template-rows: auto 1fr; opacity: 0; pointer-events: none; transform: translateX(32px); transition: transform 0.24s ease, opacity 0.24s ease;
}
.side-panel.is-open { opacity: 1; pointer-events: auto; transform: translateX(0); }
.side-panel-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 18px; border-bottom: 1px solid var(--line); }
.side-panel-body { padding: 18px; overflow: auto; }
.estimate-search-block { display: grid; gap: 10px; }
.estimate-search-input { width: 100%; min-width: 0; }
.estimate-create-btn { width: fit-content; }
.estimate-status-filter { min-width: 170px; }
.estimate-filters-row { align-items: center; }
.line-form, .inline-form { display: grid; gap: 12px; }
.inline-form { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.inline-form button { min-height: 44px; }
.note-box { padding: 12px; border-radius: 12px; background: #f6f8fc; color: var(--muted); font-size: 14px; }
.estimate-groups { display: grid; gap: 18px; }
.estimate-section { border: 1px solid var(--line); border-radius: 18px; padding: 14px; background: #fbfcff; }
.estimate-section h3 { margin: 0; }
.estimate-subtitle { margin: 10px 0 8px; color: var(--muted); font-weight: 700; }
.table-like { width: 100%; border-collapse: collapse; }
.table-like th, .table-like td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; font-size: 14px; vertical-align: top; }
.table-like th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.line-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.summary-row { display: flex; justify-content: flex-end; margin-top: 10px; font-weight: 700; }
@media (max-width: 1100px) {
  .split-layout, .estimates-layout { grid-template-columns: 1fr; }
  .detail-pane { min-height: 0; }
  .list { max-height: none; }
}
@media (max-width: 760px) {
  .topbar { padding: 14px 16px; }
  .main-shell { padding: 16px; }
  .form-grid.two, .inline-form { grid-template-columns: 1fr; }
  .search-input { min-width: 0; width: 100%; }
  .toolbar-actions { flex-wrap: wrap; }
  .menu-link { width: 100%; }
  .estimate-create-btn { width: 100%; }
}


.inline-warning {
  margin-top: -6px;
  margin-bottom: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff4d6;
  color: #7a5a00;
  font-size: 14px;
  line-height: 1.35;
}
