/* =========================================================================
 * shell.css — application frame: title bar, top menu bar (no sidebar),
 * window tabs, workspace area and status bar.
 * ========================================================================= */
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs); color: var(--text); background: var(--app-bg);
  display: flex; flex-direction: column; height: 100vh; overflow: hidden; line-height: 1.45;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
body.booting #view { visibility: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-700); text-decoration: underline; }
kbd { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; font-size: var(--fs-xs); font-family: var(--font); font-weight: 500; box-shadow: none; white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.95em; letter-spacing: -0.01em; }
[dir="rtl"] .flip-rtl { display: inline-block; transform: scaleX(-1); }
::selection { background: var(--primary-200); }

/* ------------------------------------------------ title bar */
#app-header { flex: 0 0 auto; position: relative; z-index: 1030; }
.titlebar {
  height: var(--h-title); display: flex; align-items: center; gap: 10px; padding: 0 10px;
  background: linear-gradient(var(--titlebar-2), var(--titlebar)); color: var(--titlebar-text); border-bottom: 1px solid #0c1826;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none !important; min-width: 0; flex: 0 1 auto; }
.brand:hover { color: #fff; }
.brand-mark { width: 28px; height: 28px; border-radius: 4px; background: var(--primary); display: grid; place-items: center; font-size: 16px; color: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.2); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 13.5px; font-weight: 700; letter-spacing: .01em; }
.brand-text small { font-size: 10.5px; color: var(--titlebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }

.gsearch { position: relative; flex: 1 1 420px; max-width: 560px; margin-inline: auto; }
.gsearch > .bi-search { position: absolute; inset-inline-start: 9px; top: 50%; transform: translateY(-50%); color: var(--titlebar-muted); font-size: 13px; pointer-events: none; }
.gsearch input {
  width: 100%; height: 28px; border-radius: 3px; border: 1px solid var(--titlebar-line); background: rgba(255,255,255,.08); color: #fff;
  padding-inline: 30px 64px; font-size: 12.5px; outline: none; transition: background .12s, border-color .12s;
}
.gsearch input::placeholder { color: var(--titlebar-muted); }
.gsearch input:focus { background: #fff; color: var(--text); border-color: #fff; box-shadow: 0 0 0 2px rgba(120,170,230,.45); }
.gsearch input:focus + kbd { display: none; }
.gsearch > kbd { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.1); border-color: var(--titlebar-line); color: var(--titlebar-muted); }
.gs-panel {
  display: none; position: absolute; top: calc(100% + 4px); inset-inline: 0; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-3); max-height: min(70vh, 560px); overflow: auto; z-index: 1100; min-width: 420px;
}
.gs-panel.show { display: block; }
.gs-gh { display: flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--surface-3); border-block: 1px solid var(--line-soft); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); position: sticky; top: 0; }
.gs-gh span { margin-inline-start: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; font-size: var(--fs-xs); }
.gs-item { display: grid; grid-template-columns: 110px 1fr auto auto; align-items: center; gap: 8px; padding: 5px 10px; color: var(--text); text-decoration: none !important; border-bottom: 1px solid var(--line-soft); }
.gs-item:hover, .gs-item.on { background: var(--row-active); color: var(--text); }
.gs-code { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); }
.gs-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-meta { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.gs-item mark { background: #ffe58a; padding: 0; color: inherit; }
.gs-empty { padding: 18px; text-align: center; color: var(--text-3); }

.tbar-end { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.tbar-btn {
  height: 28px; min-width: 30px; border: 1px solid transparent; background: transparent; color: var(--titlebar-text); border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 6px; position: relative; font-size: 12px;
}
.tbar-btn:hover { background: rgba(255,255,255,.1); border-color: var(--titlebar-line); }
.tbar-btn .bi { font-size: 15px; }
.tbar-btn.lang span { font-weight: 600; }
.nb-count { position: absolute; top: 1px; inset-inline-end: 0; background: #e5484d; color: #fff; font-size: 9.5px; font-weight: 700; min-width: 15px; height: 15px; border-radius: 8px; display: grid; place-items: center; padding: 0 3px; }
.btn-new { height: 28px; background: var(--primary); border: 1px solid #3f7cc4; color: #fff; font-weight: 600; font-size: 12px; padding: 0 10px; }
.btn-new:hover, .btn-new.show { background: #2a6cb8; color: #fff; border-color: #6d9bd4; }
.tbar-user { height: 30px; display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; border-radius: 3px; color: var(--titlebar-text); padding: 0 6px; font-size: 12px; }
.tbar-user:hover, .tbar-user.show { background: rgba(255,255,255,.1); border-color: var(--titlebar-line); }
.tbar-user .bi-chevron-down { font-size: 10px; opacity: .7; }
.notif-menu { width: 340px; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); font-size: var(--fs-sm); }
.dropdown-item.notif { white-space: normal; align-items: flex-start; padding-block: 7px; border-bottom: 1px solid var(--line-soft); }
.dropdown-item.notif span { display: flex; flex-direction: column; }
.dropdown-item.notif small { color: var(--text-3); font-size: var(--fs-xs); }
.dropdown-item.notif.unread { background: var(--primary-50); font-weight: 500; }

/* ------------------------------------------------ menu bar */
.menubar {
  height: var(--h-menu); display: flex; align-items: stretch; background: linear-gradient(#f6f8fa, var(--menubar)); border-bottom: 1px solid var(--menubar-line);
  padding: 0 6px; gap: 1px; box-shadow: 0 1px 0 rgba(255,255,255,.7) inset;
}
.mb-item { position: relative; display: flex; }
.mb-link {
  display: flex; align-items: center; gap: 6px; padding: 0 11px; color: var(--text); font-weight: 500; font-size: 12.8px; text-decoration: none !important;
  border-inline: 1px solid transparent; position: relative; white-space: nowrap; user-select: none;
}
.mb-link .bi { font-size: 14px; color: var(--text-2); }
.mb-link.dropdown-toggle::after { border-top-width: 4px; border-inline-width: 4px; margin-inline-start: 2px; opacity: .55; vertical-align: middle; }
.mb-link:hover, .mb-link.show { background: var(--menubar-hover); color: var(--text); border-color: var(--line-soft); }
.mb-link:focus-visible { outline: none; background: var(--menubar-hover); box-shadow: inset 0 0 0 2px var(--primary-200); }
.mb-item.active > .mb-link { background: var(--surface); border-color: var(--menubar-line); color: var(--primary-700); font-weight: 600; }
.mb-item.active > .mb-link::before { content: ''; position: absolute; inset-inline: -1px; top: -1px; height: 3px; background: var(--primary); }
.mb-item.active > .mb-link .bi { color: var(--primary); }
.menubar .dropdown-menu { top: calc(100% - 1px); inset-inline-start: 0; margin: 0; }
.menubar .dropdown-menu.mega { padding: 6px 4px; }
.mega-cols { display: flex; gap: 2px; }
.mega-col { list-style: none; margin: 0; padding: 0 2px; min-width: 210px; }
.mega-col + .mega-col { border-inline-start: 1px solid var(--line-soft); padding-inline-start: 4px; }

/* ------------------------------------------------ dropdown menus */
.erp-menu {
  --bs-dropdown-font-size: var(--fs); --bs-dropdown-padding-y: 4px; --bs-dropdown-item-padding-y: 4px; --bs-dropdown-item-padding-x: 10px;
  --bs-dropdown-link-active-bg: var(--primary); --bs-dropdown-link-hover-bg: var(--row-active); --bs-dropdown-border-color: var(--line-strong);
  --bs-dropdown-border-radius: 3px; --bs-dropdown-box-shadow: var(--shadow-2); min-width: 220px; box-shadow: var(--shadow-2);
}
.erp-menu .dropdown-item { display: flex; align-items: center; gap: 8px; border-radius: 2px; margin-inline: 3px; width: auto; }
.erp-menu .dropdown-item .bi { width: 16px; text-align: center; color: var(--primary); font-size: 13.5px; }
.erp-menu .dropdown-item:active .bi, .erp-menu .dropdown-item.active .bi { color: #fff; }
.erp-menu .dropdown-item kbd { margin-inline-start: auto; }
.erp-menu .dropdown-item:focus { background: var(--row-active); outline: none; }
.erp-menu .dropdown-header { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 5px 12px 3px; font-weight: 600; }
.erp-menu .dropdown-divider { margin: 4px 0; border-color: var(--line-soft); }

/* ------------------------------------------------ window tabs */
.window-tabs {
  flex: 0 0 auto; height: var(--h-tabs); display: flex; align-items: flex-end; background: var(--tabs-bg); border-bottom: 1px solid var(--line-strong);
  padding: 0 6px; gap: 6px;
}
.wt-list { display: flex; align-items: flex-end; gap: 2px; overflow-x: auto; overflow-y: hidden; flex: 1; scrollbar-width: none; height: 100%; }
.wt-list::-webkit-scrollbar { display: none; }
.wt {
  display: flex; align-items: center; height: 25px; background: var(--tab-bg); border: 1px solid #aeb8c4; border-bottom: none; border-radius: 3px 3px 0 0;
  max-width: 210px; flex: 0 0 auto; position: relative; top: 1px; color: var(--text-2);
}
.wt:hover { background: #eef1f5; }
.wt.active { background: var(--surface); height: 27px; color: var(--text); border-color: var(--line-strong); z-index: 1; box-shadow: inset 0 2px 0 var(--primary); }
.wt-link { display: flex; align-items: center; gap: 6px; padding-inline: 9px 4px; color: inherit; text-decoration: none !important; font-size: 12px; min-width: 0; height: 100%; }
.wt-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wt.active .wt-link { font-weight: 600; }
.wt-link .bi { color: var(--primary); font-size: 12.5px; }
.wt-dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: #e0892b; flex: none; }
.wt.dirty .wt-dot { display: inline-block; }
.wt-close { border: 0; background: transparent; color: var(--text-3); width: 20px; height: 20px; border-radius: 2px; display: grid; place-items: center; margin-inline-end: 3px; padding: 0; }
.wt-close:hover { background: var(--bad-bg); color: var(--bad); }
.wt:not(:hover):not(.active) .wt-close { visibility: hidden; }
.wt-tools { display: flex; align-items: center; height: 100%; }
.wt-tool { border: 0; background: transparent; color: var(--text-2); width: 24px; height: 22px; border-radius: 2px; }
.wt-tool:hover { background: var(--tab-bg); color: var(--bad); }

/* ------------------------------------------------ workspace */
.view { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--gap); position: relative; }
.ws { display: flex; flex-direction: column; min-height: 100%; height: 100%; gap: var(--gap); }
.ws-toolbar { flex: 0 0 auto; }
.ws-loading { padding: 30px; color: var(--text-3); text-align: center; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }

/* ------------------------------------------------ status bar */
.statusbar {
  flex: 0 0 auto; height: var(--h-status); display: flex; align-items: stretch; background: linear-gradient(#eef1f4, #e2e7ec); border-top: 1px solid var(--line-strong);
  font-size: 11px; color: var(--text-2); overflow: hidden;
}
.sb-cell { display: flex; align-items: center; gap: 5px; padding: 0 10px; border-inline-end: 1px solid var(--line); white-space: nowrap; }
.sb-cell .bi { color: var(--text-3); }
.sb-spacer { flex: 1; border-inline-end: 1px solid var(--line); }
.sb-msg { min-width: 180px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
.sb-led { font-size: 7px; color: #2e9d57 !important; }
.sb-msg.m-err .sb-led { color: var(--bad) !important; }
.sb-msg.m-warn .sb-led { color: #d99100 !important; }
.sb-msg.m-ok { color: var(--ok); }
.sb-msg.m-err { color: var(--bad); }
.sb-record { font-weight: 600; color: var(--text); }
.sb-record:empty { display: none; }
#sb-ajax b.ok { color: var(--ok); }
#sb-ajax b.bad { color: var(--bad); }
.sb-env { background: #fff4d6; color: var(--warn); }
.sb-env .bi { color: var(--warn); }
.sb-clock { font-family: var(--font-mono); border-inline-end: 0; }
.sb-busy { width: 8px; height: 8px; border-radius: 50%; background: #9aa7b6; }
.sb-busy.on { background: #f0a020; box-shadow: 0 0 0 2px rgba(240,160,32,.25); }

/* ------------------------------------------------ toasts */
#toasts { position: fixed; inset-inline-end: 12px; bottom: calc(var(--h-status) + 10px); z-index: 2000; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.erp-toast {
  display: flex; align-items: center; gap: 8px; min-width: 240px; max-width: 420px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line-strong);
  border-inline-start: 4px solid var(--info); border-radius: 3px; box-shadow: var(--shadow-2); font-size: 12.5px; opacity: 0; transform: translateY(8px); transition: all .2s;
}
.erp-toast.in { opacity: 1; transform: none; }
.erp-toast .bi { font-size: 15px; color: var(--info); }
.erp-toast.t-ok { border-inline-start-color: var(--ok); } .erp-toast.t-ok .bi { color: var(--ok); }
.erp-toast.t-warn { border-inline-start-color: #d99100; } .erp-toast.t-warn .bi { color: #d99100; }
.erp-toast.t-err { border-inline-start-color: var(--bad); } .erp-toast.t-err .bi { color: var(--bad); }

#print-root { display: none; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }
