/* D&D Energy CRM — design tokens */
@import url('https://fonts.googleapis.com/css2?family=Georama:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Brand */
  --navy-900: #0e2744;
  --navy-800: #133258;
  --navy-700: #1a3f6b;
  --navy-600: #23507f;
  --navy-500: #3a6da0;
  --navy-400: #6a91bb;
  --blue-100: #e6eef7;
  --blue-50:  #f1f5fb;
  --bg:       #f6f8fc;
  --card:     #ffffff;
  --border:   #e2e8f0;
  --border-strong: #cbd5e1;
  --ink-900:  #0b1a2e;
  --ink-700:  #2a3a52;
  --ink-500:  #5b6b82;
  --ink-400:  #8695ab;
  --ink-300:  #aab6c7;

  --amber-500: #f3a712;
  --amber-400: #f6bf47;
  --amber-100: #fdefc9;

  --green-500: #2a9d5f;
  --green-100: #dcf3e5;
  --red-500:   #d64545;
  --red-100:   #fce1e1;

  /* Type */
  --font: 'Georama', system-ui, -apple-system, sans-serif;

  /* Radius + spacing (kompakt) */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(14,39,68,0.06);
  --shadow-md: 0 2px 6px rgba(14,39,68,0.08), 0 1px 2px rgba(14,39,68,0.04);
  --shadow-lg: 0 10px 30px rgba(14,39,68,0.12);
}

* { box-sizing: border-box; }

body, html {
  margin: 0;
  font-family: var(--font);
  color: var(--ink-900);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

.app {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink-900);
  width: 100%;
  height: 100%;
  display: flex;
  overflow: hidden;
}

/* ───── Sidebar ───── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy-900);
  color: #e6eef7;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #081a2f;
}
.sidebar.collapsed { width: 56px; }

.sb-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: 56px;
}
.sb-logo-mark {
  width: 32px; height: 32px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f6bf47, #f3a712 60%, #c47a00);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18), 0 0 0 2px #0e2744;
  flex-shrink: 0;
  position: relative;
}
.sb-logo-mark::after{
  content:'';position:absolute;inset:6px;border-radius:50%;
  background:conic-gradient(from 200deg,#fff3c4 0deg,transparent 90deg);
  opacity:.5;
}
.sb-logo-text { font-weight: 800; font-size: 14px; letter-spacing: 0.02em; }
.sb-logo-text small {
  display: block; font-weight: 400; font-size: 9.5px; color: #8ea8c9; letter-spacing: 0.16em; text-transform: uppercase;
}

.sb-section {
  padding: 14px 14px 4px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: #6a8bb3; font-weight: 600;
}

.sb-nav {
  padding: 4px 8px;
  display: flex; flex-direction: column; gap: 1px;
  flex: 1; overflow: auto;
}
.sb-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  color: #b8c9e0; font-size: 13px; font-weight: 500;
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
}
.sb-nav a:hover { background: rgba(255,255,255,0.04); color: #fff; }
.sb-nav a.active {
  background: linear-gradient(180deg, #1a3f6b, #133258);
  color: #fff;
  border-color: rgba(246,191,71,0.25);
  box-shadow: inset 2px 0 0 var(--amber-500);
}
.sb-nav a .badge {
  margin-left: auto;
  background: var(--amber-500); color: #1a1200;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  min-width: 18px; text-align: center;
}
.sb-nav a .ico {
  width: 16px; height: 16px; flex-shrink: 0; opacity: .9;
}

.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sb-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #f6bf47, #f3a712);
  display: flex; align-items: center; justify-content: center;
  color: #1a1200; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.sb-user-name { font-size: 12px; font-weight: 600; color: #fff; line-height: 1.2; }
.sb-user-role { font-size: 10.5px; color: #8ea8c9; }

/* ───── Topbar ───── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  height: 48px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 14px;
  flex-shrink: 0;
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-500); }
.crumbs b { color: var(--ink-900); font-weight: 600; }
.crumbs .sep { color: var(--ink-300); }

.topbar-search {
  margin-left: auto;
  width: 280px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px 0 30px;
  font-family: var(--font);
  font-size: 12.5px;
  background: var(--bg);
  color: var(--ink-900);
}
.topbar-search input:focus { outline: none; border-color: var(--navy-500); background: #fff; }
.topbar-search .ico { position: absolute; left: 9px; top: 7px; color: var(--ink-400); }
.topbar-search kbd {
  position: absolute; right: 8px; top: 6px;
  font-family: var(--font); font-size: 10px; color: var(--ink-500);
  border: 1px solid var(--border-strong); padding: 0 5px; border-radius: 3px; height: 18px; line-height: 17px;
  background: #fff;
}

/* Hamburger button — shown only below 720px (via media query override) */
.topbar-menu-btn { display: none; }

.topbar-btn {
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-700);
  position: relative;
}
.topbar-btn:hover { background: var(--bg); }
.topbar-btn .dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber-500); border: 2px solid #fff;
}

.launcher-btn {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff; cursor: pointer;
  font-family: var(--font); font-size: 12px; font-weight: 500; color: var(--ink-700);
}
.launcher-btn:hover { background: var(--bg); }

/* ───── Content ───── */
.content {
  flex: 1; overflow: auto;
  padding: 18px 20px;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 14px; gap: 16px;
}
.page-head h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.page-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-500); }
.page-head-actions { display: flex; gap: 8px; }

