/* iConnect Exclusive - web. Design tokens first; light and dark themes.
   CSP style-src 'self': no inline styles anywhere, everything is a class here. */
/* Brand (logo iConnect Exclusive): navy #0b2d52, sky #05a8ec, green #8cbf6c, teal #00968a.
   Typeface: Montserrat (geometric, like the CONNECT wordmark), self-hosted in brand/ when present. */
@font-face { font-family: "Montserrat"; src: url("brand/montserrat.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap; }
:root {
  color-scheme: light;
  --navy: #0b2d52;
  --sky: #05a8ec;
  --green: #8cbf6c;
  --teal: #00968a;
  --brand-stripe: linear-gradient(90deg, var(--sky) 0%, var(--sky) 45%, var(--teal) 45%, var(--teal) 55%, var(--green) 55%, var(--green) 100%);
  --bg: #f3f7fb;
  --bg-soft: #e8f0f7;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --text: #0b2d52;
  --muted: #5a6f86;
  --line: #dfe8f1;
  --line-strong: #cbd8e5;
  --primary: #0b2d52;
  --primary-2: #0a4f85;
  --accent: #0389c4;
  --primary-soft: #e4f4fc;
  --primary-text: #ffffff;
  --danger: #c2362b;
  --danger-soft: #fdecea;
  --ok: #3f7f27;
  --ok-soft: #edf6e7;
  --warn: #b26b00;
  --warn-soft: #fff3df;
  --info-soft: #e4f4fc;
  --focus: rgba(5, 168, 236, .3);
  --side-bg: #ffffff;
  --side-bg-2: #ffffff;
  --side-text: #31506f;
  --side-strong: #0b2d52;
  --side-muted: #8aa0b6;
  --side-hover: #f0f6fb;
  --side-active: #e4f4fc;
  --side-line: #e3ebf3;
  --shadow-sm: 0 1px 2px rgba(11, 45, 82, .06), 0 1px 3px rgba(11, 45, 82, .05);
  --shadow: 0 8px 24px rgba(11, 45, 82, .08), 0 2px 6px rgba(11, 45, 82, .05);
  --shadow-lg: 0 24px 60px rgba(11, 45, 82, .22);
  --radius: 14px;
  --radius-sm: 10px;
  --side-w: 256px;
  font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #071526; --bg-soft: #0c1f36; --surface: #0d2139; --surface-2: #102843; --text: #e7f0f9;
    --muted: #96acc3; --line: #1a3352; --line-strong: #254268; --primary: #05a8ec; --primary-2: #00968a; --accent: #4cc3f5;
    --primary-soft: rgba(5, 168, 236, .14); --primary-text: #04162a; --danger: #ff8a80; --danger-soft: rgba(255, 138, 128, .12);
    --ok: #a5d68a; --ok-soft: rgba(140, 191, 108, .14); --warn: #ffc266; --warn-soft: rgba(255, 194, 102, .12);
    --info-soft: rgba(5, 168, 236, .12); --focus: rgba(5, 168, 236, .38);
    --side-bg: #0a1d33; --side-bg-2: #0a1d33; --side-text: #b7c8da; --side-strong: #ffffff; --side-muted: #6f88a3;
    --side-hover: rgba(255, 255, 255, .05); --side-active: rgba(5, 168, 236, .15); --side-line: #16304d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #071526; --bg-soft: #0c1f36; --surface: #0d2139; --surface-2: #102843; --text: #e7f0f9;
  --muted: #96acc3; --line: #1a3352; --line-strong: #254268; --primary: #05a8ec; --primary-2: #00968a; --accent: #4cc3f5;
  --primary-soft: rgba(5, 168, 236, .14); --primary-text: #04162a; --danger: #ff8a80; --danger-soft: rgba(255, 138, 128, .12);
  --ok: #a5d68a; --ok-soft: rgba(140, 191, 108, .14); --warn: #ffc266; --warn-soft: rgba(255, 194, 102, .12);
  --info-soft: rgba(5, 168, 236, .12); --focus: rgba(5, 168, 236, .38);
  --side-bg: #0a1d33; --side-bg-2: #0a1d33; --side-text: #b7c8da; --side-strong: #ffffff; --side-muted: #6f88a3;
  --side-hover: rgba(255, 255, 255, .05); --side-active: rgba(5, 168, 236, .15); --side-line: #16304d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Montserrat", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; line-height: 1.45; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .6rem; letter-spacing: -.01em; line-height: 1.2; }
h2 { font-size: 1.3rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); min-height: 1.2em; margin: .2rem 0; font-size: .92rem; }
p.error:not(:empty) { background: var(--danger-soft); padding: .55rem .75rem; border-radius: var(--radius-sm); }
.spacer { flex: 1; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- forms */
label { display: flex; flex-direction: column; gap: .35rem; font-size: .86rem; font-weight: 550; color: var(--muted); }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); padding: .6rem .75rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color .15s, box-shadow .15s; min-height: 2.5rem; }
textarea { min-height: 5rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; text-transform: none; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
/* Ed's rule: every text is UPPERCASE (the API stores it uppercase; this shows it while typing) */
input:not([type=email]):not([type=password]):not([name=username]):not([type=search]), textarea { text-transform: uppercase; }
input[type=checkbox], input[type=radio] { width: 1.1rem; height: 1.1rem; min-height: 0; padding: 0; accent-color: var(--primary); }
input[type=file] { padding: .45rem; }

/* ---------------------------------------------------------------- buttons */
button { font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); padding: .55rem 1rem; min-height: 2.45rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s, color .15s; }
button:hover { border-color: var(--muted); background: var(--surface-2); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
button.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-text); border-color: transparent;
  box-shadow: 0 6px 16px rgba(11, 45, 82, .22); }
