/* ==========================================================================
   ESH Portal prototype - styles
   Palette based on esh_portal_palette.scss (ikwaeshven /esh theme).
   ========================================================================== */
:root {
  --brand: #1F8476;
  --brand-hover: #165C53;
  --brand-soft: #EEF8F8;
  --brand-softer: #B8E0D7;

  --bg: #F6F7F7;
  --surface: #FFFFFF;
  --sidebar: #F0F2F1;
  --sidebar-hover: #E4E8E6;
  --sidebar-active: #DDE6E3;
  --border: #E2E6E5;
  --text: #1E2B2C;
  --text-2: #55635F;
  --muted: #84918D;

  --ok: #2E9E6B;   --ok-bg: #E5F5EC;
  --info: #2F7FA8; --info-bg: #E5F1F8;
  --warn: #B7791F; --warn-bg: #FBF3E2;
  --danger: #C83C36; --danger-bg: #FBEAE9;
  --neutral-bg: #ECEFEE;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 40, 36, .05), 0 1px 3px rgba(16, 40, 36, .06);
  --shadow-lg: 0 12px 32px rgba(16, 40, 36, .16);
  --sb-w: 272px;
  --sb-w-collapsed: 60px;
  font-family: "Inter", -apple-system, "Segoe UI", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --brand: #3BB39F;
  --brand-hover: #5FC6B4;
  --brand-soft: #17302C;
  --brand-softer: #20463F;
  --bg: #161A1A;
  --surface: #1E2323;
  --sidebar: #121515;
  --sidebar-hover: #1F2525;
  --sidebar-active: #253130;
  --border: #2D3434;
  --text: #E7ECEB;
  --text-2: #B3BDBA;
  --muted: #7F8B88;
  --ok-bg: #173327; --info-bg: #15293A; --warn-bg: #33291A; --danger-bg: #3A1D1C; --neutral-bg: #2A3030;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
kbd { font: 500 11px/1 "Inter", sans-serif; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 3px 5px; background: var(--surface); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.i { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* ---------------- Layout ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { flex: 1; overflow-y: auto; padding: 8px 32px 48px; outline: none; }
.view > * { max-width: 1180px; margin-left: auto; margin-right: auto; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: var(--sb-w); flex: none; display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--border);
  transition: width .18s ease; overflow: hidden;
}
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 14px; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 11px; letter-spacing: .04em; flex: none; }
.brand-text { font-weight: 650; font-size: 16px; white-space: nowrap; }

.icon-btn { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); position: relative; flex: none; }
.icon-btn:hover { background: var(--sidebar-hover); color: var(--text); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg); }