/* ───── Buttons ───── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: var(--font); font-weight: 500; font-size: 12.5px; color: var(--ink-900);
  cursor: pointer;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  background: var(--navy-800); border-color: var(--navy-900); color: #fff;
}
.btn-primary:hover { background: var(--navy-700); }
.btn-amber {
  background: var(--amber-500); border-color: #d8900a; color: #1a1200;
}
.btn-amber:hover { background: var(--amber-400); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(14,39,68,0.06); }
.btn-danger { color: var(--red-500); border-color: var(--border); }
.btn-danger:hover { background: var(--red-100); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 11.5px; }
.btn-xs { height: 22px; padding: 0 6px; font-size: 11px; border-radius: 4px; }

/* ───── Cards / panels ───── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.card-head .muted { color: var(--ink-500); font-size: 11.5px; font-weight: 400; }
.card-body { padding: 14px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 12px 14px; position: relative; overflow: hidden;
}
.kpi .label { font-size: 11px; color: var(--ink-500); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.kpi .delta { font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; margin-top: 4px; }
.kpi .delta.up { color: var(--green-500); }
.kpi .delta.down { color: var(--red-500); }
.kpi .spark { position: absolute; right: 10px; bottom: 10px; opacity: .6; }

.kpi.accent {
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  color: #fff; border-color: var(--navy-900);
}
.kpi.accent .label { color: #a6c0df; }
.kpi.accent .value { color: #fff; }

/* ───── Tables ───── */
table.tbl {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 12.5px;
}
table.tbl th {
  text-align: left; font-weight: 600; color: var(--ink-500);
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--blue-50);
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  position: sticky; top: 0;
}
table.tbl td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.tbl tr:hover td { background: var(--blue-50); }
table.tbl tr.sel td { background: #fff8e4; }
table.tbl tr:last-child td { border-bottom: none; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--blue-100); color: var(--navy-800);
  border: 1px solid transparent;
}
.chip.green { background: var(--green-100); color: #135e37; }
.chip.amber { background: var(--amber-100); color: #7d5500; }
.chip.red   { background: var(--red-100); color: #7c1d1d; }
.chip.gray  { background: #eef2f7; color: var(--ink-500); }
.chip.navy  { background: var(--navy-800); color: #fff; }
.chip.dot::before{ content:''; width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.9; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; color: var(--ink-700); font-weight: 500; }
.field .hint { font-size: 11px; color: var(--ink-500); }
.input, .select, .textarea {
  height: 30px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 0 10px;
  font-family: var(--font); font-size: 12.5px; color: var(--ink-900);
  background: #fff;
}
.textarea { height: auto; padding: 8px 10px; min-height: 60px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--navy-500); box-shadow: 0 0 0 3px rgba(58,109,160,0.18); }

.checkbox {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; cursor: pointer;
}
.checkbox input { margin: 0; accent-color: var(--navy-700); }

.toggle {
  width: 32px; height: 18px; border-radius: 999px;
  background: var(--border-strong); position: relative; cursor: pointer;
  transition: background .15s;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: left .15s;
}
.toggle.on { background: var(--navy-700); }
.toggle.on::after { left: 16px; }

/* Login */
.auth-wrap {
  width: 100%; height: 100%;
  display: flex;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700) 60%, var(--navy-600));
  position: relative; overflow: hidden;
}
.auth-wrap::before {
  content:''; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(246,191,71,0.18), transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(58,109,160,0.3), transparent 45%);
}
.auth-left {
  flex: 1; color: #fff;
  padding: 48px 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
}
.auth-logo { display: flex; align-items: center; gap: 12px; }
.auth-logo .sb-logo-mark { width: 40px; height: 40px; }
.auth-logo-text { font-weight: 800; font-size: 16px; letter-spacing: 0.02em; }
.auth-logo-text small { display:block; font-weight: 400; font-size: 10.5px; color: #a6c0df; letter-spacing: 0.2em; text-transform: uppercase; }

.auth-tagline h2 { font-size: 34px; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.02em; line-height: 1.1; }
.auth-tagline h2 span { color: var(--amber-400); }
.auth-tagline p { color: #b8c9e0; max-width: 420px; font-size: 14px; line-height: 1.5; }

.auth-foot { font-size: 11.5px; color: #7a97bd; display: flex; gap: 20px; }

.auth-right {
  width: 440px;
  background: #fff;
  padding: 48px 44px;
  display: flex; flex-direction: column; justify-content: center;
  position: relative; z-index: 1;
}
.auth-right h3 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.auth-right .sub { font-size: 13px; color: var(--ink-500); margin-bottom: 24px; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .input { height: 38px; font-size: 13.5px; }
.auth-form .field label { font-size: 12.5px; font-weight: 600; }
.btn-lg { height: 38px; padding: 0 16px; font-size: 13.5px; font-weight: 600; }

.row-between { display: flex; justify-content: space-between; align-items: center; }

/* 2FA otp boxes */
.otp-row { display: flex; gap: 8px; justify-content: center; }
.otp-box {
  width: 46px; height: 54px;
  border: 1.5px solid var(--border-strong); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 600; color: var(--navy-900);
  background: #fff;
}
.otp-box.filled { border-color: var(--navy-700); background: var(--blue-50); }
.otp-box.focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(58,109,160,0.22); }

/* Sparkline svg defaults */
svg { display: block; }

/* Segmented */
.seg {
  display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff;
}
.seg button {
  border: none; background: transparent;
  font-family: var(--font); font-size: 12px; font-weight: 500; color: var(--ink-500);
  padding: 6px 12px; cursor: pointer;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--navy-800); color: #fff; }

/* Filters bar */
.filters {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filters .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  background: transparent; border: none; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--ink-500);
  padding: 8px 14px; position: relative;
}
.tabs button.active { color: var(--navy-900); font-weight: 600; }
.tabs button.active::after {
  content:''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--amber-500);
}

/* Module tile */
.mod-tile {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px; display: flex; flex-direction: column; gap: 8px;
  position: relative; transition: all .15s;
}
.mod-tile:hover { border-color: var(--navy-400); box-shadow: var(--shadow-md); }
.mod-tile .mod-ico {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--blue-100); color: var(--navy-700);
  display: flex; align-items: center; justify-content: center;
}
.mod-tile.off { opacity: 0.55; background: #fafbfd; }
.mod-tile.off .mod-ico { background: #eef2f7; color: var(--ink-400); }
.mod-tile h4 { margin: 0; font-size: 13.5px; font-weight: 600; }
.mod-tile p { margin: 0; font-size: 11.5px; color: var(--ink-500); line-height: 1.4; }
.mod-tile .mod-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.mod-tile .mod-users { font-size: 11px; color: var(--ink-500); }

/* permission matrix */
.perm-matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.perm-matrix th, .perm-matrix td {
  border-bottom: 1px solid var(--border);
  padding: 6px 10px; text-align: center;
  vertical-align: middle;
}
.perm-matrix th.lbl, .perm-matrix td.lbl { text-align: left; }
.perm-matrix thead th {
  background: var(--blue-50); font-size: 10.5px; color: var(--ink-500);
  letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600;
}
.perm-matrix tbody tr:hover td { background: var(--blue-50); }

/* Clickable permission cell — full button with Áno/Nie state, optimistic updates */
.perm-cell {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 58px; height: 26px; padding: 0 10px;
  border: 1px solid transparent; border-radius: 999px;
  font-family: var(--font); font-size: 11.5px; font-weight: 600;
  cursor: pointer; transition: background .12s, border-color .12s, transform .08s;
  user-select: none;
}
.perm-cell.on {
  background: var(--green-100);
  color: #135e37;
  border-color: rgba(42,157,95,0.35);
}
.perm-cell.on:hover:not(.disabled) {
  background: #b8e6c9;
  border-color: var(--green-500);
}
.perm-cell.off {
  background: #f4f6fa;
  color: var(--ink-400);
  border-color: var(--border);
}
.perm-cell.off:hover:not(.disabled) {
  background: #fee2e2;
  color: #7c1d1d;
  border-color: rgba(214,69,69,0.3);
}
.perm-cell:active:not(.disabled) { transform: scale(0.96); }
.perm-cell.disabled { cursor: not-allowed; opacity: 0.55; }

/* keep legacy class for any remaining usages */
.dot-perm {
  width: 16px; height: 16px; border-radius: 4px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.dot-perm.y { background: var(--green-100); color: #135e37; }
.dot-perm.n { background: #f2f4f7; color: var(--ink-300); }
.dot-perm.p { background: var(--amber-100); color: #7d5500; }

/* utility */
.hstack { display: flex; align-items: center; gap: 8px; }
.vstack { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--ink-500); }
.small { font-size: 11.5px; }
.mono { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 12px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* order detail 2-col */
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }

/* Timeline */
.tl { position: relative; padding-left: 18px; }
.tl::before { content:''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl .tl-item { position: relative; padding: 0 0 12px; font-size: 12px; }
.tl .tl-item::before {
  content:''; position: absolute; left: -15px; top: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: #fff; border: 2px solid var(--navy-500);
}
.tl .tl-item .t { font-size: 11px; color: var(--ink-500); }

/* ───── Auth — interactive additions ───── */
.input-wrap { position: relative; }
.input-wrap .input { width: 100%; padding-left: 34px; }
.input-wrap .input-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-400); pointer-events: none;
}
.input-wrap .input-action {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 6px;
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-500);
  display: flex; align-items: center; justify-content: center;
}
.input-wrap .input-action:hover { background: var(--blue-50); color: var(--navy-700); }
.input-wrap .input-action:focus-visible { outline: 2px solid var(--navy-500); outline-offset: 1px; }

.input.is-invalid { border-color: var(--red-500); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(214,69,69,0.18); }

.field-err { font-size: 11.5px; color: var(--red-500); margin-top: 2px; }
.field-warn { font-size: 11.5px; color: #8a5a00; margin-top: 2px; display: inline-flex; align-items: center; gap: 4px; }

.auth-alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--red-100); color: #7c1d1d;
  font-size: 12.5px; font-weight: 500;
  border: 1px solid rgba(214,69,69,0.25);
  margin-bottom: 12px;
}
.auth-alert svg { flex-shrink: 0; }

.auth-badge {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--blue-100); color: var(--navy-700);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

.btn-block { width: 100%; justify-content: center; }
.btn-sso {
  background: #fff; color: var(--ink-900); border-color: var(--border-strong);
  font-weight: 600;
}
.btn-sso:hover { background: var(--bg); }

.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary:disabled { background: var(--navy-700); }

.auth-sep {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-400); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  margin: 6px 0 2px;
}
.auth-sep::before, .auth-sep::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.auth-links {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 6px; font-size: 12px; margin-top: 6px;
}
.auth-links a {
  color: var(--navy-700); font-weight: 500; cursor: pointer; text-decoration: none;
}
.auth-links a:hover { text-decoration: underline; }
.auth-links a.muted { color: var(--ink-500); font-weight: 400; }
.auth-links a.disabled { color: var(--ink-400); pointer-events: none; }
.auth-links .sep { color: var(--ink-300); }

.link-muted {
  font-size: 11.5px; color: var(--navy-700); text-decoration: none; font-weight: 500; cursor: pointer;
}
.link-muted:hover { text-decoration: underline; }

/* honeypot — invisible, but still submittable; not display:none (bots skip those) */
.hp-trap {
  position: absolute; left: -9999px; top: -9999px;
  width: 1px; height: 1px; overflow: hidden;
}

/* 2FA — interactive inputs */
.otp-box {
  font-family: var(--font);
  outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
  padding: 0;
  text-align: center;
}
.otp-box:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(58,109,160,0.22); background: #fff; }

/* loader spin */
.spin { animation: dd-spin 0.85s linear infinite; }
@keyframes dd-spin { to { transform: rotate(360deg); } }

/* ───── Modal ───── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(14, 39, 68, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: dd-fade 0.15s ease;
}
.modal {
  background: #fff; border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 100%;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  animation: dd-pop 0.15s ease;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}
@keyframes dd-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dd-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Select in compact tables */
table.tbl .select { height: 26px; font-size: 11.5px; padding: 0 6px; }

/* AI typing dots */
.typing {
  display: inline-block;
  font-size: 14px;
  letter-spacing: 3px;
  animation: dd-typing 1.4s infinite;
}
@keyframes dd-typing {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* Responsive — CRM sa prispôsobí tabletu aj mobilu */
@media (max-width: 1024px) {
  .sidebar { width: 56px !important; }
  .sb-logo-text, .sb-nav a span:not(.badge), .sb-user-name, .sb-user-role, .sb-section { display: none; }
  .sb-logo { justify-content: center; padding: 14px 8px; }
  .sb-nav a { justify-content: center; padding: 8px; position: relative; }
  .sb-nav a .badge { position: absolute; top: 2px; right: 2px; }
  .sb-user { justify-content: center; padding: 10px 8px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .auth-right { width: 420px; }
}

@media (max-width: 820px) {
  .auth-wrap { flex-direction: column; }
  .auth-left {
    flex: 0 0 auto;
    padding: 24px 24px 18px;
    background: transparent;
  }
  .auth-tagline { display: none; }
  .auth-foot { display: none; }
  .auth-right {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 22px 22px 28px;
    border-radius: 14px 14px 0 0;
    flex: 1;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  /* Sidebar becomes an off-canvas drawer that slides in when body.sidebar-open */
  .sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: 260px !important;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 1100;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    display: flex !important;   /* override previous display:none from older rules */
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  /* expanded version of sidebar contents when drawer is open — reset the 1024 collapse */
  .sidebar .sb-logo-text,
  .sidebar .sb-nav a span:not(.badge),
  .sidebar .sb-user-name,
  .sidebar .sb-user-role,
  .sidebar .sb-section { display: block !important; }
  .sidebar .sb-logo { justify-content: flex-start; padding: 14px 14px; }
  .sidebar .sb-nav a { justify-content: flex-start; padding: 7px 10px; }
  .sidebar .sb-nav a .badge { position: static; }
  .sidebar .sb-user { justify-content: flex-start; padding: 10px 12px; }

  /* Backdrop behind the drawer */
  body.sidebar-open::before {
    content: '';
    position: fixed; inset: 0;
    background: rgba(11, 26, 46, 0.5);
    z-index: 1050;
    animation: dd-fade 0.15s ease;
  }

  .topbar-menu-btn {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink-700);
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 4px;
  }
  .topbar-menu-btn:hover { background: var(--bg); }

  .topbar { padding: 0 12px; gap: 8px; }
  .launcher-btn span { display: none; }
  .content { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .page-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-head-actions { flex-wrap: wrap; width: 100%; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi .value { font-size: 18px; }
  .filters { flex-direction: column; align-items: stretch; gap: 6px; }
  .filters > * { width: 100%; }
  table.tbl { font-size: 11.5px; }
  table.tbl th, table.tbl td { padding: 6px 8px; }

  /* Auth on phones */
  .auth-right { padding: 18px 16px 24px; }
  .auth-right h3 { font-size: 18px; }
  .auth-right .sub { font-size: 12.5px; margin-bottom: 16px; }
  .auth-form { gap: 12px; }
  /* Touch-friendly minimum */
  .auth-form .input { height: 42px; font-size: 14px; }
  .btn-lg { height: 44px; font-size: 14px; }
  .otp-row { gap: 6px; }
  .otp-box { width: 14vw; max-width: 48px; min-width: 38px; height: 54px; font-size: 22px; }
  .auth-logo-text { font-size: 14px; }
}

@media (max-width: 380px) {
  .otp-box { font-size: 20px; height: 50px; }
  .auth-left { padding: 18px 16px 12px; }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
  .splash .dot { animation: none; }
  * { transition: none !important; }
}


/* ───── AI Asistent ───── */
.ai-avatar { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.ai-avatar-user { background: var(--navy-700); color: #fff; }
.ai-avatar-bot  { background: linear-gradient(135deg, var(--amber-500), var(--amber-400)); color: #1a1200; }

/* ───── AI chat bubbles + Markdown rendering ───── */
.ai-bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-900);
  overflow-wrap: anywhere;
}
.ai-bubble-user { }
.ai-bubble-err  { background: var(--red-100); border-color: #fecaca; color: #7c1d1d; }

.ai-md :first-child { margin-top: 0; }
.ai-md :last-child  { margin-bottom: 0; }
.ai-md p    { margin: 0 0 10px; }
.ai-md h1, .ai-md h2, .ai-md h3, .ai-md h4 { margin: 14px 0 6px; font-weight: 700; color: var(--navy-900); }
.ai-md h1 { font-size: 18px; }
.ai-md h2 { font-size: 16px; }
.ai-md h3 { font-size: 14.5px; }
.ai-md ul, .ai-md ol { margin: 6px 0 10px; padding-left: 22px; }
.ai-md li { margin: 3px 0; }
.ai-md a  { color: var(--navy-700); text-decoration: underline; text-underline-offset: 2px; }
.ai-md a:hover { color: var(--navy-900); }
.ai-md strong { color: var(--navy-900); font-weight: 600; }
.ai-md em { color: var(--ink-700); }
.ai-md code {
  background: var(--blue-50);
  border: 1px solid rgba(10,61,98,0.12);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--navy-800);
}
.ai-md pre {
  background: var(--blue-50);
  border: 1px solid rgba(10,61,98,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 12px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
}
.ai-md pre code { background: transparent; border: none; padding: 0; }
.ai-md blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--amber-500);
  background: #fff8e7;
  color: var(--ink-700);
  border-radius: 4px;
}
.ai-md hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* Markdown tables → SF-style clean look */
.ai-md table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0 12px;
  font-size: 12.5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.ai-md thead { background: var(--blue-50); }
.ai-md th, .ai-md td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.ai-md th {
  font-weight: 600;
  color: var(--ink-700);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-strong);
}
.ai-md tbody tr:last-child td { border-bottom: none; }
.ai-md tbody tr:hover { background: var(--blue-50); }
.ai-md td .mono, .ai-md td code { font-weight: 600; }

/* ───── AI chat meta chips (per-message + context strip) ───── */
.ai-context-strip {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(180deg, var(--blue-50) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.ai-meta {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-top: 6px;
  padding: 4px 2px;
  align-items: center;
}
.ai-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-700);
  background: #fff;
  border: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.ai-chip svg { width: 11px; height: 11px; flex-shrink: 0; }
.ai-chip-model {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #fcd34d;
  color: #78350f;
  font-weight: 600;
}
.ai-chip-skill {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #3730a3;
  font-weight: 600;
}
.ai-chip-tool {
  background: #d1fae5;
  border-color: #86efac;
  color: #065f46;
  font-weight: 600;
}
.ai-chip-tok {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: var(--ink-700);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
}
.ai-chip-tag {
  display: inline-flex; align-items: center;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(0,0,0,0.08);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.ai-tools-trace { margin-top: 6px; }
.ai-tools-trace summary { cursor: pointer; padding: 2px 4px; }
.ai-tools-trace summary:hover { color: var(--navy-700); }
.ai-tools-trace[open] summary { color: var(--navy-700); font-weight: 500; }
.ai-tools-trace code {
  background: var(--blue-50);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   AI ASISTENT — LAYOUT + RESPONSIVE (consolidated, mobile-first overrides at bottom)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Layout shell ── */
.ai-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100dvh - 140px);
}
.ai-content { min-width: 0; }

/* ── Sub-sidebar (left nav) ── */
.ai-subnav {
  padding: 8px 6px;
  height: fit-content;
  position: sticky;
  top: 72px;
}
.ai-subnav-list { display: flex; flex-direction: column; gap: 2px; padding: 4px; }
.ai-subnav-section {
  font-size: 10px; font-weight: 600;
  color: var(--ink-500);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 10px 10px 4px;
}
.ai-subnav-section:first-child { padding-top: 4px; }
.ai-subnav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-700);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.ai-subnav-item:hover { background: var(--blue-50); }
.ai-subnav-item.is-active {
  background: var(--blue-100);
  color: var(--navy-900);
  box-shadow: inset 2px 0 0 var(--amber-500);
  font-weight: 500;
}
.ai-subnav-item svg { flex-shrink: 0; }
.ai-subnav-badge {
  margin-left: auto;
  background: var(--amber-500);
  color: #1a1200;
  font-weight: 700;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ── Chat container ── */
.ai-chat {
  display: flex; flex-direction: column;
  min-height: calc(100dvh - 170px);
  min-width: 0;
  overflow: hidden;
}
.ai-chat-head { gap: 10px; flex-wrap: wrap; }
.ai-chat-head-actions { display: flex; gap: 6px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.ai-model-select { width: 200px; max-width: 100%; padding: 5px 6px; }

.ai-chat-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 18px; }
.ai-chat-messages { max-width: 860px; margin: 0 auto; }

.ai-chat-empty { text-align: center; max-width: 780px; margin: 30px auto; padding: 0 10px; }
.ai-chat-empty-badge {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--navy-800), var(--navy-500));
  display: grid; place-items: center;
  margin: 0 auto 18px;
  box-shadow: 0 8px 30px rgba(19,50,88,0.3);
  color: #fff;
}
.ai-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.ai-suggestion {
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ai-suggestion:hover { background: var(--blue-50); }
.ai-suggestion-label { font-size: 12.5px; font-weight: 500; }
.ai-suggestion-prompt { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Input bar ── */
.ai-chat-input-wrap {
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.ai-chat-last-meta { max-width: 860px; margin: 0 auto 8px; }
.ai-chat-input {
  max-width: 860px; margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px;
}
.ai-chat-textarea {
  width: 100%;
  border: none; outline: none; resize: none;
  font-family: var(--font);
  font-size: 13.5px;
  min-height: 44px;
  padding: 4px 6px;
  background: transparent;
}
.ai-chat-input-bar { margin-top: 6px; }
.ai-send-btn { margin-left: auto; flex-shrink: 0; }

/* ── Form rows + stats grid ── */
.ai-form-row { display: flex; gap: 10px; flex-wrap: nowrap; align-items: stretch; }
.ai-form-col-narrow { width: 180px; flex-shrink: 0; }
.ai-form-col-checks { width: 220px; flex-shrink: 0; }
.ai-stats-grid { padding: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ai-stat-card { padding: 14px; }
.ai-stat-value { font-size: 22px; font-weight: 700; }

/* ── Tables (horizontal scroll) ── */
.ai-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ai-table-wrap table.tbl { width: 100%; min-width: 560px; }

/* ── Approvals ── */
.ai-approval-item { padding: 14px; border-bottom: 1px solid var(--border); }
.ai-approval-item:last-child { border-bottom: none; }
.ai-approval-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.ai-approval-kind { padding: 2px 8px; text-transform: uppercase; font-size: 10px; letter-spacing: 0.08em; flex-shrink: 0; }
.ai-approval-meta { flex: 1; min-width: 160px; }
.ai-approval-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.ai-btn-approve { background: var(--green-100); color: #135e37; border-color: transparent; }
.ai-approval-content { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; white-space: pre-wrap; overflow-wrap: break-word; }

/* ── Skill Builder modal body ── */
.ai-builder-body { display: flex; flex-direction: column; height: min(70vh, 620px); margin: -4px -4px 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   TABLET (≤ 980 px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 980px) {
  .ai-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }

  .ai-subnav {
    position: sticky; top: 56px;
    padding: 4px;
    overflow: hidden;
    z-index: 5;
  }
  .ai-subnav-list {
    flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 4px; gap: 6px;
  }
  .ai-subnav-section {
    flex-shrink: 0;
    padding: 6px 8px 6px 10px;
    align-self: center;
    border-left: 1px solid var(--border);
  }
  .ai-subnav-section:first-child { border-left: none; padding-left: 4px; }
  .ai-subnav-item {
    flex-shrink: 0; white-space: nowrap;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 12.5px;
    box-shadow: none !important;
  }
  .ai-subnav-item.is-active {
    background: var(--navy-700);
    color: #fff;
    border-color: var(--navy-700);
  }
  .ai-subnav-item.is-active svg { color: #fff; }
  .ai-subnav-badge { margin-left: 4px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE (≤ 640 px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Layout */
  .ai-layout { grid-template-columns: minmax(0, 1fr); gap: 8px; min-height: calc(100dvh - 110px); }

  /* Chat container */
  .ai-chat { min-height: calc(100dvh - 190px); border-radius: 8px; }

  /* Chat header — hide title on mobile, put select + Nový on ONE row */
  .ai-chat-head { padding: 10px 12px; align-items: center; flex-wrap: nowrap; gap: 8px; }
  .ai-chat-head h3 { display: none; }
  .ai-chat-head-actions { flex: 1; display: flex; gap: 6px; margin-left: 0; flex-wrap: nowrap; align-items: center; }
  .ai-model-select {
    flex: 1 1 auto; min-width: 0; width: auto;
    font-size: 16px; /* iOS no-zoom */
    height: 36px;
  }
  .ai-chat-head-actions .btn-sm { flex-shrink: 0; height: 36px; padding: 0 10px; }

  /* Context strip — horizontal scroll */
  .ai-context-strip { padding: 6px 10px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 5px; }
  .ai-context-strip > * { flex-shrink: 0; }
  .ai-chip-convo-id { margin-left: 0 !important; }

  /* Chat messages */
  .ai-chat-scroll { padding: 10px; }
  .ai-chat-messages { max-width: 100%; }
  .ai-bubble { padding: 8px 10px; font-size: 13px; }
  .ai-avatar { width: 28px; height: 28px; font-size: 10px; }

  .ai-md table { font-size: 11.5px; display: block; overflow-x: auto; }
  .ai-md th, .ai-md td { padding: 5px 7px; }
  .ai-md pre { font-size: 11px; padding: 8px; white-space: pre-wrap; }

  .ai-meta { gap: 3px; }
  .ai-chip { font-size: 10px; padding: 1px 6px; }
  .ai-chip-tag { font-size: 8.5px; padding: 0 3px; }

  /* Input bar */
  .ai-chat-input-wrap { padding: 10px calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
  .ai-chat-last-meta { max-width: 100%; }
  .ai-chat-input { max-width: 100%; padding: 8px; }
  .ai-chat-textarea { font-size: 16px; min-height: 52px; }

  /* Suggestions */
  .ai-suggestions-grid { grid-template-columns: 1fr; }
  .ai-chat-empty { margin: 18px auto; padding: 0 4px; }
  .ai-chat-empty-badge { width: 52px; height: 52px; }
  .ai-chat-empty h2 { font-size: 18px; }

  /* Forms in modals */
  .ai-form-row { flex-wrap: wrap; gap: 8px; }
  .ai-form-col-narrow, .ai-form-col-checks { width: 100%; }

  /* Stats */
  .ai-stats-grid { grid-template-columns: 1fr 1fr; padding: 10px; gap: 6px; }
  .ai-stat-card { padding: 10px; }
  .ai-stat-value { font-size: 18px; }

  /* Tables inside AI content */
  .ai-content .card-head { padding: 8px 12px; gap: 6px; flex-wrap: wrap; }
  .ai-content .card-head h3 { font-size: 13.5px; }
  .ai-content .card-head .hstack { width: 100%; flex-wrap: wrap; }
  .ai-content .card-head .btn-sm { padding: 3px 8px; font-size: 11px; }
  .ai-table-wrap table.tbl { min-width: 480px; font-size: 11.5px; }
  .ai-table-wrap table.tbl th, .ai-table-wrap table.tbl td { padding: 5px 7px; }

  /* Approvals */
  .ai-approval-item { padding: 10px; }
  .ai-approval-actions { width: 100%; justify-content: flex-end; margin-top: 4px; }
  .ai-approval-actions .btn-xs { flex: 1; justify-content: center; min-width: 100px; }

  /* Skill Builder */
  .ai-builder-body { height: 70dvh; margin: 0; }

  /* Modals */
  .modal { width: 96vw !important; max-height: 92dvh; }
  .modal-body { padding: 12px; }
  .modal-foot { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  .modal textarea.input { font-size: 16px; }
  .modal .checkbox { padding: 8px 10px; }

  /* Ensure all inputs in AI use 16px to prevent iOS zoom */
  .ai-content textarea,
  .ai-content input.input,
  .ai-content select.input { font-size: 16px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   NARROW (≤ 400 px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .ai-chat-head { padding: 8px 10px; gap: 6px; }
  .ai-chip svg { width: 10px; height: 10px; }
  .ai-meta .ai-chip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
  .ai-stats-grid { grid-template-columns: 1fr; }
}

/* Prevent horizontal overflow from long tool output anywhere */
.ai-bubble { max-width: 100%; word-break: break-word; }
.ai-md a { word-break: break-all; }

/* ═══════════════════════════════════════════════════════════════════════════
   FLOATING AI CHAT — bubble + slide-in panel (visible on every screen except /#/ai)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
   FAB — SUN launcher
   - Bigger (72 px) for presence
   - Dark contrast ring keeps it visible on both light and dark backgrounds
   - Idle float animation + breathing halo + rotating rays
   - Central sparkle-star signals „AI"
   ═══════════════════════════════════════════════════════════════════════════ */
.ai-fab {
  position: fixed;
  right: 22px;
  /* Sit higher so it doesn't cover pagination / sticky footers / form action bars. */
  bottom: calc(90px + env(safe-area-inset-bottom));
  width: 72px; height: 72px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  z-index: 1200;
  padding: 0;
  outline: none;
  filter: drop-shadow(0 10px 24px rgba(14, 39, 68, 0.35));
  animation:
    ai-fab-enter 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    ai-fab-float 4s ease-in-out 0.55s infinite;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s;
}
@keyframes ai-fab-enter {
  from { transform: scale(0) rotate(-180deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes ai-fab-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.ai-fab:hover {
  animation-play-state: paused;
  transform: translateY(-4px) scale(1.08);
  filter: drop-shadow(0 16px 34px rgba(243, 167, 18, 0.55));
}
.ai-fab:active { transform: scale(0.94); }

.ai-fab-sun {
  position: relative;
  width: 72px; height: 72px;
  display: grid; place-items: center;
}

/* Breathing halo — soft warm aura */
.ai-fab-halo {
  position: absolute; inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(246,191,71,0.65) 0%,
    rgba(243,167,18,0.35) 35%,
    rgba(243,167,18,0.08) 60%,
    transparent 75%);
  animation: ai-fab-breathe 2.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes ai-fab-breathe {
  0%, 100% { transform: scale(0.88); opacity: 0.7; }
  50%      { transform: scale(1.18); opacity: 1; }
}
.ai-fab:hover .ai-fab-halo {
  animation-duration: 1.4s;
  background: radial-gradient(circle,
    rgba(246,191,71,0.9) 0%,
    rgba(243,167,18,0.5) 35%,
    rgba(243,167,18,0.12) 60%,
    transparent 75%);
}

/* Sun rays — two layers rotating opposite directions for more energy */
.ai-fab-rays {
  position: absolute;
  inset: -4px;
  width: 80px; height: 80px;
  filter: drop-shadow(0 0 4px rgba(246, 191, 71, 0.85));
  z-index: 1;
  pointer-events: none;
}
.ai-fab-rays-long  { animation: ai-fab-rays-spin 12s linear infinite; }
.ai-fab-rays-short { animation: ai-fab-rays-spin 18s linear infinite reverse; }
.ai-fab:hover .ai-fab-rays-long  { animation-duration: 3.5s; }
.ai-fab:hover .ai-fab-rays-short { animation-duration: 5s; }
@keyframes ai-fab-rays-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Dark contrast ring — keeps the sun visible on light AND dark backgrounds */
.ai-fab-ring {
  position: absolute;
  width: 48px; height: 48px;
  border-radius: 50%;
  box-shadow:
    0 0 0 2.5px rgba(14, 39, 68, 0.92),
    0 0 0 5px rgba(255, 246, 200, 0.6);
  z-index: 2;
  pointer-events: none;
}

/* Central sun orb — warm glow + specular highlight */
.ai-fab-core {
  position: relative;
  width: 44px; height: 44px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%,
      #fff9e5 0%,
      #ffd878 22%,
      #f3a712 55%,
      #b8680b 100%);
  box-shadow:
    inset 0 -4px 10px rgba(120, 60, 0, 0.45),
    inset 0 3px 6px rgba(255, 246, 200, 0.85),
    0 4px 14px rgba(243, 167, 18, 0.6);
  z-index: 3;
  display: grid; place-items: center;
}
.ai-fab-core::before {
  content: '';
  position: absolute;
  top: 6px; left: 9px; right: 12px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.85) 0%, transparent 70%);
}

/* Central AI sparkle star — pulses gently */
.ai-fab-spark {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(120, 60, 0, 0.5));
  animation: ai-fab-spark-pulse 3s ease-in-out infinite;
}
@keyframes ai-fab-spark-pulse {
  0%, 100% { transform: scale(1)    rotate(0deg);   opacity: 0.9; }
  50%      { transform: scale(1.15) rotate(45deg);  opacity: 1; }
}
.ai-fab:hover .ai-fab-spark { animation-duration: 1.2s; }

/* Green "unread conversation" pulse dot — offset to not cover the spark */
.ai-fab-dot {
  position: absolute; top: 2px; right: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, #34d399 0%, #16a34a 100%);
  border: 2.5px solid #fff;
  z-index: 4;
  animation: ai-fab-dot-pulse 1.6s ease-in-out infinite;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.5);
}
@keyframes ai-fab-dot-pulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 2px 6px rgba(22,163,74,0.5), 0 0 0 0 rgba(34,197,94,0.7); }
  50%      { transform: scale(1.15); box-shadow: 0 2px 6px rgba(22,163,74,0.5), 0 0 0 8px rgba(34,197,94,0); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-fab, .ai-fab-rays, .ai-fab-halo, .ai-fab-dot, .ai-fab-spark { animation: none !important; }
}

/* Backdrop (tap outside to close on mobile) */
.ai-fab-backdrop {
  position: fixed; inset: 0;
  background: transparent;
  z-index: 1199;
}
@media (max-width: 640px) {
  .ai-fab-backdrop { background: rgba(14, 39, 68, 0.35); }
}

/* Panel — "blooms" out of the sun at the bottom-right */
.ai-fab-panel {
  position: fixed;
  right: 20px;
  /* Match the FAB position so the panel anchors near the sun. */
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 620px;
  max-height: calc(100dvh - 40px);
  background: #fff;
  border-radius: 16px;
  box-shadow:
    0 30px 70px rgba(14, 39, 68, 0.28),
    0 8px 20px rgba(243, 167, 18, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 1200;
  display: flex; flex-direction: column;
  overflow: hidden;
  transform-origin: 100% 100%;
  animation: ai-fab-bloom 0.38s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes ai-fab-bloom {
  0%   { opacity: 0; transform: scale(0.35) translate(10%, 10%); filter: blur(6px); }
  60%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: scale(1) translate(0, 0); filter: blur(0); }
}

/* A subtle warm ring glow on the panel border while opening */
.ai-fab-panel::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(246,191,71,0.5), rgba(243,167,18,0) 40%, rgba(246,191,71,0.5));
  opacity: 0;
  z-index: -1;
  animation: ai-fab-panel-glow 1s ease-out forwards;
}
@keyframes ai-fab-panel-glow {
  0%   { opacity: 0.9; }
  100% { opacity: 0; }
}

/* Head — subtle warm gradient with sun accent */
.ai-fab-head {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fef4e0 0%, #fffbf2 100%);
  overflow: hidden;
}
.ai-fab-head::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246,191,71,0.35) 0%, transparent 65%);
  animation: ai-fab-head-shimmer 6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ai-fab-head-shimmer {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.7; }
  50%      { transform: translate(-15px, 10px) scale(1.15); opacity: 1; }
}
.ai-fab-head-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.ai-fab-head-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }
.ai-fab-model {
  height: 28px;
  font-size: 11.5px !important;
  padding: 0 6px !important;
  width: 80px;
  border-color: var(--border);
}
.ai-fab-icon-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-700);
}
.ai-fab-icon-btn:hover { background: var(--blue-50); color: var(--navy-700); }

/* Scroll area */
.ai-fab-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px 4px;
  background: var(--bg);
}

/* Empty state */
.ai-fab-empty { padding: 16px 8px; }
.ai-fab-empty-hint {
  font-size: 12px;
  color: var(--ink-500);
  text-align: center;
  margin-bottom: 14px;
  padding: 0 8px;
  line-height: 1.55;
}
.ai-fab-empty-hint i { color: var(--ink-700); background: #fff; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }
.ai-fab-suggestions { display: flex; flex-direction: column; gap: 6px; }
.ai-fab-suggestion {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  color: var(--ink-900);
  font-family: var(--font);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.ai-fab-suggestion::before {
  content: '☀';
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%) scale(0);
  color: var(--amber-500);
  opacity: 0;
  transition: transform 0.2s, opacity 0.2s;
}
.ai-fab-suggestion:hover {
  border-color: var(--amber-400);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(243,167,18,0.2);
  padding-left: 30px;
}
.ai-fab-suggestion:hover::before {
  transform: translateY(-50%) scale(1);
  opacity: 1;
}

/* Input */
.ai-fab-input-wrap {
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #fff;
}
.ai-fab-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  resize: none;
  outline: none;
  background: #fff;
  min-height: 50px;
}
.ai-fab-textarea:focus { border-color: var(--navy-500); }
.ai-fab-input-foot {
  display: flex; align-items: center;
  margin-top: 6px;
  gap: 8px;
}
.ai-fab-send { margin-left: auto; flex-shrink: 0; }

/* ── MOBILE: panel becomes almost full-screen ── */
@media (max-width: 640px) {
  .ai-fab {
    right: 14px;
    /* Sit higher to keep pagination + form action bars accessible */
    bottom: calc(80px + env(safe-area-inset-bottom));
    width: 64px; height: 64px;
  }
  .ai-fab-sun { width: 64px; height: 64px; }
  .ai-fab-rays { width: 72px; height: 72px; inset: -4px; }
  .ai-fab-ring { width: 42px; height: 42px; }
  .ai-fab-core { width: 38px; height: 38px; }
  .ai-fab-spark { width: 15px; height: 15px; }
  .ai-fab-dot { width: 12px; height: 12px; }
  .ai-fab-panel {
    right: 0; bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: calc(100dvh - 50px);
    max-height: calc(100dvh - 50px);
    border-radius: 14px 14px 0 0;
  }
  .ai-fab-head { padding: 12px 14px; }
  .ai-fab-model { width: 72px; font-size: 11px !important; }
  .ai-fab-textarea { font-size: 16px; min-height: 54px; /* iOS no-zoom */ }
  .ai-fab-suggestions { gap: 6px; }
}

/* ── Hide the FAB when a modal is open so it doesn't overlap Close/Save buttons ── */
body:has(.modal-backdrop) .ai-fab { opacity: 0; pointer-events: none; transform: translateY(20px); }
body:has(.modal-backdrop) .ai-fab-panel { opacity: 0.7; pointer-events: none; }

/* ───── AI navigation action (from crm_open_* tools) ───── */
.ai-nav-action {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--navy-800) 0%, var(--navy-700) 100%);
  color: #fff !important;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(14, 39, 68, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-nav-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(14, 39, 68, 0.35);
  background: linear-gradient(135deg, var(--navy-700) 0%, var(--navy-600) 100%);
}
.ai-nav-action svg { flex-shrink: 0; }

/* AI navigation toast — appears briefly after AI auto-opens a page */
.ai-nav-toast {
  position: fixed;
  top: 60px; right: 20px;
  background: linear-gradient(135deg, var(--navy-800) 0%, var(--navy-700) 100%);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(14, 39, 68, 0.35);
  font-size: 13px;
  z-index: 1300;
  animation: ai-nav-toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex; align-items: center; gap: 8px;
}
.ai-nav-toast b { color: #f6bf47; }
.ai-nav-toast span { font-size: 16px; }
.ai-nav-toast.fade { opacity: 0; transform: translateY(-8px); transition: opacity 0.4s, transform 0.4s; }
@keyframes ai-nav-toast-in { from { opacity:0; transform: translateY(-20px); } to { opacity:1; transform: translateY(0); } }
@media (max-width: 640px) {
  .ai-nav-toast { top: 55px; right: 10px; left: 10px; font-size: 12.5px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TEAM CALENDAR / LEAVES
   ═══════════════════════════════════════════════════════════════════════════ */

.cal-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 14px;
}
.cal-head {
  gap: 10px;
  flex-wrap: wrap;
}
.cal-nav { flex-wrap: wrap; gap: 4px; }

.cal-grid-wrap { padding: 0 10px 10px; }
.cal-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  padding: 8px 0 4px;
  font-size: 11px;
  color: var(--ink-500);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cal-weekday { text-align: center; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.cal-cell {
  min-height: 88px;
  background: #fff;
  padding: 6px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: none;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  align-items: stretch;
  transition: background 0.1s;
}
.cal-cell:hover { background: var(--blue-50); }
.cal-cell.out-month { background: #f6f8fc; }
.cal-cell.out-month .cal-daynum { color: var(--ink-300); }

.cal-daynum {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-700);
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
}
.cal-cell.is-today .cal-daynum {
  background: var(--navy-800);
  color: #fff;
  font-weight: 700;
}
.cal-events {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.cal-event {
  font-size: 10.5px;
  font-weight: 500;
  color: #fff;
  background: var(--ev-color, var(--navy-700));
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.cal-event.pending {
  background: repeating-linear-gradient(
    45deg,
    var(--ev-color, var(--navy-700)) 0, var(--ev-color, var(--navy-700)) 6px,
    rgba(255, 255, 255, 0.3) 6px, rgba(255, 255, 255, 0.3) 10px
  );
  opacity: 0.85;
}
.cal-event-name { pointer-events: none; }
.cal-event-more { font-size: 9.5px; color: var(--ink-500); padding: 0 2px; }

/* Legend */
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 12px 10px 4px;
  font-size: 11px;
  color: var(--ink-500);
}
.cal-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* Side panel rows */
.cal-side-row {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.cal-side-row:first-child { border-top: none; }
.cal-type-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-size: 13px;
  flex-shrink: 0;
}

/* New leave — type picker grid */
.cal-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}
.cal-type-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--ink-700);
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.cal-type-btn:hover {
  border-color: var(--type-color, var(--navy-500));
  background: #fafbfd;
  transform: translateY(-1px);
}
.cal-type-btn.is-active {
  border-color: var(--type-color, var(--navy-700));
  background: var(--blue-50);
  color: var(--ink-900);
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(10, 61, 98, 0.08);
}
.cal-type-btn-icon {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--type-color, var(--navy-500));
  color: #fff;
  font-size: 13px;
  flex-shrink: 0;
}

/* ─── TABLET (≤ 980 px): stack ─── */
@media (max-width: 980px) {
  .cal-layout { grid-template-columns: 1fr; }
  .cal-cell { min-height: 78px; }
}

/* ─── MOBILE (≤ 640 px): compact cells + horizontal scroll if needed ─── */
@media (max-width: 640px) {
  .cal-head { padding: 8px 10px; }
  .cal-grid-wrap { padding: 0 6px 6px; }
  .cal-cell { min-height: 66px; padding: 3px; }
  .cal-daynum { width: 18px; height: 18px; font-size: 11px; }
  .cal-event { font-size: 9.5px; padding: 1px 4px; }
  .cal-event-more { font-size: 9px; }
  .cal-legend { gap: 8px; font-size: 10.5px; padding: 10px 6px 4px; }
  .cal-legend-swatch { width: 8px; height: 8px; }
  .cal-type-grid { grid-template-columns: 1fr 1fr; }
  .cal-side-row { padding: 10px; }
  .cal-head h3, .cal-head b { font-size: 13.5px; }
  .cal-head .btn-sm { padding: 3px 8px; font-size: 11px; }
}
@media (max-width: 400px) {
  .cal-cell { min-height: 58px; padding: 2px; }
  .cal-event { font-size: 9px; padding: 0 3px; }
  .cal-type-grid { grid-template-columns: 1fr; }
}

/* ───── Allowance tiles ───── */
.cal-allowance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  padding: 10px 14px 14px;
}
.cal-allowance-tile {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.cal-allowance-bar {
  margin-top: 6px;
  height: 5px;
  background: var(--blue-50);
  border-radius: 3px;
  overflow: hidden;
}
.cal-allowance-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.2s;
}

/* ───── Attachments panel ───── */
.cal-attach-panel {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--blue-50);
  border: 1px solid rgba(10, 61, 98, 0.1);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal-attach-row {
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.cal-attach-link {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 0;
  color: var(--navy-700);
  text-decoration: none;
  font-size: 12px;
}
.cal-attach-link:hover { color: var(--navy-900); }
.cal-attach-thumb {
  width: 28px; height: 28px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.cal-attach-icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--red-100);
  color: #b91c1c;
  border-radius: 4px;
  flex-shrink: 0;
  font-size: 14px;
}
.cal-attach-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cal-file-drop {
  padding: 8px 10px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  background: #fafbfd;
}

/* ───── Segment buttons (seg) — ensure they work in calendar ───── */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button {
  border: none; background: #fff;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-700);
  cursor: pointer;
  font-family: var(--font);
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: none; }
.seg button:hover { background: var(--blue-50); }
.seg button.active { background: var(--navy-700); color: #fff; }

/* ───── FULL MOBILE PASS FOR CALENDAR ───── */
@media (max-width: 980px) {
  .cal-allowance-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .cal-allowance-grid { padding: 8px 10px; gap: 6px; }
  .cal-allowance-tile { padding: 6px 8px; }
  .cal-attach-row { flex-wrap: wrap; }
  .cal-attach-name { font-size: 11.5px; }
}
@media (max-width: 400px) {
  .cal-allowance-grid { grid-template-columns: 1fr; }
}

/* ───── Animated typing indicator (AI chat, Skill Builder, FAB) ───── */
.ty-wrap { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.ty-label { margin-bottom: 0; }
.ty-bubble {
  display: inline-flex; align-items: center; gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  width: fit-content;
  max-width: 100%;
  font-size: 12px;
  color: var(--ink-500);
}
.ty-dots {
  display: inline-flex; gap: 4px; align-items: center;
}
.ty-dots > span {
  width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg, var(--amber-500), #d97706);
  box-shadow: 0 0 0 0 rgba(243,167,18,0.5);
  animation: ty-bounce 1.1s ease-in-out infinite;
}
.ty-dots > span:nth-child(1) { animation-delay: 0s; }
.ty-dots > span:nth-child(2) { animation-delay: 0.18s; }
.ty-dots > span:nth-child(3) { animation-delay: 0.36s; }
@keyframes ty-bounce {
  0%, 80%, 100% { transform: scale(0.6) translateY(0); opacity: 0.5; box-shadow: 0 0 0 0 rgba(243,167,18,0.45); }
  40%           { transform: scale(1.15) translateY(-4px); opacity: 1; box-shadow: 0 0 0 4px rgba(243,167,18,0); }
}
.ty-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: var(--ink-400);
  padding: 1px 6px;
  background: var(--blue-50);
  border-radius: 4px;
}

/* Variant — small (for FAB) */
.ty-wrap.ty-small .ty-bubble { padding: 6px 10px; font-size: 11px; }
.ty-wrap.ty-small .ty-dots > span { width: 6px; height: 6px; }
@media (prefers-reduced-motion: reduce) {
  .ty-dots > span { animation: none; opacity: 0.7; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   NOTIFICATION TOAST (popup in top-right when a new item arrives)
   ═══════════════════════════════════════════════════════════════════════════ */
.notif-toast {
  position: fixed;
  top: 60px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--amber-500);
  border-radius: 10px;
  box-shadow: 0 20px 40px rgba(14, 39, 68, 0.2), 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 12px 14px;
  z-index: 1400;
  animation: notif-toast-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.notif-toast.fade { opacity: 0; transform: translateX(20px); transition: opacity 0.3s, transform 0.3s; }
@keyframes notif-toast-in {
  0%   { opacity: 0; transform: translateX(30px) scale(0.95); }
  100% { opacity: 1; transform: translateX(0)     scale(1); }
}
.notif-toast-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.notif-toast-chip {
  background: var(--amber-500);
  color: #1a1200;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
}
.notif-toast-close {
  margin-left: auto;
  width: 22px; height: 22px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ink-400);
  font-size: 13px;
  line-height: 1;
}
.notif-toast-close:hover { color: var(--ink-900); }
.notif-toast-title { font-size: 13px; font-weight: 600; color: var(--ink-900); margin-bottom: 2px; }
.notif-toast-sub   { font-size: 11.5px; color: var(--ink-500); margin-bottom: 6px; }
.notif-toast-action {
  color: var(--navy-700);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
.notif-toast-action:hover { text-decoration: underline; }
@media (max-width: 640px) {
  .notif-toast { top: 55px; right: 10px; left: 10px; width: auto; }
}

/* ───── Sound toggle switch (in bell dropdown footer) ───── */
.notif-switch {
  width: 36px; height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}
.notif-switch.on { background: var(--amber-500); }
.notif-switch-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.notif-switch.on .notif-switch-knob { transform: translateX(16px); }

/* chip blue (for AI chip in notifications) */
.chip.blue { background: var(--blue-100); color: var(--navy-700); }

/* ═══════════════════════════════════════════════════════════════════════════
   AI CHAT ATTACHMENTS (paperclip + drag&drop + preview chips + inline gallery)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Paperclip button inside input bar */
.ai-attach-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-500);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ai-attach-btn:hover { background: var(--blue-50); color: var(--navy-700); border-color: var(--border); }
.ai-attach-btn-sm { width: 28px; height: 28px; }

/* Drag-over visual */
.ai-chat-input.is-dragging,
.ai-fab-input-wrap.is-dragging {
  outline: 2px dashed var(--amber-500);
  outline-offset: -4px;
  background: #fff8e7;
}

/* Pending attachment chips (shown above textarea before sending) */
.ai-attach-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 2px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.ai-attach-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 4px;
  background: var(--blue-50);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 200px;
  font-size: 11px;
}
.ai-attach-chip-thumb {
  width: 28px; height: 28px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.ai-attach-chip-icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  flex-shrink: 0;
}
.ai-attach-chip-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-attach-chip-x {
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-400); font-size: 12px; padding: 0 4px;
}
.ai-attach-chip-x:hover { color: var(--red-500); }

/* Inline attachments in the sent message bubble (above the text) */
.ai-msg-files {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.ai-msg-file {
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
.ai-msg-file-img {
  max-width: 180px;
  max-height: 180px;
  border: 1px solid var(--border);
  display: block;
  transition: transform 0.15s, box-shadow 0.15s;
}
.ai-msg-file-img:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(14,39,68,0.2); }
.ai-msg-file-img img {
  width: 100%; height: 100%; display: block;
  max-width: 180px; max-height: 180px;
  object-fit: cover;
}
.ai-msg-file-doc {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 280px;
  min-width: 160px;
}
.ai-msg-file-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--red-100);
  color: #b91c1c;
  border-radius: 6px;
  font-size: 16px;
  flex-shrink: 0;
}
.ai-msg-file-name {
  font-size: 12px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Reserve safe space at the bottom of the main content so pagination / sticky
   action rows aren't hidden beneath the floating AI sun. */
body:has(.ai-fab) .content { padding-bottom: 100px; }
@media (max-width: 640px) {
  body:has(.ai-fab) .content { padding-bottom: 90px; }
}
