﻿:root {
  --navy: #0f1e36;
  --navy-2: #1a2f4e;
  --blue: #2f6fed;
  --blue-soft: #eaf1ff;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e3e9f2;
  --text: #1d2a3a;
  --muted: #6b7a8c;
  --ok: #16865b;
  --warn: #b36a00;
  --danger: #c33c48;
  --shadow-sm: 0 1px 2px rgba(15,30,54,.04), 0 1px 3px rgba(15,30,54,.06);
  --shadow-md: 0 4px 12px rgba(15,30,54,.06), 0 2px 4px rgba(15,30,54,.04);
  --shadow-lg: 0 12px 32px rgba(15,30,54,.12), 0 4px 8px rgba(15,30,54,.06);
  --radius: 12px;
  --radius-sm: 8px;
  --water:#d8efff; --pumps:#eadcff; --electric:#fff0c7; --sewer:#dff4e6;
  --fire:#ffdfe2; --heat:#ffe3d0; --building:#e7e9ff; --territory:#e3f3d7;
  --transport:#eee3d3; --telecom:#e2e6eb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 22px 32px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 4px 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.eyebrow {
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #80a9df;
  font-weight: 600;
}
.muted { color: #b8c7d8; font-size: 12.5px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.mode-badge {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  color: #ffd89a;
}