.sb-actions { padding: 4px 8px 6px; display: flex; flex-direction: column; gap: 2px; }
.sb-new {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-weight: 550;
}
.sb-new:hover { border-color: var(--brand); color: var(--brand); }
.sb-new .ico { width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.sb-new .ico .i { width: 14px; height: 14px; }

.sb-nav { padding: 2px 8px; display: flex; flex-direction: column; gap: 1px; }
.sb-link {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 8px;
  color: var(--text-2); width: 100%; text-align: left; position: relative; white-space: nowrap;
}
.sb-link .ico { display: grid; place-items: center; }
.sb-gap { display: block; height: 10px; flex: none; }
.sb-link:hover { background: var(--sidebar-hover); color: var(--text); }
.sb-link.active { background: var(--sidebar-active); color: var(--text); font-weight: 600; }
.sb-link.active .i { color: var(--brand); }
.sb-link kbd { margin-left: auto; }
.badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11px; font-weight: 600; display: grid; place-items: center; background: var(--neutral-bg); color: var(--text-2); }
.badge.alert { background: var(--brand); color: #fff; }
.badge-dot { display: none; }

.sb-sep { height: 1px; background: var(--border); margin: 10px 16px; flex: none; }

.sb-open { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sb-open-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 18px 6px; font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.link-btn { font-size: 12px; color: var(--muted); }
.link-btn:hover { color: var(--brand); text-decoration: underline; }
.sb-tabs { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; }
.sb-tabs-empty { font-size: 12px; color: var(--muted); padding: 4px 10px; line-height: 1.5; }
.sb-tab { position: relative; border-radius: 8px; margin-bottom: 4px; }
/* Every tab: light card background + hairline border */
.sb-tab a {
  display: flex; align-items: center; gap: 10px; padding: 6px 34px 6px 10px; border-radius: 8px; min-height: 44px;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
}
.sb-tab .i { color: var(--muted); }
.sb-tab:hover a { border-color: var(--brand-softer); color: var(--text); }
/* Selected tab: inverted (brand fill, white text) with a darker border */
.sb-tab.active a {
  background: var(--brand); color: #fff; border: 1px solid var(--brand-hover);
  box-shadow: 0 0 0 2px var(--brand-softer), var(--shadow);
}
.sb-tab.active .i, .sb-tab.active .tab-num { color: rgba(255, 255, 255, .85); }
.sb-tab.active .tab-title { font-weight: 600; }
.sb-tab.active .tab-close { color: rgba(255, 255, 255, .85); }
.sb-tab.active .tab-close:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.sb-tab.dragging { opacity: .5; }
.tab-text { display: flex; flex-direction: column; min-width: 0; }
.tab-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.tab-num { font-size: 11px; color: var(--muted); }
.tab-close {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--muted);
  opacity: 0; transition: opacity .1s;
}
.tab-close .i { width: 14px; height: 14px; }
.sb-tab:hover .tab-close, .sb-tab.active .tab-close, .tab-close:focus-visible { opacity: 1; }
.tab-close:hover { background: var(--sidebar-active); color: var(--danger); }

.sb-user { position: relative; padding: 8px; border-top: 1px solid var(--border); flex: none; }
.user-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border-radius: 10px; text-align: left; }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--sidebar-hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #7C5CC4; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; background: var(--brand-softer); color: var(--brand-hover); }
.avatar.sm .i { width: 14px; height: 14px; }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; }
.user-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); display: grid; }
.chev .i { width: 16px; height: 16px; }

.user-menu {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 4px); min-width: 236px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 30; animation: pop .12s ease;
}
.um-head { padding: 8px 10px 6px; }
.um-email { font-size: 12px; color: var(--muted); }
.user-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: left; color: var(--text-2); }
.user-menu button:hover { background: var(--sidebar-hover); color: var(--text); }
.um-arrow { margin-left: auto; display: grid; color: var(--muted); }
.um-sep { height: 1px; background: var(--border); margin: 6px 4px; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }

/* Collapsed sidebar */
.app.collapsed .sidebar { width: var(--sb-w-collapsed); }
.app.collapsed .lbl, .app.collapsed .brand-text, .app.collapsed .sb-open-head { display: none !important; }
.app.collapsed .sb-top { flex-direction: column; padding: 12px 8px 6px; }
.app.collapsed .sb-link, .app.collapsed .sb-new, .app.collapsed .sb-tab a { justify-content: center; padding: 0; }
.app.collapsed .sb-new { width: 40px; margin: 0 auto; }
.app.collapsed .sb-tab a { min-height: 38px; }
.app.collapsed .tab-close { display: none; }
.app.collapsed .badge-dot { display: block; position: absolute; top: 7px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.app.collapsed .user-btn { justify-content: center; }
.app.collapsed .user-menu { left: 8px; right: auto; }

/* ---------------- Top bar ---------------- */
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 24px 0 32px; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a:hover { color: var(--brand); }
.crumbs span:last-child { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { width: 14px; height: 14px; }
.topbar-right { margin-left: auto; display: flex; gap: 4px; }
.mobile-only { display: none; }

/* ---------------- Common components ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 4px 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.link { display: inline-flex; align-items: center; gap: 2px; color: var(--brand); font-size: 13px; font-weight: 550; }
.link .i { width: 14px; height: 14px; }
.link:hover { text-decoration: underline; }

.grid-2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 16px; }

.seg { display: inline-flex; gap: 2px; background: var(--neutral-bg); padding: 3px; border-radius: 9px; margin-bottom: 8px; }
.seg button { padding: 5px 12px; border-radius: 7px; color: var(--text-2); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.count { font-size: 11px; background: var(--border); border-radius: 8px; padding: 0 6px; }
.count.alert { background: var(--brand); color: #fff; }

.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 9px; }
.rows .row + .row { border-top: 1px solid var(--border); border-radius: 0; }
.rows .row:hover { background: var(--brand-soft); border-radius: 9px; }
.rows .row:hover + .row { border-top-color: transparent; }
.row-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.row-icon.task { background: var(--warn-bg); color: var(--warn); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--warn); font-weight: 550; }
.due .i { width: 14px; height: 14px; }
.empty { color: var(--muted); padding: 18px 8px; text-align: center; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.st-new { background: var(--info-bg); color: var(--info); }
.st-in_progress, .st-open { background: var(--brand-soft); color: var(--brand); }
.st-awaiting { background: var(--warn-bg); color: var(--warn); }
.st-resolved, .st-done { background: var(--ok-bg); color: var(--ok); }
.st-closed { background: var(--neutral-bg); color: var(--text-2); }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 550; border: 1px solid transparent; }
.btn.sm { height: 32px; padding: 0 12px; }
.btn .i { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.ghost { border-color: var(--border); background: var(--surface); }
.btn.ghost:hover { border-color: var(--text-2); }
.btn.danger-ghost { border-color: var(--border); color: var(--danger); background: var(--surface); }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions.end { justify-content: flex-end; }

.notice { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; position: relative; }
.notice.info { background: var(--info-bg); border-color: transparent; }
.notice.warn { background: var(--warn-bg); border-color: transparent; }
.notice span { color: var(--text-2); font-size: 13px; }
.notice.action { padding-right: 44px; }
.notice.action:hover { filter: brightness(.98); }
.notice.action > .i { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--warn); }

/* ---------------- Dashboard ---------------- */
.hero { padding: 20px 0 22px; }
.hero h1 { font-size: 28px; font-weight: 650; }
.hero p { margin-top: 4px; font-size: 15px; }
.hero-search {
  margin-top: 16px; width: 100%; max-width: 680px; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); color: var(--muted); text-align: left;
}
.hero-search span { flex: 1; }
.hero-search:hover { border-color: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat:hover { border-color: var(--brand); }
.stat-num { font-size: 26px; font-weight: 700; color: var(--brand); line-height: 1.1; }
.stat.warn .stat-num { color: var(--warn); }
.stat-lbl { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }

.quick { display: flex; flex-direction: column; gap: 2px; }
.quick-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 9px; }
.quick-item:hover { background: var(--brand-soft); }
.quick-item > span:last-child { display: flex; flex-direction: column; }
.qi-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.qi-icon.lg { width: 48px; height: 48px; border-radius: 12px; }
.qi-icon.lg .i { width: 24px; height: 24px; }
.qi-title { font-weight: 550; }
.qi-sub { font-size: 12px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; transition: transform .12s, border-color .12s; }
.tile:hover { border-color: var(--c); transform: translateY(-2px); }
.tile-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--c); margin-bottom: 8px; }
.tile-name { font-weight: 600; }
.tile-count { font-size: 12px; color: var(--muted); }

/* ---------------- List pages ---------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 12px 0 16px; }
.page-head p { margin-top: 4px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .seg { margin-bottom: 0; }
.filter-box { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--muted); margin-left: auto; min-width: 260px; }
.filter-box.wide { margin-left: 0; width: 100%; max-width: 520px; }
.filter-box input { border: 0; outline: 0; background: transparent; flex: 1; }
.filter-box:focus-within { border-color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { padding: 5px 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; color: var(--text-2); }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.form-card { background: var(--surface); border: 1px solid var(--border); padding: 14px; align-items: flex-start; flex-wrap: wrap; }
.form-card:hover { border-color: var(--brand); }
.form-card .row-title, .form-card .row-sub { white-space: normal; }
.fc-cat { width: 100%; padding-left: 46px; font-size: 11px; color: var(--muted); }

/* ---------------- Detail ---------------- */
.detail { max-width: 980px; }
.detail.narrow { max-width: 820px; }
.detail-head { display: flex; gap: 24px; padding: 22px 24px; }
.detail-head.plain { align-items: center; gap: 16px; }
.dh-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.dh-main h1 { font-size: 21px; }
.dh-side { margin: 0; padding-left: 24px; border-left: 1px dashed var(--border); display: flex; flex-direction: column; gap: 12px; min-width: 150px; }
.dh-side dt { font-size: 12px; color: var(--muted); }
.dh-side dd { margin: 2px 0 0; font-weight: 550; }
.dh-people { display: flex; gap: 32px; margin-top: 8px; }
.dh-people > div { display: flex; flex-direction: column; }
.dh-people .person { flex-direction: row; align-items: center; gap: 10px; }
.dh-people .person > div { display: flex; flex-direction: column; }
.parent-link { display: inline-flex; align-items: center; gap: 6px; color: var(--brand); font-weight: 550; margin-top: 6px; }
.parent-link:hover { text-decoration: underline; }