button.primary:hover { filter: brightness(1.12); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
button.danger:hover { background: var(--danger-soft); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--bg-soft); color: var(--text); }
button.link { background: none; border: none; color: var(--accent); padding: .3rem .55rem; min-height: 0; border-radius: 8px; font-weight: 600; }
button.link:hover { background: var(--primary-soft); }
button.link.danger, button.link.danger:hover { color: var(--danger); }
button.link.danger:hover { background: var(--danger-soft); }
button.block { width: 100%; }
button:disabled { opacity: .55; cursor: default; transform: none; }
.icon-btn { width: 2.45rem; padding: 0; background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }

/* ---------------------------------------------------------------- auth screens */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--bg); }
.auth.single { grid-template-columns: 1fr; }
/* the brand side is always light: the logo is designed on white */
.auth-hero { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 48px;
  background: #ffffff; color: #0b2d52; border-right: 1px solid #e3ebf3; }
.auth-hero::before { content: ""; position: absolute; width: 520px; height: 520px; right: -220px; top: -200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(5, 168, 236, .16), transparent 65%); }
.auth-hero::after { content: ""; position: absolute; width: 460px; height: 460px; left: -200px; bottom: -220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(140, 191, 108, .2), transparent 65%); }
.auth-hero-inner { position: relative; z-index: 1; max-width: 480px; text-align: center; }
.auth-logo { width: min(300px, 70%); height: auto; margin: 0 auto 26px; display: block; }
.auth-lead { font-size: 1.04rem; color: #3d5873; margin: 0 0 24px; }
.auth-points { list-style: none; padding: 0; margin: 0 auto 30px; display: inline-grid; gap: 11px; text-align: left; }
.auth-points li { display: flex; gap: 10px; align-items: center; color: #0b2d52; font-weight: 500; }
.auth-points li::before { content: ""; width: 22px; height: 22px; flex: none; border-radius: 50%;
  background: rgba(140, 191, 108, .22) center / 12px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233f7f27' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }
.auth-companies { color: #5a6f86; font-size: .86rem; margin: 0; padding-top: 18px; border-top: 1px solid #e3ebf3; }
.auth-panel { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 18px;
  background: radial-gradient(700px 400px at 100% 0%, rgba(5, 168, 236, .12), transparent 60%),
              radial-gradient(600px 400px at 0% 100%, rgba(140, 191, 108, .12), transparent 60%), var(--bg); }
.auth-card { position: relative; overflow: hidden; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: .9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 2.2rem 2rem 2rem; box-shadow: var(--shadow); }
.auth-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--brand-stripe); }
.auth-card h2 { font-size: 1.45rem; font-weight: 800; margin: 0; }
.auth-card > p.muted { margin: 0 0 .3rem; }
.exclusive-pill { align-self: flex-start; display: inline-flex; align-items: center; gap: .45rem; padding: .32rem .8rem; border-radius: 99px;
  font-size: .7rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: #fff;
  background: linear-gradient(135deg, #0b2d52, #0a4f85); box-shadow: 0 6px 14px rgba(11, 45, 82, .25); }
.exclusive-pill::before { content: ""; width: 9px; height: 9px; transform: rotate(45deg); border-radius: 2px;
  background: linear-gradient(135deg, var(--sky), var(--green)); }
.auth-logo-sm { display: none; width: 150px; height: auto; margin: 0 auto .4rem; }
.auth.single .auth-logo-sm { display: block; }
.auth-foot { margin: -8px 0 0; text-align: center; max-width: 520px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-logo-sm { display: block; padding: 10px; background: #fff; border-radius: 14px; }
}

/* ---------------------------------------------------------------- app shell */
.shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 20; display: flex; flex-direction: column;
  background: var(--side-bg); color: var(--side-text); border-right: 1px solid var(--side-line); }
.sidebar::before { content: ""; height: 4px; flex: none; background: var(--brand-stripe); }
.side-brand { display: flex; align-items: center; gap: 11px; padding: 16px 18px 14px; text-decoration: none; }
.mark-tile { width: 42px; height: 42px; border-radius: 12px; background: #fff; display: grid; place-items: center; flex: none;
  border: 1px solid #e3ebf3; box-shadow: 0 2px 6px rgba(11, 45, 82, .08); }
.side-word { display: flex; flex-direction: column; line-height: 1.05; }
.side-word b { font-size: 1.18rem; font-weight: 800; color: var(--side-strong); letter-spacing: -.01em; }
.side-word small { font-size: .62rem; font-weight: 700; letter-spacing: .42em; color: var(--sky); margin-top: 3px; }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.nav-group { margin-top: 16px; padding: 0 10px 6px; font-size: .66rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--side-muted); }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; margin: 1px 0; border-radius: 10px;
  color: var(--side-text); text-decoration: none; font-size: .9rem; font-weight: 550; position: relative;
  transition: background .15s, color .15s; }
.side-nav a:hover { background: var(--side-hover); color: var(--side-strong); }
.side-nav a.active { background: var(--side-active); color: var(--side-strong); font-weight: 700; }
.side-nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--sky), var(--green)); }
.side-nav a.active svg.ic { color: var(--sky); }
.side-foot { padding: 14px 20px 18px; color: var(--side-muted); border-top: 1px solid var(--side-line); font-size: .74rem; line-height: 1.4; }
.workspace { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .6rem; padding: .7rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); }
.page-head { display: flex; flex-direction: column; min-width: 0; }
.page-group { font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.page-title { font-size: 1.25rem; margin: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip { display: flex; align-items: center; gap: .55rem; padding: .25rem .7rem .25rem .25rem; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line); max-width: min(480px, 45vw); flex: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .78rem; font-weight: 800;
  color: #fff; background: linear-gradient(135deg, #0b2d52, var(--sky)); }
.who { font-size: .92rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: inline-flex; }
.side-foot b { color: var(--side-strong); font-weight: 800; }
.sidebar, .workspace { transition: width .18s ease, margin-left .18s ease; }
/* collapsed side menu (desktop default): icons only, names as tooltips */
@media (min-width: 961px) {
  .shell.side-collapsed { --side-w: 76px; }
  .shell.side-collapsed .side-brand { justify-content: center; padding: 16px 0 14px; }
  .shell.side-collapsed .side-word,
  .shell.side-collapsed .nav-label { display: none; }
  .shell.side-collapsed .nav-group { font-size: 0; padding: 0; margin: 12px 14px 6px; height: 1px; background: var(--side-line); }
  .shell.side-collapsed .side-nav { padding: 4px 12px 16px; }
  .shell.side-collapsed .side-nav a { justify-content: center; padding: 10px 0; }
  .shell.side-collapsed .side-nav a svg.ic { width: 20px; height: 20px; }
  .shell.side-collapsed .side-foot { padding: 12px 6px 16px; text-align: center; font-size: .6rem; line-height: 1.25; }
}
.scrim { position: fixed; inset: 0; background: rgba(5, 20, 40, .45); z-index: 15; }
/* content starts at the same left edge as the menu button (☰), in collapsed and expanded menus */
.container { width: 100%; max-width: 1440px; margin: 0; padding: 1.5rem 1.5rem 3rem; }
.menu-btn { margin-left: -.625rem; }
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .workspace { margin-left: 0; }
  .topbar { padding: .6rem 16px; }
  .container { padding: 1.1rem 16px 3rem; }
}
@media (max-width: 600px) {
  .who { display: none; }
  .user-chip { padding: .25rem; }
  .page-title { font-size: 1.08rem; }
}

/* ---------------------------------------------------------------- page building blocks */
.container > .toolbar:first-child, .container > form.toolbar:first-child { margin-top: 0; }
.toolbar { display: flex; gap: .7rem; align-items: end; flex-wrap: wrap; margin: 0 0 1rem; }
.toolbar h2 { margin: 0 auto 0 0; align-self: center; font-size: 1.15rem; font-weight: 800; }
h2, h3, .page-title, .tile b { font-weight: 800; }
.toolbar h2.dup { visibility: hidden; font-size: 0; }
.toolbar:has(> h2.dup:only-child) { display: none; }
form.toolbar:not(:has(> h2)) { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: var(--shadow-sm); }
.toolbar label { min-width: 150px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow-sm); }
.narrow { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: .8rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: .8rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .91rem; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; text-align: right; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td .small.muted { margin-top: 2px; }
td[colspan].muted { text-align: center; padding: 2.4rem 1rem; }

/* status pills */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .6rem; border-radius: 99px; font-size: .74rem;
  font-weight: 650; letter-spacing: .02em; background: var(--bg-soft); color: var(--muted); border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.off { color: var(--muted); background: var(--bg-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
td .badge + .badge, td .badge { margin-right: .25rem; }

/* tabs = segmented control */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 1.1rem; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 12px; }
.tabs button { border: none; background: transparent; color: var(--muted); padding: .4rem .9rem; min-height: 2.1rem; border-radius: 9px; font-weight: 600; }
.tabs button:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--text); }
.tabs button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem 1rem; }
.grid2 > * { min-width: 0; }
.grid2 select, .private select { width: 100%; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; align-items: center; }
.checks label, label.checks { flex-direction: row; align-items: center; gap: .45rem; color: var(--text); font-weight: 500; }
details { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .65rem .9rem; background: var(--surface-2); }
details > summary { cursor: pointer; font-weight: 650; }
details[open] > summary { margin-bottom: .7rem; }
.perm-module { margin-top: .9rem; padding-bottom: .3rem; font-weight: 700; color: var(--accent); font-size: .76rem;
  text-transform: uppercase; letter-spacing: .07em; border-bottom: 1px solid var(--line); }