.layout { display: flex; min-height: calc(100vh - 86px); }
.sidebar {
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 14px 4px;
  font-weight: 600;
}
.nav {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .18s ease;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav:hover { background: var(--blue-soft); color: var(--blue); }
.nav.active {
  background: linear-gradient(90deg, var(--blue-soft), transparent);
  color: var(--blue);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--blue);
}
.sidebar-foot {
  margin-top: auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.content { flex: 1; padding: 28px 32px; max-width: 1600px; margin: auto; width: 100%; }
.page { display: none; animation: fadeIn .3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head h2 {
  margin: 2px 0 6px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.inline-date {
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.inline-date:hover { background: var(--blue-soft); }

.button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all .18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.button.primary {
  background: linear-gradient(135deg, var(--blue), #4a85f5);
  color: #fff;
  box-shadow: 0 2px 6px rgba(47,111,237,.3);
}
.button.primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(47,111,237,.4); }
.button.secondary { background: #eef2f8; color: #263a55; }
.button.secondary:hover { background: #e3e9f2; }
.button.ghost {
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,.15);
}
.button.ghost:hover { background: rgba(255,255,255,.14); }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: all .2s ease;
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--blue-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  flex: none;
}
.kpi-body { flex: 1; min-width: 0; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.kpi .label { color: var(--muted); font-size: 12px; margin-bottom: 2px; }

.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 16px; font-size: 15px; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-head h3 { margin: 0; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select,
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  width: 100%;
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.toolbar input { max-width: 420px; }
.toolbar select { max-width: 220px; }
.toolbar input:focus, .toolbar select:focus,
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,111,237,.12);
}

.table-wrap {
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
table { border-collapse: collapse; width: 100%; min-width: 800px; }
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}
th {
  background: #f7f9fc;
  color: #596b80;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
tr:last-child td { border-bottom: 0; }
tr { transition: background .15s; }
tbody tr:hover { background: #fafbfd; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.status.ok { background: #dcf5e9; color: var(--ok); }
.status.warn { background: #fff0cb; color: var(--warn); }
.status.danger { background: #ffe0e2; color: var(--danger); }
.status.neutral { background: #e9eef5; color: #51647a; }

.cat-W { background: var(--water); color: #1b5a85; }
.cat-P { background: var(--pumps); color: #5a3a8a; }
.cat-E { background: var(--electric); color: #7a5a10; }
.cat-S { background: var(--sewer); color: #2d6a45; }
.cat-F { background: var(--fire); color: #8a2a32; }
.cat-H { background: var(--heat); color: #8a4a20; }
.cat-B { background: var(--building); color: #3a3f8a; }
.cat-G { background: var(--territory); color: #3a6a25; }
.cat-T { background: var(--transport); color: #6a4a25; }
.cat-C { background: var(--telecom); color: #4a5560; }

tr.cat-W td:first-child { box-shadow: inset 3px 0 0 #55aee8; }
tr.cat-P td:first-child { box-shadow: inset 3px 0 0 #a375e5; }
tr.cat-E td:first-child { box-shadow: inset 3px 0 0 #e7b84e; }
tr.cat-S td:first-child { box-shadow: inset 3px 0 0 #56ae75; }
tr.cat-F td:first-child { box-shadow: inset 3px 0 0 #df6570; }
tr.cat-H td:first-child { box-shadow: inset 3px 0 0 #e98a55; }
tr.cat-B td:first-child { box-shadow: inset 3px 0 0 #787bd4; }
tr.cat-G td:first-child { box-shadow: inset 3px 0 0 #72aa50; }
tr.cat-T td:first-child { box-shadow: inset 3px 0 0 #9f7d56; }
tr.cat-C td:first-child { box-shadow: inset 3px 0 0 #76828f; }

.bars { display: grid; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 170px 1fr 30px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.bar-label { display: flex; align-items: center; gap: 8px; }
.bar-track { background: #edf1f6; height: 10px; border-radius: 10px; overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width .6s cubic-bezier(.2,.8,.2,1);
}
.bar-fill.cat-W { background: linear-gradient(90deg,#55aee8,#7ac0f0); }
.bar-fill.cat-P { background: linear-gradient(90deg,#a375e5,#b890ef); }
.bar-fill.cat-E { background: linear-gradient(90deg,#e7b84e,#f0cc70); }
.bar-fill.cat-S { background: linear-gradient(90deg,#56ae75,#78c090); }
.bar-fill.cat-F { background: linear-gradient(90deg,#df6570,#ea8890); }
.bar-fill.cat-H { background: linear-gradient(90deg,#e98a55,#f0a575); }
.bar-fill.cat-B { background: linear-gradient(90deg,#787bd4,#9598e0); }
.bar-fill.cat-G { background: linear-gradient(90deg,#72aa50,#90c070); }
.bar-fill.cat-T { background: linear-gradient(90deg,#9f7d56,#b89570); }
.bar-fill.cat-C { background: linear-gradient(90deg,#76828f,#909aa5); }

.list-row {
  display: grid;
  grid-template-columns: auto 1fr 2fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.list-row:hover { background: #f7f9fc; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.req-num { color: var(--blue); font-weight: 600; }
.list-title { font-weight: 600; }
.list-text { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.link-button {
  background: none;
  border: 0;
  color: var(--blue);
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  padding: 4px 0;
}
.link-button.danger { color: var(--danger); }
.link-button:hover { text-decoration: underline; }
.auto-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 9px;
  background: linear-gradient(135deg, var(--blue), #4a85f5);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: .08em;
  font-weight: 700;
  vertical-align: middle;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,30,54,.5);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
  animation: fadeIn .2s ease;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--card);
  border-radius: 16px;
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 600; }
.icon-button {
  border: 0;
  background: #eef2f6;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 20px;
  cursor: pointer;
  transition: background .15s;
}
.icon-button:hover { background: #e3e9f2; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.field .req { color: var(--danger); }
.field textarea { min-height: 90px; resize: vertical; font-family: inherit; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.steps div {
  display: flex;
  gap: 12px;
  background: linear-gradient(135deg, #f6f8fb, #fff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  line-height: 1.5;
}
.steps b {
  background: linear-gradient(135deg, var(--blue), #4a85f5);
  color: #fff;
  border-radius: 50%;
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(47,111,237,.3);
}

.note {
  margin-top: 20px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fff7db, #fffbe8);
  color: #684d00;
  border-left: 4px solid #e2b845;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  transform: translateX(120%);
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
  z-index: 100;
}
.toast.show { transform: translateX(0); }
.toast-icon {
  width: 22px; height: 22px;
  background: var(--ok);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.empty { padding: 30px; color: var(--muted); text-align: center; font-style: italic; }
.small { font-size: 11.5px; }
.file-label { position: relative; overflow: hidden; cursor: pointer; }
.file-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.checkbox input { width: auto; accent-color: var(--blue); }
.hint-mini {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-two, .steps { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 18px 20px; }
  .layout { display: block; }
  .sidebar {
    width: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
    gap: 4px;
  }
  .nav-group { display: flex; gap: 4px; margin: 0; }
  .nav-group-title { display: none; }
  .sidebar-foot { display: none; }
  .content { padding: 18px; }
  .header-actions { flex-wrap: wrap; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
}
/* Inline Editing Styles */
.editing-row { background: #fffbe6 !important; border-left: 4px solid var(--warn); }
.inline-input {
  width: 100%; padding: 6px 8px; border: 1px solid #d0d7de; border-radius: 6px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
}
.inline-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(47,111,237,.15); }
.full-width { width: 100%; box-sizing: border-box; }
.mt-4 { margin-top: 4px; }
.small-btn { padding: 4px 8px; font-size: 11px; height: auto; }
.actions-cell { white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.status-select option[value="Принята"] { color: var(--ok); font-weight: bold; }
.status-select option[value="В работе"] { color: var(--warn); }
/* Photo Gallery Styles */
.photo-upload-area { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.photo-btn { font-size: 11px; padding: 4px 8px; }
.thumb-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.view-thumbs { justify-content: flex-start; }
.large-thumbs { gap: 8px; margin-bottom: 8px; }
.thumb-img {
  width: 48px; height: 48px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); cursor: pointer; transition: transform .15s;
}
.thumb-img:hover { transform: scale(1.1); border-color: var(--blue); box-shadow: 0 2px 8px rgba(47,111,237,.2); }
.large-thumbs .thumb-img { width: 80px; height: 80px; }

/* Photo Viewer Modal */
#photoViewerModal {
  position: fixed; inset: 0; background: rgba(0,0,0,.85); backdrop-filter: blur(8px);
  display: grid; place-items: center; z-index: 200; animation: fadeIn .2s ease;
}
#photoViewerModal.hidden { display: none; }
.viewer-container {
  max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.viewer-container img {
  max-width: 90vw; max-height: 75vh; object-fit: contain; border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.viewer-info { color: #fff; font-size: 14px; font-weight: 500; }
.viewer-actions { display: flex; gap: 10px; }
.viewer-actions .button { font-size: 13px; }