.progress { list-style: none; display: flex; margin: 10px 0 4px; padding: 0; counter-reset: s; }
.progress li { flex: 1; position: relative; font-size: 11.5px; color: var(--muted); padding-top: 18px; }
.progress li span { position: absolute; top: 0; left: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--border); z-index: 1; }
.progress li::before { content: ""; position: absolute; top: 5px; left: 0; right: 0; height: 2px; background: var(--border); }
.progress li:last-child::before { display: none; }
.progress li.done span, .progress li.done::before { background: var(--brand); }
.progress li.done { color: var(--text-2); }
.progress li.cur span { background: var(--surface); border: 3px solid var(--brand); }
.progress li.cur { color: var(--text); font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px -4px 16px; }
.tabs button { padding: 8px 12px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; margin: 0; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 2px 0 0; }

.composer { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.composer textarea { flex: 1; resize: vertical; border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; background: var(--bg); outline: none; }
.composer textarea:focus { border-color: var(--brand); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.timeline li { display: flex; gap: 10px; }
.timeline li > div { flex: 1; }
.timeline .tl-head { display: flex; gap: 8px; align-items: baseline; }
.timeline p { color: var(--text-2); margin-top: 2px; }
.timeline li.comment > div { background: var(--bg); border-radius: 10px; padding: 8px 12px; }
.timeline li.system .avatar { background: var(--neutral-bg); color: var(--muted); }

/* ---------------- Forms ---------------- */
.form h2 { margin: 4px 0 12px; }
.form h2:not(:first-child) { margin-top: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field i { color: var(--danger); font-style: normal; }
.field input, .field textarea, .field select { border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; background: var(--surface); outline: none; }
.field input[readonly] { background: var(--bg); color: var(--text-2); }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.drop { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 18px; border: 1.5px dashed var(--border); border-radius: 10px; color: var(--muted); cursor: pointer; }
.drop:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------- Palette / toast ---------------- */
.palette { position: fixed; inset: 0; background: rgba(10, 20, 18, .35); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.palette-box { width: min(620px, calc(100% - 32px)); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .12s ease; border: 1px solid var(--border); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 52px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--text); }
.palette-results { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette-results a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); }
.palette-results a span:nth-child(2) { flex: 1; color: var(--text); }
.palette-results a.sel, .palette-results a:hover { background: var(--brand-soft); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 60; font-weight: 500; }

.scrim { display: none; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; width: var(--sb-w) !important; box-shadow: var(--shadow-lg); }
  .app.mobile-open .sidebar { transform: none; }
  .app.mobile-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
  .app.collapsed .lbl, .app.collapsed .brand-text, .app.collapsed .sb-open-head { display: revert !important; }
  .sb-collapse { display: none; }
  .mobile-only { display: grid; }
  .topbar { padding: 0 12px; }
  .view { padding: 4px 16px 40px; }
  .detail-head { flex-direction: column; }
  .dh-side { border-left: 0; padding-left: 0; border-top: 1px dashed var(--border); padding-top: 12px; flex-direction: row; flex-wrap: wrap; gap: 20px; }
  .kv, .form-grid { grid-template-columns: 1fr; }
  .filter-box { min-width: 0; width: 100%; margin-left: 0; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .cards { grid-template-columns: 1fr; }
  .progress li { font-size: 0; }
  .tab-close { opacity: 1; }
}