.private { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius); padding: 1rem;
  display: flex; flex-direction: column; gap: .8rem; position: relative; }
.private > .small.muted:first-child { font-weight: 650; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.preview-img { max-width: 100%; max-height: 300px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
pre.json { margin: 0; white-space: pre-wrap; font-size: .78rem; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.container > p.muted:only-child { padding: 3rem 0; text-align: center; }
.container > p.small.muted { margin: .3rem .2rem; }

/* ---------------------------------------------------------------- dialog */
dialog { border: none; border-radius: 18px; padding: 0; background: var(--surface); color: var(--text);
  width: min(780px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); }
dialog[open] { animation: pop .16s ease-out; }
dialog::backdrop { background: rgba(5, 15, 30, .5); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
#dialog-form { padding: 0 1.5rem 1.3rem; display: flex; flex-direction: column; gap: .85rem; max-height: 88vh; overflow-y: auto; }
#dialog-form > h2:first-child { position: sticky; top: 0; z-index: 1; margin: 0 -1.5rem .2rem; padding: 1.1rem 1.5rem; font-size: 1.15rem;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.dialog-actions { position: sticky; bottom: -1.3rem; display: flex; justify-content: flex-end; gap: .6rem; margin: .3rem -1.5rem -1.3rem;
  padding: .9rem 1.5rem; background: var(--surface-2); border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- toast */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 12px); background: #0b2d52; color: #fff;
  padding: .75rem 1.15rem; border-radius: 12px; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 50; font-weight: 550; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- home */
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: 1.9rem 2rem 2.1rem; margin-bottom: 1.6rem; color: #fff;
  background: radial-gradient(520px 260px at 100% 110%, rgba(140, 191, 108, .45), transparent 60%),
              radial-gradient(600px 300px at 85% -20%, rgba(5, 168, 236, .55), transparent 60%),
              linear-gradient(135deg, #0b2d52 0%, #0a3d6b 65%, #0a4f85 100%); box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--brand-stripe); }
.hero h2 { font-size: 1.75rem; font-weight: 800; margin: 0 0 .35rem; color: #fff; }
.hero p { margin: 0; color: #cfe3f5; }
.hero .exclusive-pill { margin-bottom: .9rem; background: rgba(255, 255, 255, .12); box-shadow: none; border: 1px solid rgba(255, 255, 255, .22); }
.home-group { margin: 1.6rem 0 .7rem; font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 10px; }
.tile { display: flex; gap: 10px; align-items: center; padding: .65rem .8rem; border-radius: 12px; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--sky) 45%, var(--line)); }
.tile-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--accent); }
.tiles > .tile:nth-child(3n+2) .tile-ic { background: var(--ok-soft); color: var(--ok); }
.tile-ic svg.ic { width: 18px; height: 18px; }
.tile b { display: block; font-size: .88rem; margin-bottom: 1px; }
.tile span { color: var(--muted); font-size: .68rem; line-height: 1.3; }
.home-group { margin: 1.2rem 0 .55rem; }

/* ---------------------------------------------------------------- month calendar */
.cal-nav { display: inline-flex; align-items: center; gap: .4rem; align-self: end; }
.cal-nav button { min-width: 2.45rem; padding: 0; font-size: 1.2rem; }
.cal-title { min-width: 10.5rem; text-align: center; font-size: 1.05rem; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { text-align: center; font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: .35rem 0; }
.cal-cell { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 3px; min-height: 92px;
  padding: .5rem .55rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-align: left;
  font-weight: 500; color: var(--text); box-shadow: none; }
.cal-cell:hover { border-color: var(--sky); background: var(--surface); box-shadow: var(--shadow-sm); }
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--sky); box-shadow: inset 0 0 0 1px var(--sky); }
.cal-cell.busy { background: linear-gradient(180deg, var(--primary-soft), var(--surface) 70%); }
.cal-num { font-weight: 800; font-size: .95rem; }
.cal-cell.today .cal-num { color: var(--accent); }
.cal-count { font-size: .74rem; font-weight: 700; color: var(--primary-text); background: var(--primary); padding: .1rem .5rem; border-radius: 99px; }
.cal-sub { font-size: .68rem; color: var(--ok); font-weight: 600; }
.cal-sub.off { color: var(--muted); }
.cal-sub.open { color: var(--accent); }
.prof-day { margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.prof-name { margin: 0 0 .5rem; font-size: .95rem; font-weight: 800; }
.prof-day .slots { margin-bottom: 0; }
.form-section { margin: .4rem 0 0; font-size: .8rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.picked { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.picked:empty { display: none; }
.pick-results table td { padding: .45rem .6rem; }
.pick-results { max-height: 320px; overflow-y: auto; margin-top: .6rem; }
.pick-results tr.pickable { cursor: pointer; }
.pick-results tr.pickable:hover { background: var(--primary-soft); }
.pick-results .link { color: var(--accent); font-weight: 700; }
/* lab tube colours (Ed 2026-11-08): table cell tinted with the tube colour, dot in the order / popup */
.tube-yellow { --tube: #f2c200; } .tube-blue { --tube: #4fb3e8; } .tube-lilac { --tube: #a77bd1; }
.tube-green { --tube: #3fa34d; } .tube-gray { --tube: #8d969e; } .tube-red { --tube: #d63a3a; } .tube-black { --tube: #222; }
td.tube-cell { background: color-mix(in srgb, var(--tube) 30%, transparent); box-shadow: inset 5px 0 0 var(--tube); font-weight: 600; }
.tube-dot { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--tube);
  border: 1px solid rgba(0,0,0,.25); vertical-align: middle; }
.tube-dot.none { background: transparent; border: 1px dashed var(--muted); }
.tube-line { display: inline-flex; align-items: center; gap: 8px; }
.exam-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: .5rem; }
.exam-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 8px; }
.exam-item .exam-name { flex: 1; min-width: 0; }
.exam-item .num { white-space: nowrap; }
dialog.popup { width: min(640px, calc(100vw - 24px)); }
#popup-body { padding: 1.1rem 1.4rem 1.3rem; display: flex; flex-direction: column; gap: .6rem; }
.popup-head { display: flex; align-items: center; justify-content: space-between; }
.popup-head h2 { margin: 0; font-size: 1.15rem; }
.popup-head .icon-btn { font-size: 1.4rem; }
.inline-check, .grid2 > .checks { align-self: end; min-height: 2.5rem; }
tr.row-edit { cursor: pointer; }
.status-select { min-height: 2rem; padding: .25rem .5rem; font-size: .8rem; font-weight: 700; border-radius: 99px; width: auto; }
.status-select.st-scheduled { color: var(--accent); }
.status-select.st-confirmed { color: var(--ok); }
.status-select.st-no_show { color: var(--warn); }
input.readonly, input[readonly] { background: var(--surface-2); color: var(--text); font-weight: 700; cursor: default; }
.day-title { margin: .2rem 0 .8rem; font-size: 1.1rem; }
/* time slots of a day */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 1.2rem; }
.slot { flex-direction: column; align-items: flex-start; gap: 1px; padding: .45rem .6rem; min-height: 0; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line-strong); text-align: left; }
.slot b { font-size: .95rem; }
.slot span { font-size: .7rem; font-weight: 600; color: var(--ok); }
.slot:hover:not(:disabled) { border-color: var(--sky); background: var(--primary-soft); }
.slot.some span { color: var(--warn); }
.slot.taken { background: var(--bg-soft); border-style: dashed; opacity: 1; cursor: not-allowed; }
.slot.taken span { color: var(--muted); }
.enabled-blocks { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: -.2rem 0 .8rem; }
.enabled-blocks .badge button.link { padding: 0 .2rem; min-height: 0; font-size: .9rem; line-height: 1; }
@media (max-width: 700px) {
  .cal { gap: 3px; }
  .cal-cell { min-height: 58px; padding: .3rem; }
  .cal-count { font-size: .62rem; padding: .05rem .3rem; }
  .cal-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .sidebar, .topbar { display: none; } .workspace { margin: 0; } }

/* prescriptions dialog: each prescription with its medicines (Ed 2026-11-08) */
.rx-list { display: grid; gap: 10px; margin-bottom: 12px; min-width: min(560px, 80vw); }
.rx-card { border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 10px; padding: 10px 14px; background: var(--surface); }
.rx-card.voided { border-left-color: var(--danger); opacity: .7; }
.rx-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.rx-actions { margin-left: auto; display: flex; gap: 6px; }
.rx-lines { margin: 8px 0 0; padding-left: 20px; }
.rx-lines li { margin: 3px 0; }

/* time + print icons in the appointment table (Ed 2026-11-08) */
.time-cell { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.time-cell > span { font-weight: 600; margin-right: 4px; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--accent); cursor: pointer; }
.icon-btn:hover { background: var(--primary-soft); border-color: var(--sky); color: var(--text); }
.icon-btn svg.ic { width: 16px; height: 16px; }

/* row "⋯" actions menu (Ed 2026-11-08) */
details.row-menu { display: inline-block; }
details.row-menu > summary { list-style: none; display: inline-grid; place-items: center; width: 32px; height: 30px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
details.row-menu > summary::-webkit-details-marker { display: none; }
details.row-menu > summary:hover, details.row-menu[open] > summary { background: var(--primary-soft); border-color: var(--sky); }
details.row-menu > summary svg.ic { stroke-width: 3.2; }
.row-menu-list { position: fixed; z-index: 40; min-width: 180px; padding: 6px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(11, 45, 82, .18); display: flex; flex-direction: column; gap: 2px; }
.row-menu-list button { display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-size: .88rem; text-align: left; cursor: pointer; }
.row-menu-list button:hover { background: var(--primary-soft); }
.row-menu-list button svg.ic { width: 16px; height: 16px; color: var(--accent); }
.time-cell .status-select { margin: 0 2px; }

/* wide dialog (lists inside a window, e.g. "Otras brigadas") */
dialog.wide { width: min(1100px, calc(100vw - 24px)); }
td.nowrap { white-space: nowrap; }

/* field chosen in a search popup (Equipo, Sede, Ciudad) */
button.picker { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; justify-content: flex-start;
  font: inherit; font-weight: 500; padding: .6rem .75rem; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); cursor: pointer; text-transform: uppercase; }
button.picker .picker-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.picker::after { content: "⌕"; flex: none; color: var(--muted); }
button.picker:hover { border-color: var(--sky); }
button.picker.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* users who can see a brigade (form) */
.user-checks { max-height: 220px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; }

/* compact time cards (Ed 2026-11-08): just the time, colour = state */
.slots { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.slot { align-items: center; padding: .28rem .3rem; border-radius: 8px; border-left: 3px solid var(--ok); }
.slot b { font-size: .82rem; font-weight: 700; }
.slot span { display: none; }
.slot.taken { border-left-color: var(--line-strong); color: var(--muted); }
.slot.taken b { text-decoration: line-through; font-weight: 600; }

/* brigade detail: buttons line, then venue + city, then team */
.toolbar .spacer { flex: 1; }
.brigade-head { margin: .2rem 0 .8rem; }
.brigade-head h2 { margin: 0 0 .15rem; font-size: 1.15rem; }
.brigade-head p { margin: 0; }

/* Agenda Pública: one day agenda as a list, free times interleaved (Ed 2026-11-08) */
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: .4rem 0 .6rem; color: var(--muted); font-size: .9rem; }
.day-head b { color: var(--text); }
.table-wrap tr.free-row td { padding-top: .22rem; padding-bottom: .22rem; height: auto; line-height: 1.2; background: transparent; }
.day-head label.inline-check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; margin: 0;
  font-size: .85rem; color: var(--text); cursor: pointer; }
