/* =========================================================
   Construction Analytics — Modern Flat Design System
   Light + Dark themes, CSS variables
   ========================================================= */

:root {
  /* Light theme (default) */
  --bg: #f5f7fb;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-hover: #f1f5f9;

  --text: #0f172a;
  --text-2: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #1976d2;
  --accent-hover: #1565c0;
  --accent-soft: rgba(25, 118, 210, 0.08);
  --accent-soft-hover: rgba(25, 118, 210, 0.14);
  --on-accent: #ffffff;

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.10);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.10);
  --info: #06b6d4;
  --info-soft: rgba(6, 182, 212, 0.10);

  --kpi-1: linear-gradient(135deg, #4f7cff 0%, #1976d2 100%);
  --kpi-2: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --kpi-3: linear-gradient(135deg, #38bdf8 0%, #0891b2 100%);
  --kpi-4: linear-gradient(135deg, #fb7185 0%, #e11d48 100%);

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.05);
  --shadow-accent: 0 4px 14px rgba(25, 118, 210, 0.30);
  --shadow-accent-strong: 0 8px 22px rgba(25, 118, 210, 0.42);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --font-sans: 'Inter', 'Segoe UI', Tahoma, Arial, Helvetica, sans-serif;
  --duration: .18s;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* Dark theme */
html[data-theme="dark"] {
  --bg: #0b1220;
  --bg-elevated: #111a2c;
  --surface: #131d33;
  --surface-2: #18243d;
  --surface-hover: #1d2a47;

  --text: #f1f5f9;
  --text-2: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --border: #243049;
  --border-strong: #334155;

  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --accent-soft-hover: rgba(96, 165, 250, 0.22);
  --on-accent: #0b1220;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  --shadow-accent: 0 4px 14px rgba(96, 165, 250, 0.35);
  --shadow-accent-strong: 0 8px 22px rgba(96, 165, 250, 0.50);
}

/* =========================================================
   Reset / base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

a { color: var(--accent); text-decoration: none; transition: color var(--duration); }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 { color: var(--text); margin: 0 0 var(--space-3); font-weight: 700; line-height: 1.25; }
h1 { font-size: 24px; } h2 { font-size: 20px; } h3 { font-size: 17px; } h4 { font-size: 15px; }

p { margin: 0 0 var(--space-3); }

::placeholder { color: var(--text-faint); opacity: 1; }

/* Scrollbar (subtle) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* =========================================================
   Layout
   ========================================================= */
.app-shell { min-height: 100%; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: var(--space-5) var(--space-4); }
.container-narrow { max-width: 720px; }

.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row-flex { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* =========================================================
   Topbar (header)
   ========================================================= */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(8px);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-3) var(--space-4);
  max-width: 1280px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-accent);
  font-size: 16px;
}
.brand-name { font-size: 15px; line-height: 1.1; }
.brand-name small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 500; }

.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  transition: background var(--duration), color var(--duration);
}
.nav-item:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); }

/* User chip */
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 12.5px;
}
.user-chip strong { color: var(--text); font-weight: 600; }

/* Theme toggle */
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer;
  transition: background var(--duration), color var(--duration), transform var(--duration);
}
.theme-toggle:hover { background: var(--accent-soft); color: var(--accent); transform: translateY(-1px); }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun  { display: inline; }

/* Mobile menu */
.menu-toggle {
  display: none; width: 38px; height: 38px;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
  align-items: center; justify-content: center;
}
@media (max-width: 880px) {
  .menu-toggle { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding: var(--space-3) 0; gap: 4px; }
  .nav-item { padding: 10px 14px; }
  .topbar.is-open .nav { display: flex; }
  .topbar-inner { flex-wrap: wrap; }
}

