/* XC Subs theme — dark default, light via [data-theme="light"] */
:root, [data-theme="dark"] {
  --bg: #070B14;
  --card: #0F172A;
  --border: #1E293B;
  --text: #E2E8F0;
  --muted: #94A3B8;
  --accent: #3B82F6;
  --green: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;
  --input: #0B1222;
  --hover: #16213a;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --pill-paid: rgba(16,185,129,.15);
  --pill-up: rgba(59,130,246,.16);
  --pill-issue: rgba(245,158,11,.16);
  --pill-cx: rgba(239,68,68,.14);
}
[data-theme="light"] {
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --muted: #64748B;
  --input: #F1F5F9;
  --hover: #F1F5F9;
  --shadow: 0 8px 24px rgba(15,23,42,.08);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
.hidden { display: none !important; }
h1,h2,h3,h4 { margin: 0 0 .6em; }
p { color: var(--muted); }

/* ---------- buttons / inputs ---------- */
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: .6em 1.1em; font-weight: 600; cursor: pointer; font-size: .92rem;
}
.btn:hover { filter: brightness(1.1); }
.btn.block { width: 100%; margin-top: .8em; }
.btn.small { padding: .4em .8em; font-size: .82rem; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--red); }
.btn.warn { background: var(--amber); color: #1a1206; }
.btn.ok { background: var(--green); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: .45em .6em; cursor: pointer; font-size: 1rem; position: relative;
}
.icon-btn:hover { background: var(--hover); }
input, select, textarea {
  background: var(--input); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: .6em .8em; font-size: .92rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
label.fld { display: block; margin: .8em 0; }
label.fld > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .35em; font-weight: 600; }
.form-error { color: var(--red); font-size: .85rem; margin-top: .6em; min-height: 1.2em; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8em; }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5em;
  background: radial-gradient(1000px 500px at 50% -10%, rgba(59,130,246,.18), transparent); }
.login-wrap { width: 400px; max-width: 100%; }
.login-brand { display: flex; align-items: center; gap: .9em; margin-bottom: 1.4em; }
.login-brand h1 { margin: 0; font-size: 1.8rem; letter-spacing: .02em; }
.login-brand p { margin: .1em 0 0; }
.logo-mark {
  width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.25rem; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2, #8B5CF6)); box-shadow: 0 0 24px rgba(59,130,246,.5);
}
.logo-mark.has-img { background: transparent; box-shadow: none; padding: 0; overflow: hidden; }
.logo-mark.has-img img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; display: block; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 1.8em; box-shadow: var(--shadow); }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; right: 6px; top: 6px; border: 0; }
.remember { display: flex; align-items: center; gap: .5em; font-size: .88rem; color: var(--muted); margin-top: .4em; }
.remember input { width: auto; }
.creds-box {
  margin-top: 1.4em; border: 1px dashed var(--accent); border-radius: 12px; padding: 1em;
  background: rgba(59,130,246,.07);
}
.creds-title { font-weight: 700; font-size: .85rem; margin-bottom: .6em; color: var(--accent); }
.creds-row { display: flex; justify-content: space-between; font-size: .85rem; margin: .3em 0; }
.creds-row span { color: var(--muted); }
.creds-row code { font-family: ui-monospace, monospace; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1em .8em; position: sticky; top: 0; height: 100vh;
  transition: margin .2s;
}
.sidebar.collapsed { margin-left: -250px; }
.side-brand { display: flex; align-items: center; gap: .6em; padding: .4em .4em 1em; font-weight: 800; font-size: 1.1rem; }
.side-brand .logo-mark { width: 38px; height: 38px; font-size: 1rem; }
#side-collapse { margin-left: auto; }
.nav-item {
  display: flex; align-items: center; gap: .7em; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--muted); padding: .75em .8em;
  border-radius: 10px; cursor: pointer; font-size: .92rem; font-weight: 600; margin-bottom: .25em;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: rgba(59,130,246,.15); color: var(--accent); }
