/* FieldPulse design system — tokens, layout, components. No build step required. */
:root {
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
  --brand-line: color-mix(in srgb, var(--brand) 28%, white);
  --brand-dark: color-mix(in srgb, var(--brand) 82%, black);
  --ink: #0b1220;
  --ink-2: #121a2b;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e6e8ec;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ok: #15803d; --ok-bg: #e8f6ec;
  --warn: #b45309; --warn-bg: #fdf1dc;
  --bad: #b91c1c; --bad-bg: #fde9e9;
  --info: #1d4ed8; --info-bg: #e7efff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar: 252px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-sm { width: 15px; height: 15px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .18s ease; }
.app.collapsed { --sidebar: 72px; }
.sidebar { background: var(--ink); color: #c7cddb; position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden auto; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; flex: none; }
.brand-mark .ic { stroke: #fff; width: 17px; height: 17px; }
.org-chip { margin: 0 14px 10px; padding: 9px 11px; border-radius: 9px; background: var(--ink-2); font-size: 12.5px; color: #9aa3b6; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.org-chip { white-space: normal; flex: none; }
.org-chip b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: #e8ebf3; font-weight: 600; font-size: 13.5px; line-height: 1.3; overflow: hidden; word-break: break-word; }
.org-chip span { display: block; margin-top: 2px; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { padding: 6px 10px 18px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #667089; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 8px; color: #c7cddb; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.nav a.active { background: color-mix(in srgb, var(--brand) 26%, var(--ink)); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
@media (min-width: 961px) { .collapsed .brand-text, .collapsed .nav a span, .collapsed .nav-label, .collapsed .org-chip { display: none; } }
@media (min-width: 961px) { .collapsed .nav a { justify-content: center; } }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(245, 246, 248, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 24px; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: #f0f2f5; }
.search { flex: 1; max-width: 420px; position: relative; }
.search .ic { position: absolute; left: 11px; top: 9px; color: var(--faint); }
.search input { width: 100%; padding-left: 36px; height: 36px; }
.spacer { flex: 1; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 12px 3px 3px; cursor: pointer; font: inherit; color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 650; font-size: 12px; flex: none; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50; }
.dropdown.open { display: block; }
.dropdown .who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.dropdown button, .dropdown a { display: flex; gap: 9px; align-items: center; width: 100%; border: 0; background: none; padding: 9px 12px; border-radius: 8px; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.dropdown button:hover, .dropdown a:hover { background: #f3f4f6; text-decoration: none; }
.content { padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards, grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-b { padding: 18px; }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.g-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.kpi .value { font-size: 30px; font-weight: 680; color: var(--ink); letter-spacing: -.03em; margin-top: 6px; line-height: 1.1; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.accent .value { color: var(--brand-dark); }
.kpi.warn .value { color: var(--warn); }
.kpi.bad .value { color: var(--bad); }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--bad); border-color: #f3c7c7; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #116530; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid #d5d9e0; border-radius: 8px; padding: 8px 11px; height: 38px; width: 100%; }
textarea { height: auto; min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-line); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; height: auto; accent-color: var(--brand); }
label { display: block; font-weight: 550; margin-bottom: 5px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 6px 0; }
.check label { margin: 0; font-weight: 500; }
.err { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.filters .field { margin: 0; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { display: inline-flex; gap: 5px; align-items: center; border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; margin: 0; font-weight: 500; cursor: pointer; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 16px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
.person { display: flex; align-items: center; gap: 10px; }
.person b { display: block; color: var(--ink); font-weight: 600; }
.person span { color: var(--muted); font-size: 12.5px; }

/* ---------- Badges, alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f3; color: #4b5563; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-brand { background: var(--brand-soft); color: var(--brand-dark); }
.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; border: 1px solid; display: flex; gap: 10px; }
.alert-ok { background: var(--ok-bg); border-color: #bfe3c9; color: #14532d; }
.alert-bad { background: var(--bad-bg); border-color: #f3c7c7; color: #7f1d1d; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.alert-info { background: var(--info-bg); border-color: #c5d6fb; color: #1e3a8a; }
.alert ul { margin: 0; padding-left: 18px; }
.cred { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #fff; border: 1px dashed #9ca3af; padding: 8px 12px; border-radius: 8px; margin-top: 6px; display: inline-block; user-select: all; }

/* ---------- Charts, calendar ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 6px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.bar-stack { width: 100%; max-width: 44px; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 3px 3px; overflow: hidden; background: #f0f2f5; min-height: 3px; }
.bar-stack i { display: block; }
.bar-ontime { background: var(--brand); }
.bar-late { background: #f0a53a; }
.bar-label { font-size: 11.5px; color: var(--muted); text-align: center; }
.bar-val { font-size: 12px; font-weight: 600; color: var(--ink); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .05em; padding-bottom: 2px; }
.cal .day { aspect-ratio: 1.15; border-radius: 8px; background: #f3f4f6; padding: 5px 6px; display: flex; flex-direction: column; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.cal .day b { font-size: 13px; color: var(--ink); }
.cal .day.l1 { background: color-mix(in srgb, var(--brand) 14%, white); }
.cal .day.l2 { background: color-mix(in srgb, var(--brand) 32%, white); }
.cal .day.l3 { background: color-mix(in srgb, var(--brand) 58%, white); color: #fff; }
.cal .day.l3 b { color: #fff; }
.cal .day.today { outline: 2px solid var(--ink); }
.cal .day.void { background: transparent; }
.matrix td, .matrix th { padding: 7px 5px; text-align: center; font-size: 12px; min-width: 26px; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: #fff; min-width: 190px; z-index: 1; }
.matrix th:first-child { background: #fafbfc; }
.cell-P { color: var(--ok); font-weight: 700; } .cell-L { color: var(--warn); font-weight: 700; } .cell-H { color: var(--info); font-weight: 700; }
.cell-A { color: var(--bad); font-weight: 700; } .cell-W { color: var(--faint); }
.matrix .wk { background: #f6f7f9; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ic { width: 34px; height: 34px; color: var(--faint); margin-bottom: 8px; }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.feed li:last-child { border-bottom: 0; }
.feed .grow { flex: 1; min-width: 0; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick a { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-weight: 550; background: #fff; }
.quick a:hover { border-color: var(--brand-line); background: var(--brand-soft); text-decoration: none; }
.pagination { display: flex; gap: 4px; padding: 14px 18px; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span.pg { min-width: 32px; height: 32px; padding: 0 8px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); color: var(--text); background: #fff; font-size: 13px; }
.pagination span.cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination span.dis { color: var(--faint); background: #f6f7f9; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; color: var(--ink); }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumbs a { display: block; width: 120px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; color: var(--text); }
.thumbs img { width: 120px; height: 90px; object-fit: cover; display: block; }
.thumbs span { display: block; padding: 6px 8px; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skeleton { background: linear-gradient(90deg, #eceff3 25%, #f6f7f9 37%, #eceff3 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 6px; }
@keyframes sk { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast div { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); animation: up .2s ease; }
@keyframes up { from { transform: translateY(8px); opacity: 0 } }
details.card summary { cursor: pointer; padding: 14px 18px; font-weight: 600; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art { background: radial-gradient(1200px 600px at 20% 10%, color-mix(in srgb, var(--brand) 55%, #0b1220), var(--ink)); color: #dbe3f0; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h2 { color: #fff; font-size: 30px; line-height: 1.2; max-width: 460px; letter-spacing: -.02em; }
.auth-art li { margin: 10px 0; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { margin-bottom: 6px; }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .g-main { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; }
}
@media print { .sidebar, .topbar, .actions, .filters { display: none !important; } .app { display: block; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Platform: manage an organization from the platform panel ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.manage-head { margin: 4px 14px 0; padding: 10px 11px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--ink-2)); background: color-mix(in srgb, var(--brand) 14%, var(--ink)); display: grid; gap: 3px; flex: none; }
.manage-head b { color: #fff; font-size: 13.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.manage-head .nav-label { color: #9fd9cf; }
.manage-head-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.manage-head-actions .btn { height: 30px; padding: 0 10px; }
@media (min-width: 961px) { .collapsed .manage-head { display: none; } }
.manage-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); background: color-mix(in srgb, var(--brand) 7%, var(--card)); }
.manage-bar > .ic { color: var(--brand); }
.manage-bar .grow { flex: 1; min-width: 220px; }
.manage-bar .grow > span { display: block; }
.manage-switch select { height: 34px; padding-top: 0; padding-bottom: 0; min-width: 180px; max-width: 260px; }
.manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; padding: 16px 18px; }
.manage-grid h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.manage-grid button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 8px; margin: 0 -8px; border-radius: 7px; font: inherit; color: var(--brand); cursor: pointer; }
.manage-grid button:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .btn { height: 30px; padding: 0 10px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.stat-row div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat-row b { display: block; font-size: 22px; line-height: 1.1; }
.stat-row span { font-size: 12px; color: var(--muted); }

/* platform: block menu */
.block-menu{display:block;position:relative;margin-top:4px;text-align:right}
.block-menu>summary{list-style:none;cursor:pointer}
.block-menu>summary::-webkit-details-marker{display:none}
.block-menu[open]>form{position:absolute;right:0;text-align:left;z-index:20;display:grid;gap:6px;width:220px;padding:10px;background:var(--card,#fff);border:1px solid var(--line,#e5e7eb);border-radius:10px;box-shadow:0 8px 24px rgba(0,0,0,.12)}