/* =========================================================
   Cards
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration), border-color var(--duration);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-3);
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 0; }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* =========================================================
   Buttons (Modern Flat)
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  background: var(--accent); color: var(--on-accent);
  border: 1px solid transparent; border-radius: 10px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  line-height: 1.2; letter-spacing: .01em;
  cursor: pointer; user-select: none;
  text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-accent);
  transition: transform var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              background var(--duration) var(--ease),
              color var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
}
.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent-strong);
  text-decoration: none;
  color: var(--on-accent);
}
.btn:active { transform: translateY(0); box-shadow: var(--shadow-accent); }
.btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* Variants */
.btn-ghost {
  background: transparent; color: var(--accent);
  border-color: var(--border); box-shadow: none;
}
.btn-ghost:hover {
  background: var(--accent-soft); border-color: var(--accent-soft-hover);
  color: var(--accent); box-shadow: var(--shadow-sm);
}
.ua-period-active {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

.btn-secondary {
  background: var(--surface-2); color: var(--text-2);
  border-color: var(--border); box-shadow: none;
}
.btn-secondary:hover {
  background: var(--surface-hover); color: var(--text);
  border-color: var(--border-strong); box-shadow: var(--shadow-sm);
}

.btn-success {
  background: var(--success); color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.30);
}
.btn-success:hover { background: #059669; box-shadow: 0 8px 22px rgba(16, 185, 129, 0.42); color: #fff; }

.btn-danger {
  background: var(--danger); color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.30);
}
.btn-danger:hover { background: #dc2626; box-shadow: 0 8px 22px rgba(239, 68, 68, 0.42); color: #fff; }

.btn-warning {
  background: var(--warning); color: #1f1500;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.30);
}
.btn-warning:hover { background: #d97706; color: #1f1500; box-shadow: 0 8px 22px rgba(245, 158, 11, 0.42); }

/* Sizes */
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block, .btn-full { width: 100%; }

/* Icon-only */
.btn-icon { padding: 9px; width: 38px; height: 38px; border-radius: 10px; }

/* =========================================================
   Forms
   ========================================================= */
.input, .form-input,
input[type="text"], input[type="number"], input[type="password"],
input[type="email"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 14px;
  transition: border-color var(--duration), box-shadow var(--duration), background var(--duration);
}
.input:focus, .form-input:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 90px; resize: vertical; }
input[type="file"] {
  padding: 8px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
label { display: inline-block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }

.field { display: flex; flex-direction: column; margin-bottom: var(--space-3); }

/* =========================================================
   Tables
   ========================================================= */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.table {
  width: 100%; border-collapse: collapse; background: var(--surface); color: var(--text);
}
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-2);
  font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em;
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table-sm thead th, .table-sm tbody td { padding: 7px 10px; font-size: 13px; }

/* =========================================================
   KPI Cards
   ========================================================= */
.kpi {
  position: relative;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  color: #fff;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--duration), box-shadow var(--duration);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi .kpi-label { font-size: 12.5px; opacity: .92; font-weight: 500; letter-spacing: .02em; text-transform: uppercase; }
.kpi .kpi-value { font-size: 28px; font-weight: 800; line-height: 1.1; margin-top: 6px; }
.kpi .kpi-sub { font-size: 12px; opacity: .85; margin-top: 4px; }
.kpi-1 { background: var(--kpi-1); }
.kpi-2 { background: var(--kpi-2); }
.kpi-3 { background: var(--kpi-3); }
.kpi-4 { background: var(--kpi-4); }

/* =========================================================
   Badges / chips
   ========================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge-primary  { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-success  { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning  { background: var(--warning-soft); color: #b45309; border-color: transparent; }
.badge-danger   { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info     { background: var(--info-soft); color: var(--info); border-color: transparent; }
html[data-theme="dark"] .badge-warning { color: var(--warning); }

.status-badge { display: inline-flex; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; }
.status-new        { background: var(--info-soft); color: var(--info); }
.status-sent       { background: var(--info-soft); color: var(--info); }
.status-inprogress { background: var(--warning-soft); color: #b45309; }
.status-done       { background: var(--success-soft); color: var(--success); }
.status-checked    { background: var(--success-soft); color: var(--success); }
.status-rejected   { background: var(--danger-soft); color: var(--danger); }
html[data-theme="dark"] .status-inprogress { color: var(--warning); }

/* =========================================================
   Modal
   ========================================================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, .55);
  display: none;
  align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px);
  animation: fadeIn .18s ease both;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}
.modal-backdrop.is-open { display: flex; }
.modal-box {
  width: 100%; max-width: 880px;
  background: var(--surface); color: var(--text);
  border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-4); max-height: 92vh; overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .22s var(--ease) both;
}
@media (min-width: 640px) {
  .modal-box { border-radius: var(--radius-lg); }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-3);
  padding-bottom: var(--space-3); border-bottom: 1px solid var(--border);
}
.modal-close {
  background: transparent; border: 0; color: var(--text-muted);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 18px;
  transition: background var(--duration), color var(--duration);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   Photos / thumbnails
   ========================================================= */
.thumb-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.thumb-list img, .thumb {
  width: 80px; height: 80px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; transition: transform var(--duration);
}
.thumb-list img:hover, .thumb:hover { transform: scale(1.04); }

.photos { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.photos img {
  width: 120px; height: 120px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; transition: transform var(--duration);
}
.photos img:hover { transform: scale(1.04); }

/* =========================================================
   Auth box (login)
   ========================================================= */
.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 10% 10%, var(--accent-soft), transparent 60%),
    radial-gradient(800px 400px at 90% 90%, var(--accent-soft), transparent 60%),
    var(--bg);
  padding: var(--space-4);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); color: var(--text);
  padding: var(--space-5); border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.auth-card .brand { justify-content: center; margin-bottom: var(--space-4); }
.auth-error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: var(--radius-sm); margin-top: var(--space-3); font-size: 13px; }

