/* ─── Design tokens (from task-planner.html palette) ────────────────────── */
:root {
  --bg:            #f7f6f2;
  --surface:       #ffffff;
  --card:          #ffffff;
  --input-bg:      #ffffff;
  --border:        #e6e4de;
  --text:          #1a1917;
  --muted:         #7a7670;
  --accent:        #01696f;
  --accent-l:      #e0f2f2;
  --red:           #a12c2c;
  --red-l:         #fde8e8;
  --yellow:        #d19900;
  --yellow-l:      #fff8dc;
  --green:         #437a22;
  --green-l:       #e8f5e1;
  --blue:          #1d5fa8;
  --blue-l:        #deeaf9;
  --orange:        #c05c00;
  --orange-l:      #fff0e0;
  --shadow:        0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg:     0 10px 30px rgba(0,0,0,.15);
  --radius:        10px;
  --ease:          cubic-bezier(.16,1,.3,1);
  --mark-cyan:     #33c5e4;
  --logo-wordmark: #121212;
}

[data-theme="dark"] {
  --bg:            #171614;
  --surface:       #211f1d;
  --card:          #2a2825;
  --input-bg:      #1e1c1a;
  --border:        #2e2c29;
  --text:          #f0ede8;
  --muted:         #8a8680;
  --accent:        #00a8b0;
  --accent-l:      #0d2f31;
  --red-l:         #2d1515;
  --yellow-l:      #2a2000;
  --green-l:       #1a2e0d;
  --blue-l:        #0d1e33;
  --orange-l:      #2a1800;
  --logo-wordmark: #ffffff;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Satoshi', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { font-family: 'Cabinet Grotesk', 'Satoshi', sans-serif; }
img, svg { display: block; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn { padding: 8px 18px; border-radius: 6px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, opacity .15s; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { opacity: .9; }
.btn-outline  { border: 1px solid var(--border); background: var(--surface); }
.btn-outline:hover  { background: var(--border); }
.btn-danger   { border: 1px solid var(--red); color: var(--red); }
.btn-danger:hover   { background: var(--red-l); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; }
.form-control { border: 1px solid var(--border); border-radius: 6px; padding: 9px 12px; background: var(--input-bg); color: var(--text); font-size: 14px; outline: none; transition: border-color .15s; }
.form-control:focus { border-color: var(--accent); }
.form-hint { font-size: 12px; color: var(--muted); }
.form-error { font-size: 12px; color: var(--red); min-height: 18px; }

/* ─── Alert banner ────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.alert-error  { background: var(--red-l);    color: var(--red); }
.alert-success { background: var(--green-l); color: var(--green); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); display: none; place-items: center; z-index: 1000; padding: 20px; }
.modal-overlay.active { display: grid; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-weight: 700; font-size: 17px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg); }

/* ─── Icon button ─────────────────────────────────────────────────────────── */
.icon-btn { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; border: 1px solid var(--border); transition: background .15s; }
.icon-btn:hover { background: var(--border); }

/* ─── Badge / chips ───────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-admin    { background: var(--accent-l); color: var(--accent); }
.badge-surveyor { background: var(--blue-l);   color: var(--blue);   }
.badge-manager  { background: var(--yellow-l); color: var(--yellow); }
.badge-installer { background: var(--green-l); color: var(--green);  }
.badge-foreman   { background: #f3e8f8; color: #7b3a9e; }
.badge-warehouse { background: #fde8dc; color: #c45c26; }

/* ─── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

/* Logo — идентичная стилистика call-analytics */
.logo {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.logo-mark {
  width: 44px; height: 44px;
  object-fit: contain; object-position: center;
  flex-shrink: 0; border-radius: 10px;
  border: 1px solid var(--border);
}
.logo-mark--fallback {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
}
.logo-sep {
  width: 2px; align-self: stretch;
  min-height: 38px; max-height: 44px;
  margin: 0 2px 0 0; flex-shrink: 0; border-radius: 1px;
  background: var(--mark-cyan);
}
.logo-text {
  display: flex; flex-direction: column; justify-content: center;
}
.logo-wordmark {
  font-family: 'Open Sans', 'Cabinet Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(0.78rem, 2.6vw, 0.95rem);
  letter-spacing: 0.05em;
  line-height: 1.02;
  text-transform: uppercase;
  color: var(--logo-wordmark);
  display: flex; flex-direction: column; gap: 1px;
}
.logo-w-line { display: block; white-space: nowrap; }
.logo-tagline {
  flex-shrink: 0; align-self: center;
  padding-left: 14px; border-left: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--muted);
  letter-spacing: 0.03em; line-height: 1.25; white-space: nowrap;
}

/* Глобальная навигация: Портал / (Аналитика) / (Задачи) */
.section-nav {
  display: flex;
  flex-direction: row;
  gap: 2px;
  align-items: center;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: background .15s, color .15s;
  text-decoration: none;
  line-height: 1;
}
.section-nav-item:hover:not(.section-nav-item--active) { background: var(--border); color: var(--text); }
.section-nav-item--active { background: var(--accent-l); color: var(--accent); pointer-events: none; }

/* Right controls */
.header-right { display: flex; flex-direction: row; align-items: center; gap: 10px; flex-shrink: 0; }
.user-chip { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-l); color: var(--accent); font-weight: 700; font-size: 12px; display: grid; place-items: center; }

/* Responsive header */
@media (max-width: 768px) {
  .logo-tagline { display: none; }
  .section-nav-item { padding: 6px 12px; font-size: 12px; }
}
@media (max-width: 520px) {
  .logo-text { display: none; }
  .logo-sep  { display: none; }
}

/* ─── Tabs ────────────────────────────────────────────────────────────────── */
/* Tabs bar: shadow line instead of border so the active-tab indicator (inset
   border-bottom) doesn't cause an overflow-y scrollbar. */
.tabs-bar {
  background: var(--surface);
  box-shadow: 0 2px 0 0 var(--border);
  padding: 0 20px;
  display: flex;
  gap: 0;
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── Content area ────────────────────────────────────────────────────────── */
.content-area { flex: 1; overflow: visible; padding: 24px 20px; }
.view-section { display: none; }
.view-section.active { display: block; }

/* ─── Table ───────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 8px 12px; color: var(--muted);
  font-weight: 600; border-bottom: 2px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
  background: var(--card);
  box-shadow: 0 1px 0 var(--border);
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* Table scroll wrapper — used by price list, materials, etc. */
.table-scroll-wrap {
  overflow: auto;
  max-height: calc(100vh - 230px);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Price list (Прайс-лист ЛОС): let the wide table grow to its natural width so
   the wrapper provides a horizontal scrollbar instead of squeezing columns. */
.pr-price-table {
  width: auto;
  min-width: 100%;
}
.pr-price-table th,
.pr-price-table td {
  white-space: nowrap;
}

/* Visibility toggle (eye) in the admin price list */
.pl-eye-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  padding: 2px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, opacity .15s;
}
.pl-eye-btn:hover { background: var(--border); }
.pl-eye-btn--off { color: var(--muted); opacity: .65; }

/* ─── Checkboxes (role picker) ────────────────────────────────────────────── */
.roles-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.role-check { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; transition: border-color .15s, background .15s; }
.role-check:hover { border-color: var(--accent); }
.role-check input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.role-check.checked { border-color: var(--accent); background: var(--accent-l); }

/* ─── Placeholder views ───────────────────────────────────────────────────── */
.placeholder-view { text-align: center; padding: 60px 20px; color: var(--muted); }
.placeholder-view .placeholder-icon { font-size: 48px; margin-bottom: 16px; }
.placeholder-view h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* ─── Admin sub-tab bar ───────────────────────────────────────────────────── */
.admin-subtab-bar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  margin-bottom: 20px;
}
.admin-subtab {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
  transition: color .15s, background .15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.admin-subtab:hover  { color: var(--text); background: var(--border); }
.admin-subtab.active { color: var(--accent); background: var(--accent-l); }
.admin-sub-content   { min-height: 300px; }

/* ─── Inline input (table cells) ─────────────────────────────────────────── */
.inline-input {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.inline-input:focus { outline: none; border-color: var(--accent); }
.inline-select {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
}

/* ─── Blocks editor layout ────────────────────────────────────────────────── */
.blocks-editor-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}
.blocks-editor-main { min-width: 0; }
.blocks-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.block-col {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}
.block-col-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.blocks-preview-panel {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--accent-l);
  position: sticky;
  top: 16px;
}

/* ─── Profile modal ──────────────────────────────────────────────────────── */
.profile-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-modal-box {
  background: #ffffff;
  color: #1a1917;
  border-radius: 14px;
  padding: 28px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 48px rgba(0,0,0,.28);
  position: relative;
}
[data-theme="dark"] .profile-modal-box {
  background: #2a2825;
  color: #f0ede8;
}
[data-theme="dark"] .profile-modal-box .form-control {
  background: #1e1c1a;
  color: #f0ede8;
  border-color: #3e3c39;
}
.profile-modal-box hr { border-color: #e6e4de; }
[data-theme="dark"] .profile-modal-box hr { border-color: #3e3c39; }
.profile-modal-box .close-btn { color: #7a7670; }
[data-theme="dark"] .profile-modal-box .close-btn { color: #8a8680; }

/* ─── Misc ────────────────────────────────────────────────────────────────── */
.loading-text { color: var(--muted); font-size: 13px; }
.form-control-sm { padding: 5px 9px; font-size: 12px; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .blocks-editor-layout { grid-template-columns: 1fr; }
  .blocks-preview-panel { position: static; }
}
@media (max-width: 700px) {
  .blocks-3col { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .content-area { padding: 16px 12px; }
  .data-table td, .data-table th { padding: 8px 8px; }
  .modal { max-width: 100%; }
}