.day-head label.inline-check input { margin: 0; width: auto; }
tr.free-row .time-cell > span:first-child { color: var(--muted); font-weight: 600; }
tr.free-row .free-tag { font-size: .7rem; font-weight: 700; color: var(--ok); background: var(--ok-soft); border-radius: 999px; padding: 1px 8px; }
tr.free-row:hover td { background: var(--primary-soft); }
tr.free-row .link { font-weight: 700; }

/* segmented filter: Todos / Solo agendados / Solo disponibles */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--muted); font: inherit; font-size: .82rem;
  font-weight: 600; padding: .35rem .8rem; cursor: pointer; box-shadow: none; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--primary); color: var(--primary-text); }
.seg button:hover:not(.active) { background: var(--primary-soft); color: var(--text); }

/* aligned first column: the time has a fixed width so "Libre" and the status line up */
.time-cell > span:first-child { display: inline-block; min-width: 3.1em; }

/* attention: diagnoses and treatments as compact cards (Ed 2026-11-08) */
.enc-list { display: grid; gap: 8px; }
.enc-item { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; display: grid; gap: 6px; background: var(--surface); }
.enc-item-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.enc-item-head select { flex: 1; min-width: 200px; }
.enc-code { font-weight: 800; color: var(--navy); background: var(--primary-soft); border-radius: 6px; padding: 1px 8px; }
.enc-desc { flex: 1; min-width: 180px; font-weight: 600; }
.enc-kind { flex: none !important; min-width: 0 !important; width: auto; }
#dialog-form label.enc-check { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 600; }
#dialog-form label.enc-check input { width: auto; margin: 0; }

/* "Eliminar turno" icon on free slots */
.icon-btn.danger-ic { width: 20px; height: 20px; color: var(--muted); border-color: transparent; background: transparent; vertical-align: middle; }
.table-wrap tr.free-row td.actions { padding-top: 0; padding-bottom: 0; }
.icon-btn.danger-ic:hover { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.icon-btn.danger-ic svg.ic { width: 14px; height: 14px; }