.side-foot { margin-top: auto; color: var(--muted); font-size: .75rem; padding: .5em; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .7em; padding: .7em 1.2em;
  border-bottom: 1px solid var(--border); background: var(--card); position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.admin-badge {
  display: flex; align-items: center; gap: .5em; font-weight: 700; font-size: .9rem;
  border: 1px solid var(--border); padding: .4em .8em; border-radius: 999px;
}
.sync-chip {
  display: flex; align-items: center; gap: .5em; font-size: .85rem; color: var(--muted);
  border: 1px solid var(--border); padding: .4em .8em; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.bell-count {
  position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff;
  font-size: .68rem; font-weight: 800; border-radius: 999px; padding: .1em .5em;
}
#theme-toggle { margin-left: auto; }
.view { padding: 1.4em; max-width: 1500px; width: 100%; margin: 0 auto; }
.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 29; }

/* ---------- cards / tables ---------- */
.grid { display: grid; gap: 1em; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 1.2em; box-shadow: var(--shadow); }
.card h3 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-big { font-size: 1.9rem; font-weight: 800; margin: .2em 0; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .82rem; color: var(--muted); }
.kpi-sub b { color: var(--text); }
.pos { color: var(--green); } .neg { color: var(--red); } .warn-t { color: var(--amber); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { text-align: left; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  padding: .7em .6em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: .7em .6em; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:hover td { background: var(--hover); }
.badge {
  display: inline-block; padding: .25em .7em; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap;
}
.b-green { background: rgba(16,185,129,.15); color: var(--green); }
.b-blue { background: rgba(59,130,246,.15); color: var(--accent); }
.b-amber { background: rgba(245,158,11,.16); color: var(--amber); }
.b-red { background: rgba(239,68,68,.14); color: var(--red); }
.b-gray { background: var(--hover); color: var(--muted); }
.b-purple { background: rgba(139,92,246,.15); color: #8B5CF6; }
.plan-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4em; }
.toolbar { display: flex; gap: .7em; align-items: center; flex-wrap: wrap; margin-bottom: 1em; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: .85rem; flex-shrink: 0;
}
.row-flex { display: flex; align-items: center; gap: .7em; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: .7em; flex-wrap: wrap; margin-bottom: 1em; }
.cal-head h2 { margin: 0; font-size: 1.3rem; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: .5em 1em; cursor: pointer; font-weight: 700; font-size: .85rem; }
.seg button.active { background: var(--accent); color: #fff; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; padding: .4em; text-transform: uppercase; }
.cal-day {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; min-height: 118px;
  padding: .45em; cursor: pointer; overflow: hidden;
}
.cal-day:hover { border-color: var(--accent); }
.cal-day.dim { opacity: .38; }
.cal-day.selected { border: 2px solid var(--accent); }
.cal-day.today .day-num { background: var(--accent); color: #fff; }
.day-num { font-size: .78rem; font-weight: 700; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.event-pill {
  font-size: .7rem; border-radius: 8px; padding: .28em .5em; margin-top: 4px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600;
  border: 1px solid transparent;
}
.event-pill:hover { filter: brightness(1.25); }
.ev-paid { background: var(--pill-paid); color: var(--green); border-color: rgba(16,185,129,.4); }
.ev-up { background: var(--pill-up); color: var(--accent); border-color: rgba(59,130,246,.4); }
.ev-issue { background: var(--pill-issue); color: var(--amber); border-color: rgba(245,158,11,.45); }
.ev-cx { background: var(--pill-cx); color: var(--red); border-color: rgba(239,68,68,.4); text-decoration: line-through; }
.ev-refunded { background: var(--hover); color: var(--muted); }
.gw { font-size: .62rem; font-weight: 800; border: 1px solid currentColor; border-radius: 4px; padding: 0 .3em; margin-right: .3em; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-col { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .6em; min-height: 300px; cursor: pointer; }
.week-col.selected { border: 2px solid var(--accent); }
.week-col h4 { font-size: .8rem; color: var(--muted); margin-bottom: .5em; }
.day-list .event-pill { font-size: .85rem; padding: .6em .8em; }
.day-total { font-weight: 800; margin-top: 1em; font-size: 1.05rem; }
.legend { display: flex; gap: 1em; flex-wrap: wrap; font-size: .78rem; color: var(--muted); margin-top: .8em; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: .3em; vertical-align: -1px; }

/* ---------- modal ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1em; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 18px; width: 640px; max-width: 100%;
  max-height: 90vh; overflow: auto; padding: 1.5em; box-shadow: var(--shadow); }
.modal.wide { width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1em; }
.modal-head h3 { margin: 0; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: .4em 1em; font-size: .9rem; margin: .8em 0; }
.kv div span { color: var(--muted); display: block; font-size: .75rem; }
.btn-row { display: flex; gap: .6em; flex-wrap: wrap; margin-top: 1em; }
.tabs { display: flex; gap: .4em; border-bottom: 1px solid var(--border); margin-bottom: 1em; flex-wrap: wrap; }
.tabs button { background: transparent; border: 0; color: var(--muted); padding: .6em .9em; cursor: pointer; font-weight: 700; font-size: .88rem; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.note { border: 1px solid var(--border); border-radius: 12px; padding: .8em; margin-bottom: .7em; background: var(--input); }
.note.pinned { border-color: var(--amber); }
.note-meta { font-size: .75rem; color: var(--muted); margin-bottom: .4em; display: flex; gap: .8em; align-items: center; }
.note-actions { margin-top: .5em; display: flex; gap: .5em; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: .8rem; font-weight: 700; padding: 0; }
.link-btn.danger { color: var(--red); }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 1.2em; right: 1.2em; z-index: 99; display: flex; flex-direction: column; gap: .6em; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: .8em 1.1em; box-shadow: var(--shadow); max-width: 340px; font-size: .88rem; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }

/* ---------- misc ---------- */
.plan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1em; }
.plan-card { cursor: pointer; transition: transform .12s; }
.plan-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.plan-price { font-size: 1.7rem; font-weight: 800; }
.feat-list { font-size: .82rem; color: var(--muted); margin: .6em 0; padding-left: 1.1em; }
.chart-box { width: 100%; }
.chart-box canvas { width: 100%; height: auto; display: block; }
.sim-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8em; }
.sim-card { border: 1px solid var(--border); border-radius: 12px; padding: 1em; background: var(--input); }
.sim-card p { font-size: .82rem; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4em; }
.section-title { margin: 1.6em 0 .8em; font-size: 1.05rem; }
.drawer-list { max-height: 300px; overflow: auto; }
.drawer-item { padding: .7em; border-bottom: 1px solid var(--border); font-size: .85rem; cursor: pointer; }
.drawer-item:hover { background: var(--hover); }
.empty { color: var(--muted); text-align: center; padding: 2em; }

/* ---------- customer cards (phones) ---------- */
.crm-cards { display: none; }
.cust-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1em; margin-bottom: .8em; box-shadow: var(--shadow); }
.cust-card-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .55em .8em; margin: .9em 0; font-size: .86rem; }
.cust-card-meta > div > span:first-child { display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15em; }
.cust-card .btn { flex: 1; text-align: center; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .sidebar.collapsed { margin-left: 0; }
  .only-mobile { display: inline-block; }
  #side-collapse { display: none; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 64px; padding: .25em; }
  .event-pill { font-size: .6rem; }
  .week-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  #theme-toggle { margin-left: 0; }
  .view { padding: .9em; }
}

/* Phones: stacked customer cards instead of the wide table (tablets keep the table) */
@media (max-width: 700px) {
  .crm-table-wrap { display: none; }
  .crm-cards { display: block; }
}

/* ================= Calendar categories + custom events ================= */
.cat-legend { display: flex; flex-wrap: wrap; gap: .5em; align-items: center; padding: .6em .8em; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.cat-legend-label { font-size: .82rem; font-weight: 700; color: #FFFFFF; }
.cat-chip { display: inline-flex; align-items: center; gap: .45em; background: var(--input); border: 1px solid var(--border); color: #FFFFFF; border-radius: 999px; padding: .35em .85em; font-size: .82rem; font-weight: 600; cursor: pointer; }
.cat-chip:hover { border-color: var(--cc, var(--accent)); }
.cat-chip.active { background: var(--cc, var(--accent)); border-color: var(--cc, var(--accent)); color: #fff; }
.cat-chip.clear { color: var(--muted); }
.cat-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.pill-badge { display: inline-block; color: #fff; font-size: .68rem; font-weight: 800; letter-spacing: .04em; padding: .15em .6em; border-radius: 999px; margin-right: .4em; vertical-align: middle; }
.event-pill.ev-custom { background: rgba(168,85,247,.14); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8em; margin-top: .8em; }
.cat-card { background: var(--input); border: 1px solid var(--border); border-radius: 12px; padding: .8em; }
.swatches { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.drawer-sub { font-size: .82rem; color: var(--muted); margin: .2em 0; }
.alert-item { border-left: 3px solid var(--amber); }

/* ================= Notification Studio ================= */
.trig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1em; }
.trig-card h3 { font-size: 1rem; }
.sys-checklist { display: grid; grid-template-columns: 1fr 1fr; gap: .4em; margin-top: .6em; }
.sys-check { display: flex; align-items: center; gap: .5em; font-size: .85rem; color: #FFFFFF; background: var(--input); border: 1px solid var(--border); border-radius: 8px; padding: .5em .7em; cursor: pointer; }
.sys-check input { width: auto; }
.chk { display: inline-flex; align-items: center; gap: .5em; color: #FFFFFF; font-size: .9rem; margin: .4em 0; cursor: pointer; }
.chk input { width: auto; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #475569; border-radius: 999px; cursor: pointer; transition: .2s; }
.switch .slider:before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: #10B981; }
.switch input:checked + .slider:before { transform: translateX(20px); }
.tpl-list { display: flex; flex-direction: column; gap: .5em; margin-top: .8em; }
.tpl-row { display: flex; justify-content: space-between; align-items: center; gap: .8em; background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: .7em .9em; }
.var-pills { display: flex; flex-wrap: wrap; gap: .4em; margin: .5em 0 1em; }
.var-pill { background: #1E293B; border: 1px solid #334155; color: #FFFFFF; border-radius: 999px; padding: .3em .75em; font-size: .76rem; font-family: monospace; cursor: pointer; }
.var-pill:hover { border-color: var(--accent); background: #273549; }
.preview-label { font-size: .78rem; font-weight: 700; color: #FFFFFF; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4em; }
.preview-subj { background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: .6em .9em; margin-bottom: .8em; color: #FFFFFF; }
.preview-split { display: grid; grid-template-columns: 1fr 360px; gap: 1em; align-items: start; }
.email-preview { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #0B1220; }
.email-preview.desktop iframe, .email-preview.mobile iframe { display: block; }
.email-preview table { max-width: 100% !important; }
@media (max-width: 900px) { .preview-split { grid-template-columns: 1fr; } }

/* accordions */
.acc { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .6em; background: var(--input); }
.acc summary { cursor: pointer; padding: .7em .9em; font-weight: 700; color: #FFFFFF; list-style: none; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary:before { content: '▸ '; color: var(--accent); }
.acc[open] summary:before { content: '▾ '; }
.acc-body { padding: 0 .9em .9em; }

/* embed builder */
.modal.xwide { width: 1240px; }
.builder-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1em; flex-wrap: wrap; gap: .6em; }
.builder-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; }
@media (max-width: 1000px) { .builder-split { grid-template-columns: 1fr; } }
.builder-form { max-height: 70vh; overflow: auto; padding-right: .4em; }
.builder-preview { max-height: 70vh; overflow: auto; }
.dc-scroll { background: #313338; border-radius: 12px; padding: .8em; }
.emoji-pop { display: flex; flex-wrap: wrap; gap: .3em; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: .5em; margin-bottom: .5em; }
.emoji-pop button { background: transparent; border: 0; font-size: 1.3rem; cursor: pointer; padding: .15em; border-radius: 6px; }
.emoji-pop button:hover { background: var(--hover); }
.db-field { border: 1px dashed var(--border); border-radius: 10px; padding: .7em; margin-bottom: .6em; }
.payload-pre { background: #0B1220; color: #E2E8F0; border: 1px solid var(--border); border-radius: 10px; padding: .8em; max-height: 320px; overflow: auto; font-size: .78rem; white-space: pre-wrap; word-break: break-word; }
.status-badge { display: inline-block; font-size: .75rem; font-weight: 800; border-radius: 999px; padding: .2em .8em; color: #fff; }
.status-badge.ok { background: #10B981; }
.status-badge.err { background: #EF4444; }
.status-badge.muted { background: #64748B; }
.sim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8em; margin-top: .8em; }
.sim-card { background: var(--input); border: 1px solid var(--border); border-radius: 12px; padding: .9em; }
.sim-card b { color: #FFFFFF; }

/* ---------- authentic Discord dark-mode message ---------- */
.dc-msg { display: flex; gap: .8em; color: #DBDEE1; font-size: .92rem; }
.dc-msg a { color: #00AFF4; text-decoration: none; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #5865F2, #9B59B6); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; flex: none; }
.dc-body { flex: 1; min-width: 0; }
.dc-head { display: flex; align-items: baseline; gap: .5em; margin-bottom: .15em; }
.dc-user { color: #fff; font-weight: 600; }
.dc-bot-tag { background: #5865F2; color: #fff; font-size: .62rem; font-weight: 700; border-radius: 4px; padding: .1em .35em; }
.dc-time { color: #949BA4; font-size: .72rem; }
.dc-content { color: #DBDEE1; margin-bottom: .3em; word-wrap: break-word; }
.dc-mention { background: rgba(88,101,242,.3); color: #DEE0FC; border-radius: 3px; padding: 0 .25em; font-weight: 500; }
.dc-code { background: #2B2D31; border-radius: 4px; padding: .1em .35em; font-family: monospace; font-size: .85em; }
.dc-code-block { background: #2B2D31; border: 1px solid #1E1F22; border-radius: 8px; padding: .6em; font-family: monospace; font-size: .85em; overflow-x: auto; }
.dc-spoiler { background: #4b4e56; color: transparent; border-radius: 3px; padding: 0 .3em; cursor: pointer; }
.dc-embed { display: flex; gap: .8em; background: #2B2D31; border-radius: 8px; border-left: 4px solid var(--eb, #5865F2); padding: .8em .9em; margin-top: .3em; max-width: 520px; }
.dc-embed-main { flex: 1; min-width: 0; }
.dc-author { display: flex; align-items: center; gap: .45em; font-size: .78rem; font-weight: 600; color: #fff; margin-bottom: .4em; }
.dc-author img { width: 20px; height: 20px; border-radius: 50%; }
.dc-title { color: #00AFF4; font-weight: 700; margin-bottom: .35em; }
.dc-desc { color: #DBDEE1; font-size: .88rem; margin-bottom: .4em; }
.dc-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55em; margin: .4em 0; }
.dc-field { min-width: 0; }
.dc-field.inline { grid-column: span 1; }
.dc-field:not(.inline) { grid-column: 1 / -1; }
.dc-field-name { color: #fff; font-weight: 700; font-size: .78rem; margin-bottom: .15em; }
.dc-field-value { color: #DBDEE1; font-size: .85rem; }
.dc-thumb img { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; }
.dc-image img { max-width: 100%; border-radius: 8px; margin-top: .5em; }
.dc-footer { display: flex; align-items: center; gap: .45em; color: #949BA4; font-size: .72rem; font-weight: 500; margin-top: .5em; }
.dc-footer img { width: 18px; height: 18px; border-radius: 50%; }

/* high-contrast pass for new components */
.trig-card p, .sim-card p, .tpl-row .kpi-sub, .builder-form p { color: #FFFFFF; }
.kpi-sub { color: #CBD5E1; }
[data-theme="light"] .trig-card p, [data-theme="light"] .sim-card p,
[data-theme="light"] .tpl-row .kpi-sub, [data-theme="light"] .cat-legend-label,
[data-theme="light"] .chk, [data-theme="light"] .sys-check,
[data-theme="light"] .cat-chip, [data-theme="light"] .preview-label,
[data-theme="light"] .preview-subj, [data-theme="light"] .sim-card b,
[data-theme="light"] .acc summary { color: #0F172A; }

/* ---------- Site & Branding + File Manager ---------- */
.color-row { display: flex; align-items: center; gap: .8em; padding: .55em 0; border-bottom: 1px solid var(--border); }
.color-row:last-child { border-bottom: 0; }
.color-row input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--input); cursor: pointer; flex-shrink: 0; }
.color-row .color-meta { flex: 1; min-width: 0; }
.color-row .color-meta b { display: block; font-size: .88rem; }
.color-row .color-meta span { font-size: .75rem; color: var(--muted); display: block; }
.color-row .color-meta code { font-size: .75rem; color: var(--muted); font-family: ui-monospace, monospace; }
.color-row .hex-in { width: 86px; flex-shrink: 0; font-family: ui-monospace, monospace; text-transform: uppercase; }
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 90px; border: 1px dashed var(--border); border-radius: 12px; margin-bottom: .8em; background: var(--input); }
.logo-preview img { max-width: 220px; max-height: 90px; object-fit: contain; }
.brand-preview { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.bp-bar { height: 8px; }
.bp-body { padding: 1em; background: var(--input); }
.bp-brand { display: flex; align-items: center; gap: .7em; margin-bottom: .8em; }
.bp-brand img { max-width: 120px; max-height: 40px; object-fit: contain; }
.bp-foot { font-size: .75rem; margin-top: .8em; }
.fm-toolbar { display: flex; gap: .8em; align-items: center; flex-wrap: wrap; margin-bottom: 1em; }
.fm-toolbar input { flex: 1; min-width: 180px; }
.fm-toolbar select { width: auto; }
.fm-summary { margin-left: auto; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.dropzone { border: 2px dashed var(--border); border-radius: 14px; padding: 1.6em; text-align: center; margin-bottom: 1.2em; color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: rgba(59,130,246,.06); color: var(--text); }
.dropzone .fm-hint { font-size: .78rem; margin-top: .4em; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9em; }
.file-grid.sm { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.file-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .7em; cursor: pointer; transition: border-color .15s, transform .15s; }
.file-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.file-card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.file-thumb { height: 90px; display: flex; align-items: center; justify-content: center; background: var(--input); border-radius: 8px; overflow: hidden; margin-bottom: .5em; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-glyph { font-size: 2.2rem; }
.file-glyph.sm { font-size: 1.4rem; }
.file-glyph.big { font-size: 4rem; }
.file-name { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: .72rem; color: var(--muted); }
.row-thumb { width: 44px; height: 32px; object-fit: cover; border-radius: 6px; }
.file-preview { display: flex; justify-content: center; margin-bottom: 1em; background: var(--input); border-radius: 12px; padding: 1em; }
.file-preview img { max-width: 100%; max-height: 320px; object-fit: contain; border-radius: 8px; }
.kv { display: grid; gap: .4em; margin-bottom: .6em; }
.kv > div { display: flex; gap: .8em; font-size: .85rem; }
.kv span { color: var(--muted); width: 90px; flex-shrink: 0; }
.kv .url-code { font-size: .75rem; word-break: break-all; }

/* ---------- Cloud Backups ---------- */
.note-card { border-left: 4px solid var(--accent); }
.prov-card h3 { display: flex; align-items: center; gap: .5em; flex-wrap: wrap; }
.guide-box { margin-top: 1em; background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: .8em 1em; }
.guide-box summary { cursor: pointer; font-weight: 600; }
.guide { margin: .8em 0 .2em; padding-left: 1.4em; font-size: .88rem; }
.guide li { margin-bottom: .55em; }
.guide .uri, code.uri { display: inline-block; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .25em .5em; font-size: .78rem; word-break: break-all; margin-top: .3em; }
.chk-row { display: flex; gap: 1.2em; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: .4em; font-size: .9rem; cursor: pointer; }
.chk input { width: auto; }
.restore-warn { background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.5); border-radius: 12px; padding: 1em 1.2em; margin-bottom: 1em; }
.restore-warn p { color: var(--text); }

/* ---------- Productivity features ---------- */
.qs-results { max-height: 420px; overflow: auto; }
.qs-group { margin-bottom: .9em; }
.qs-group-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .4em; }
.qs-item { display: flex; align-items: center; gap: .7em; padding: .55em .7em; border-radius: 10px; cursor: pointer; }
.qs-item:hover { background: var(--hover); }
.kbd-hint { font-size: .72rem; color: var(--muted); font-weight: 400; }

.pin-strip { display: flex; gap: .6em; flex-wrap: wrap; margin-top: .6em; }
.pin-chip { display: flex; align-items: center; gap: .6em; background: var(--input); border: 1px solid var(--border); border-radius: 12px; padding: .45em .7em; cursor: pointer; min-width: 180px; }
.pin-chip:hover { background: var(--hover); }
.pin-btn.on { border-color: var(--accent); background: rgba(59,130,246,.12); }

.dash-widgets { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.dash-widget h3 { font-size: .95rem; margin-bottom: .6em; }
.calc-out .kv > div { justify-content: space-between; }

#sp-text { min-height: 110px; resize: vertical; }

.recent-dropdown { position: absolute; top: 100%; right: 0; width: 340px; max-height: 420px; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); z-index: 200; padding: .6em; margin-top: .4em; }
.topbar { position: relative; }
.recent-item { display: flex; gap: .7em; align-items: flex-start; padding: .55em .6em; border-radius: 10px; cursor: pointer; }
.recent-item:hover { background: var(--hover); }

.dp-row { display: flex; align-items: center; gap: .7em; padding: .5em .4em; border-bottom: 1px solid var(--border); }
.dp-row input[type="checkbox"] { width: auto; }

.dup-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .8em; }
.dup-col { background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: .8em; }
@media (max-width: 640px) { .dup-cols { grid-template-columns: 1fr; } }

tr.row-selected { background: rgba(59,130,246,.08); }
#crm-bulkbar { align-items: center; }

.pos { color: var(--green); }
.neg { color: var(--red); }