/* =========================================================
   Utilities
   ========================================================= */
.small { font-size: 12.5px; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); } .mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); }

.divider { height: 1px; background: var(--border); margin: var(--space-3) 0; border: 0; }

/* Chart cards */
.chart-card { padding: var(--space-3); }
.chart-card canvas { max-height: 240px !important; }

/* Footer */
.footer {
  margin-top: auto;
  padding: var(--space-4);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* =========================================================
   view.php — New record detail components
   ========================================================= */

/* ---- Chips (title row) ---- */
.chips-row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:10px 0 4px; }
.chip {
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 10px; border-radius:var(--radius-pill);
  background:var(--surface-2); border:1px solid var(--border);
  font-size:13px; color:var(--text-2); white-space:nowrap;
}

/* ---- Progress card ---- */
.progress-card { background:linear-gradient(135deg,#1d4ed8 0%,#2563eb 100%); color:#fff; }
.progress-card * { color:#fff !important; border-color:rgba(255,255,255,.25) !important; }
.progress-card label { opacity:.75; font-size:11px; text-transform:uppercase; letter-spacing:.6px; }
.progress-floor-num { font-size:42px; font-weight:800; line-height:1; }
.progress-floor-total { font-size:18px; font-weight:600; opacity:.8; }
.progress-bar { width:100%; height:6px; background:rgba(255,255,255,.25);
                border-radius:var(--radius-pill); overflow:hidden; margin:10px 0 14px; border:0 !important; }
.progress-bar > span { display:block; height:100%; background:#fff; border-radius:inherit; min-width:2px; }
.progress-dates { display:flex; justify-content:space-between; font-size:12px; opacity:.8; }

/* ---- Params table ---- */
.params-table { width:100%; border-collapse:collapse; }
.params-table tr td { padding:7px 0; border-bottom:1px solid var(--border); font-size:14px; vertical-align:middle; }
.params-table tr:last-child td { border-bottom:0; }
.params-table td:first-child { color:var(--text-muted); width:52%; }
.params-table td:last-child { color:var(--text); font-weight:500; text-align:right; }
.params-section-title { font-size:13px; font-weight:700; color:var(--text); padding:14px 0 4px; margin-top:2px; border-top:1px solid var(--border); }
.params-sup-share { font-weight:400; color:var(--text-muted); }

/* ---- Timeline ---- */
.timeline { display:flex; flex-direction:column; gap:14px; }
.timeline-item { display:flex; gap:10px; align-items:flex-start; }
.tl-icon {
  width:26px; height:26px; border-radius:50%; flex-shrink:0;
  background:var(--surface-2); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-size:13px; color:var(--text-2);
}
.tl-body { display:flex; flex-direction:column; gap:2px; padding-top:2px; }
.tl-body strong { font-size:14px; color:var(--text); font-weight:600; }
.tl-body span   { font-size:12px; color:var(--text-muted); }

/* ---- Mini-map ---- */
.mini-map { height:200px; border-radius:var(--radius); overflow:hidden; border:1px solid var(--border); }

/* ---- Dropdown menu (…) ---- */
.dropdown { position:relative; display:inline-block; }
.dropdown-menu {
  position:absolute; right:0; top:calc(100% + 6px); min-width:190px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--shadow-lg);
  padding:6px; z-index:80; display:none;
}
.dropdown.is-open .dropdown-menu { display:block; }
.dropdown-menu a,
.dropdown-menu button {
  display:flex; align-items:center; gap:8px; width:100%;
  padding:8px 10px; border-radius:var(--radius-sm);
  text-align:left; color:var(--text); background:transparent;
  border:0; cursor:pointer; font-size:14px; text-decoration:none;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background:var(--surface-2); }
.dropdown-menu .dd-danger { color:var(--danger) !important; }

/* ---- Photo gallery (main + thumbs) ---- */
.photo-main-wrap { position:relative; border-radius:var(--radius); overflow:hidden;
                   background:var(--surface-2); aspect-ratio:16/9; }
.photo-main-wrap img { width:100%; height:100%; object-fit:cover; display:block; }
.photo-main-label {
  position:absolute; bottom:10px; left:10px;
  background:rgba(0,0,0,.55); color:#fff; padding:3px 10px;
  border-radius:var(--radius-sm); font-size:12px; backdrop-filter:blur(4px);
}
.photo-thumbs-row { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:8px; }
.photo-thumbs-row a { display:block; border-radius:var(--radius-sm); overflow:hidden;
                      aspect-ratio:16/9; background:var(--surface-2); }
.photo-thumbs-row a img { width:100%; height:100%; object-fit:cover; display:block; transition:opacity .15s; }
.photo-thumbs-row a:hover img { opacity:.8; }

/* ---- Пустое состояние фото ---- */
.photo-empty-wrap {
  border-radius:var(--radius);
  padding:36px 20px 32px;
  display:flex; align-items:center; justify-content:center;
  flex-direction:column; gap:12px; text-align:center;
  background:linear-gradient(145deg, #c8d8f8 0%, #aec4f5 55%, #bccef8 100%);
  color:#3d5a96;
  border:none;
}
.photo-empty-wrap svg { opacity:.65; color:#3d5a96; }
.photo-empty-wrap span { font-size:13px; font-weight:600; letter-spacing:.01em; }
.photo-thumbs-skel { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:8px; }
.photo-thumb-ph {
  border-radius:var(--radius-sm); aspect-ratio:16/9;
  border:none;
}
.photo-thumb-ph:nth-child(1) { background:linear-gradient(135deg,#f7c84a 0%,#f0a020 100%); }
.photo-thumb-ph:nth-child(2) { background:linear-gradient(135deg,#5ecf8c 0%,#2dab62 100%); }
.photo-thumb-ph:nth-child(3) { background:linear-gradient(135deg,#c28ef5 0%,#9b5de5 100%); }

/* ---- Exif collapsible ---- */
#exifBlock { display:none; }
#exifBlock.is-open { display:block; }

/* ---- View page header ---- */
.view-page-header {
  display:flex; justify-content:space-between; align-items:flex-start;
  flex-wrap:wrap; gap:12px; margin-bottom:20px;
}
.view-page-header h1 { margin:6px 0 0; font-size:clamp(20px,3vw,28px); }
.view-actions { display:flex; align-items:center; gap:8px; flex-shrink:0; }

/* =========================================================
   Dashboard 2.0 — hero / kpi-mini / donut / lists
   ========================================================= */

/* ---- HERO cards ---- */
.hero-card { position:relative; padding:24px; min-height:170px; }
.hero-card .hero-icon {
  position:absolute; top:18px; right:18px;
  width:42px; height:42px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  font-size:22px; background:var(--accent-soft);
}
.hero-leader .hero-icon { background:rgba(16,185,129,0.16); }
.hero-mat    .hero-icon { background:rgba(96,165,250,0.16); }
.hero-pot    .hero-icon { background:rgba(245,158,11,0.16); }
.hero-tag {
  font-size:11px; font-weight:700; letter-spacing:0.08em;
  color:var(--text-2); margin-bottom:14px;
}
.hero-value { font-size:34px; font-weight:800; line-height:1; margin-bottom:10px; color:var(--text); }
.hero-text  { font-size:14px; color:var(--text-2); line-height:1.5; }
.hero-text strong { color:var(--text); }

/* ---- KPI mini ---- */
.kpi-mini { padding:16px 18px; }
.kpi-mini-label { font-size:12px; color:var(--text-2); margin-bottom:6px; }
.kpi-mini-value { font-size:28px; font-weight:800; line-height:1; margin-bottom:8px; color:var(--text); }
.kpi-mini-delta { font-size:12px; font-weight:600; }
.kpi-mini-delta.up   { color:#10b981; }
.kpi-mini-delta.down { color:#ef4444; }
.kpi-mini canvas.spark { width:80px !important; height:32px !important; }

/* ---- Donut ---- */
.donut-wrap { position:relative; width:180px; height:180px; flex-shrink:0; }
.donut-center {
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  pointer-events:none;
}
.donut-pct  { font-size:24px; font-weight:800; color:var(--text); }
.donut-name { font-size:12px; color:var(--text-2); text-align:center; margin-top:2px; }

.supplier-legend {
  list-style:none; padding:0; margin:0;
  flex:1; min-width:160px;
}
.supplier-legend li {
  padding:7px 0; display:flex; align-items:center; gap:10px;
  font-size:14px; color:var(--text);
  border-bottom:1px solid var(--border);
}
.supplier-legend li:last-child { border-bottom:0; }
.supplier-legend .muted { margin-left:auto; font-weight:600; color:var(--text-2); }
.legend-dot {
  display:inline-block; width:10px; height:10px;
  border-radius:50%; flex-shrink:0;
}

/* ---- Last records / activity lists ---- */
.list-records, .list-activity { list-style:none; padding:0; margin:0; }
.list-records li {
  padding:12px 0; display:flex; justify-content:space-between;
  align-items:center; gap:8px; border-bottom:1px solid var(--border);
}
.list-records li:last-child { border-bottom:0; }
.record-name { font-weight:600; color:var(--accent); text-decoration:none; }
.record-name:hover { text-decoration:underline; }

.list-activity li {
  padding:12px 0; display:flex; align-items:center; gap:12px;
  border-bottom:1px solid var(--border); color:var(--text);
}
.list-activity li:last-child { border-bottom:0; }
.list-activity .big {
  margin-left:auto; font-size:22px; font-weight:800; color:var(--text);
}

/* ---- Chart card spacing ---- */
.chart-card .card-title { margin:0; font-size:15px; font-weight:600; }
.chart-card { padding:18px 20px; }

/* =========================================================
   Map page 2.0 — sidebar + hover popup
   ========================================================= */

.map-shell--with-sidebar {
  display:grid;
  grid-template-columns:280px 1fr;
  flex:1; min-height:0;
}
.map-sidebar {
  background:var(--surface);
  border-right:1px solid var(--border);
  padding:16px;
  overflow-y:auto;
  display:flex; flex-direction:column; gap:18px;
}
.map-sidebar-head {
  display:flex; justify-content:space-between; align-items:center;
}
.map-sidebar-head h3 { margin:0; font-size:16px; color:var(--text); }
.map-sidebar-section label.small {
  font-size:11px; color:var(--text-2);
  text-transform:uppercase; letter-spacing:0.06em;
  display:block; margin-bottom:8px; font-weight:600;
}
.map-sidebar-foot { margin-top:auto; padding-top:12px; border-top:1px solid var(--border); }

.filter-list {
  max-height:55vh; overflow-y:auto;
  display:flex; flex-direction:column; gap:2px;
  margin-top:6px; padding-right:4px;
}
.filter-row {
  display:flex; align-items:center; gap:8px;
  padding:7px 8px; border-radius:var(--radius-sm);
  cursor:pointer; font-size:14px; color:var(--text);
  transition:background var(--duration);
}
.filter-row:hover { background:var(--surface-hover); }
.filter-row input[type="checkbox"] { margin:0; cursor:pointer; flex-shrink:0; }
.filter-row .sup-name { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.filter-row .muted { font-size:12px; color:var(--text-muted); flex-shrink:0; }
.filter-all {
  background:var(--surface-2); border:1px solid var(--border);
  margin-bottom:6px; font-weight:600;
}
.sup-dot {
  width:11px; height:11px; border-radius:50%;
  flex-shrink:0; border:2px solid var(--surface);
  box-shadow:0 0 0 1px var(--border);
}

@media (max-width: 768px) {
  .map-shell--with-sidebar {
    grid-template-columns:1fr;
    grid-template-rows:auto 1fr;
  }
  .map-sidebar {
    max-height:240px;
    border-right:0; border-bottom:1px solid var(--border);
  }
  .filter-list { max-height:140px; }
}

/* =========================================================
   form.php — Accordion / mobile-first blocks
   ========================================================= */

.form-page { max-width: 700px; margin: 0 auto; padding: var(--space-3) var(--space-3) var(--space-6); }

/* Accordion block */
.acc-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration);
}
.acc-block + .acc-block { margin-top: 10px; }
.acc-block.is-open { box-shadow: var(--shadow); }

.acc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px;
  cursor: pointer; user-select: none;
  background: var(--surface);
  transition: background var(--duration);
}
.acc-head:hover { background: var(--surface-hover); }
.acc-block.is-open .acc-head { border-bottom: 1px solid var(--border); }

.acc-icon { font-size: 20px; flex-shrink: 0; }
.acc-title { flex: 1; font-size: 15px; font-weight: 700; color: var(--text); }
.acc-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.acc-chevron {
  flex-shrink: 0; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 14px;
  transition: transform var(--duration), background var(--duration);
}
.acc-block.is-open .acc-chevron { transform: rotate(180deg); background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.acc-body { display: none; padding: 16px; }
.acc-block.is-open .acc-body { display: block; }

/* Volume summary row inside accordion */
.vol-row {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.vol-box {
  flex: 1; min-width: 130px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.vol-box-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.vol-box-value { font-size: 22px; font-weight: 800; color: var(--text); }
.vol-box-unit  { font-size: 11px; color: var(--text-muted); }

/* Supplier row */
.supplier-row {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px;
}
.supplier-row-head {
  display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap;
}
.supplier-row-head .field { flex: 1; min-width: 140px; margin-bottom: 0; }
.supplier-row-head .field-share { flex: 0 0 80px; }
.supplier-row-head .btn-icon-del {
  flex-shrink: 0; width: 34px; height: 36px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center;
  transition: background var(--duration), color var(--duration);
  align-self: flex-end; margin-bottom: 0;
}
.supplier-row-head .btn-icon-del:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* Feedback inside supplier row */
.supplier-feedback { margin-top: 10px; }
.feedback-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--accent); cursor: pointer; font-weight: 600;
  background: none; border: none; padding: 0;
}
.feedback-toggle:hover { text-decoration: underline; }
.feedback-table { margin-top: 8px; display: none; }
.feedback-table.is-open { display: block; }
.fb-grid {
  display: flex; flex-direction: column; gap: 6px;
}
.fb-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 8px; align-items: center; font-size: 13px;
}
.fb-row label { color: var(--text-2); cursor: default; margin: 0; font-weight: 400; }
.fb-row .fb-opt { display: flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; font-size: 12px; }
.fb-row .fb-opt input { margin: 0; cursor: pointer; }

/* Material block (block 3+) */
.mat-block {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px;
  position: relative;
}
.mat-block-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mat-block-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mat-block-title { font-size: 14px; font-weight: 700; color: var(--text); flex: 1; }
.mat-block-del {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: var(--radius-sm); padding: 4px 10px; cursor: pointer; font-size: 13px;
  transition: background var(--duration), color var(--duration);
}
.mat-block-del:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* Required star */
.req { color: var(--danger); }

/* GPS status row */
.gps-row { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.gps-row .input-coords { max-width: 170px; font-family: monospace; font-size: 13px; }
@media (max-width: 480px) {
  .gps-row .input-coords { max-width: 100%; }
}

/* Share counter */
.share-counter {
  font-size: 12.5px; font-weight: 600;
  margin: 6px 0 8px; min-height: 16px;
  transition: color var(--duration);
}
.share-counter:empty { display: none; }
.share-counter.ok  { color: var(--success); }
.share-counter.err { color: var(--danger); }

/* Submit bar */
.submit-bar {
  position: sticky; bottom: 0; z-index: 20;
  background: var(--bg-elevated); border-top: 1px solid var(--border);
  padding: 12px 16px; display: flex; gap: 10px; align-items: center;
  margin: 0 calc(-1 * var(--space-3));
}
@media (max-width: 480px) {
  .submit-bar { flex-direction: column; }
  .submit-bar .btn { width: 100%; }
}

/* ---- Map popup (hover/click) ---- */
.map-popup .popup-title {
  font-weight:700; font-size:14px; color:var(--text); margin-bottom:2px;
}
.map-popup .popup-addr {
  color:var(--text-2); font-size:12px; margin-bottom:8px;
}
.map-popup .popup-grid {
  display:flex; flex-direction:column; gap:5px;
  font-size:12px; border-top:1px solid var(--border); padding-top:8px;
}
.map-popup .popup-grid > div {
  display:flex; justify-content:space-between; gap:12px;
}
.map-popup .popup-grid span { color:var(--text-2); }
.map-popup .popup-grid b { color:var(--text); font-weight:600; text-align:right; }
.map-popup .popup-link {
  display:inline-block; margin-top:10px;
  font-weight:600; color:var(--accent); font-size:13px;
}

/* =========================================================
   Dashboard filter bar
   ========================================================= */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.flt-group { display: flex; flex-direction: column; gap: 4px; }
.flt-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.flt-input { height: 36px; padding: 0 10px; font-size: 13px; border-radius: var(--radius-sm); min-width: 140px; width: auto; }
.flt-actions { display: flex; gap: 8px; align-items: flex-end; margin-left: auto; }

/* Multiselect */
.multisel-wrap { position: relative; }
.multisel-trigger {
  height: 36px; padding: 0 10px; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  cursor: pointer; white-space: nowrap; min-width: 160px;
  transition: border-color var(--duration);
}
.multisel-trigger:hover { border-color: var(--accent); }
.multisel-trigger.is-open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.multisel-arrow { margin-left: auto; transition: transform var(--duration); }
.multisel-trigger.is-open .multisel-arrow { transform: rotate(180deg); }
.multisel-list {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 100;
  min-width: 180px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px;
}
.multisel-list.is-open { display: block; }
.multisel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text); cursor: pointer;
  transition: background var(--duration);
}
.multisel-item:hover { background: var(--surface-2); }
.multisel-item input { margin: 0; cursor: pointer; }

/* Active filters badge */
.flt-active-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-muted);
  background: var(--accent-soft); border: 1px solid var(--accent-soft-hover);
  border-radius: var(--radius-sm); padding: 7px 12px;
}
.flt-active-bar svg { flex-shrink: 0; color: var(--accent); }
.flt-active-bar strong { color: var(--text); }

/* Sparkline wrapper — fixes Chart.js growing to full card height */
.spark-wrap { height: 44px; position: relative; margin-top: 10px; overflow: hidden; }

/* Supplier KPI mid-cards */
.kpi-sup { padding: 20px 22px; border-left: 4px solid var(--accent); }
.kpi-sup-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 8px; }
.kpi-sup-value { font-size: 32px; font-weight: 800; line-height: 1; color: var(--text); margin-bottom: 6px; }
.kpi-sup-sub { font-size: 12px; color: var(--text-muted); }
.kpi-sup-share { border-left-color: #10b981; }
.kpi-sup-pot    { border-left-color: #f59e0b; }

@media (max-width: 640px) {
  .filter-bar { flex-direction: column; }
  .flt-actions { margin-left: 0; }
  .flt-input, .multisel-trigger { min-width: 100%; }
}

/* Complex blocks (жилой комплекс) */
.complex-block-row {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px;
}
.complex-block-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px;
}
.complex-block-num {
  font-size: 13px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .5px;
}

/* Complex progress (view.php) */
.complex-progress-block { margin-bottom: 20px; }
.complex-progress-block:last-child { margin-bottom: 0; }
.complex-progress-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; opacity: .85; margin-bottom: 4px;
}
.complex-progress-block .progress-floor-num { font-size: 28px; }
.complex-progress-block .progress-floor-total { font-size: 14px; }
