/* Dynamic ERP — design system */
:root {
  --brand: #6d5dfc; --brand-2: #8b7bff; --brand-ink: #4c3fd9; --brand-soft: #efedff;
  --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --faint: #94a3b8;
  --line: #e6e8f0; --line-2: #eef0f6; --bg: #f6f7fb; --surface: #fff;
  --green: #059669; --green-soft: #e7f8f1; --red: #dc2626; --red-soft: #fdecec;
  --amber: #b45309; --amber-soft: #fff5e1; --blue: #2563eb; --blue-soft: #e8f0ff;
  --violet: #7c3aed; --violet-soft: #f1eaff; --pink: #db2777; --pink-soft: #fde9f3;
  --teal: #0d9488; --teal-soft: #e2f7f5; --gray: #475569; --gray-soft: #eef1f5;
  --radius: 12px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 24px -8px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --sidebar: 248px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 .8em; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; text-decoration: none !important; }
.btn:hover { background: #f8f9fc; border-color: #d7dbe7; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(109, 93, 252, .3); outline-offset: 1px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(76, 63, 217, .3), inset 0 1px 0 rgba(255,255,255,.15); }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #047857; border-color: #047857; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: #f5c2c2; }
.btn-danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(15, 23, 42, .05); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-ai { background: linear-gradient(135deg, #6d5dfc, #c04cfd); border: 0; color: #fff; box-shadow: 0 4px 14px -4px rgba(140, 80, 255, .6); }
.btn-ai:hover { filter: brightness(1.07); background: linear-gradient(135deg, #6d5dfc, #c04cfd); }

/* ---------- form controls ---------- */
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); font: inherit; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109, 93, 252, .15); }
.input[readonly], .input:disabled { background: #f8f9fc; color: var(--ink-2); }
.input.err { border-color: var(--red); box-shadow: 0 0 0 3px rgba(220, 38, 38, .1); }
select.input { appearance: none; padding-right: 32px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
label.lbl { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.req::after { content: ' *'; color: var(--red); }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.errtext { font-size: 12px; color: var(--red); margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.field { margin-bottom: 14px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-soft); color: var(--gray); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.b-blue { background: var(--blue-soft); color: var(--blue); } .b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); } .b-amber { background: var(--amber-soft); color: var(--amber); }
.b-violet { background: var(--violet-soft); color: var(--violet); } .b-pink { background: var(--pink-soft); color: var(--pink); }
.b-teal { background: var(--teal-soft); color: var(--teal); } .b-gray { background: var(--gray-soft); color: var(--gray); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-body { padding: 18px; }

/* ---------- flash messages ---------- */
.toasts { position: fixed; z-index: 90; right: 20px; top: 16px; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast { padding: 11px 14px 11px 40px; border-radius: 10px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); position: relative; animation: toastIn .25s ease-out; font-size: 13.5px; word-break: break-word; }
.toast::before { position: absolute; left: 14px; top: 10px; font-size: 15px; }
.toast.success::before { content: '✓'; color: #34d399; } .toast.error::before { content: '!'; color: #f87171; font-weight: 800; }
.toast.info::before, .toast.warning::before { content: 'i'; color: #93c5fd; font-weight: 800; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } }

/* ================= ERP shell ================= */
.shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 70; left: 0; top: 0; bottom: 0; width: var(--sidebar); background: #0f1222; color: #c7cbe0; display: flex; flex-direction: column; }
.sb-nav { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.sb-head, .sb-foot { flex: none; }
.sb-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sb-logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.sb-name { color: #fff; font-weight: 650; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-host { font-size: 11.5px; color: #8187a8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-nav { padding: 10px 10px 16px; flex: 1; min-height: 0; }
.sb-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: #c7cbe0; font-weight: 500; font-size: 13.5px; text-decoration: none !important; }
.sb-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sb-link.active { background: rgba(109, 93, 252, .22); color: #fff; }
.sb-link .ic { width: 20px; text-align: center; font-size: 15px; flex: none; }
.sb-sec { margin: 16px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #6b7194; }
.sb-app > summary { list-style: none; cursor: pointer; }
.sb-app > summary::-webkit-details-marker { display: none; }
.sb-app > summary .chev { margin-left: auto; transition: transform .15s; opacity: .5; font-size: 10px; }
.sb-app[open] > summary .chev { transform: rotate(90deg); }
.sb-sub { margin: 2px 0 6px 20px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.08); }
.sb-sub .sb-link { padding: 5px 10px; font-size: 13px; color: #a9aecb; }
.sb-sub .sb-link.active { color: #fff; background: rgba(109, 93, 252, .22); }
.sb-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.sb-build { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #fff !important; font-weight: 600; text-decoration: none !important;
  background: linear-gradient(135deg, rgba(109, 93, 252, .9), rgba(192, 76, 253, .9)); box-shadow: 0 8px 22px -10px rgba(170, 90, 255, .8); }
.sb-build:hover { filter: brightness(1.08); }
.sb-build small { display: block; font-weight: 400; opacity: .85; font-size: 11.5px; }

.main { min-width: 0; min-height: 100vh; margin-left: var(--sidebar); display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: rgba(246, 247, 251, .85); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs .sep { opacity: .5; }
.crumbs b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-box { position: relative; width: min(380px, 40vw); margin-left: auto; }
.search-box input { padding-left: 36px; height: 36px; background: #fff; }
.search-box::before { content: ''; position: absolute; left: 12px; top: 10px; width: 16px; height: 16px; opacity: .45;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f172a' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat center/contain; }
.search-box kbd { position: absolute; right: 9px; top: 8px; font: 11px/18px ui-monospace, monospace; padding: 0 5px; border: 1px solid var(--line); border-radius: 5px; color: var(--faint); background: #fafbfc; }
.search-pop { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; max-height: 420px; overflow: auto; z-index: 50; }
.search-pop .grp { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--faint); padding: 8px 10px 4px; letter-spacing: .05em; }
.search-pop a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--ink); text-decoration: none; }
.search-pop a:hover, .search-pop a.on { background: var(--brand-soft); }
.icon-btn { position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: var(--ink-2); text-decoration: none !important; }
.icon-btn:hover { background: rgba(15,23,42,.06); }
.dot { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #a5b4fc, #c4b5fd); color: #312e81; font-weight: 700; font-size: 12px; flex: none; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 42px; min-width: 220px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; }
.menu-pop a, .menu-pop button { display: flex; width: 100%; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 7px; color: var(--ink); font: inherit; background: none; border: 0; cursor: pointer; text-decoration: none !important; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: #f4f5f9; }
.menu-pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }

.content { padding: 24px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 10px; }
.page-head .count { font-size: 13px; font-weight: 600; color: var(--muted); background: #eceef5; padding: 2px 9px; border-radius: 999px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- toolbar / list ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { height: 34px; }
.toolbar form.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.seg { display: inline-flex; padding: 3px; background: #eceef5; border-radius: 9px; }
.seg a { padding: 5px 12px; border-radius: 7px; color: var(--muted); font-weight: 550; font-size: 13px; text-decoration: none !important; }
.seg a.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: 12.5px; font-weight: 600; }
.chip a { color: inherit; opacity: .6; text-decoration: none; padding: 0 4px; }
.chip a:hover { opacity: 1; }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { position: sticky; top: 0; background: #fafbfd; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th a { color: inherit; text-decoration: none; }
.tbl th a:hover { color: var(--ink); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: #f8f8fe; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 700; padding: 10px 14px; border-top: 1px solid var(--line); background: #fafbfd; }
.tbl .cb { width: 36px; padding-right: 0; }
.tbl td:first-child + td, .tbl td.primary { font-weight: 550; color: var(--ink); }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 13px; }
.bulkbar { display: none; align-items: center; gap: 10px; padding: 8px 14px; background: var(--brand-soft); border-bottom: 1px solid var(--line); font-weight: 600; color: var(--brand-ink); }
.bulkbar.on { display: flex; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .em { font-size: 40px; margin-bottom: 8px; }
.empty h3 { color: var(--ink); margin-bottom: 4px; }

/* ---------- kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; min-height: 60vh; }
.kcol { flex: 0 0 290px; background: #eef0f6; border-radius: 12px; padding: 10px; transition: background .15s, box-shadow .15s; }
.kcol.over { background: #e4e1ff; box-shadow: inset 0 0 0 2px var(--brand); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.kcol-head .n { color: var(--muted); font-size: 12px; font-weight: 600; }
.kcol-head .sum { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.kcards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcard { display: block; background: #fff; border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--line); color: var(--ink); cursor: grab; text-decoration: none !important; transition: box-shadow .15s, transform .15s; }
.kcard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kcard.dragging { opacity: .5; }
.kcard .t { font-weight: 600; margin-bottom: 6px; }
.kcard .kv { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.kcard .kv span:last-child { color: var(--ink-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kadd { display: block; text-align: center; padding: 8px; border-radius: 8px; color: var(--muted); font-size: 13px; margin-top: 8px; text-decoration: none !important; }
.kadd:hover { background: rgba(255,255,255,.7); color: var(--ink); }

/* ---------- form ---------- */
.form-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.form-head .title { font-size: 22px; font-weight: 700; }
.statusbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line-2); background: #fbfbfe; border-radius: var(--radius) var(--radius) 0 0; }
.steps { margin-left: auto; display: flex; align-items: center; }
.steps span { position: relative; padding: 5px 14px 5px 20px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: #eef0f6; clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%, 9px 50%); margin-left: -4px; }
.steps span:first-child { clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%); padding-left: 14px; border-radius: 6px 0 0 6px; }
.steps span.on { background: var(--brand); color: #fff; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.form-layout.full { grid-template-columns: 1fr; }
.sheet { padding: 4px 22px 22px; }
.fsec { padding-top: 18px; }
.fsec + .fsec { border-top: 1px dashed var(--line); margin-top: 6px; }
.fsec-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; }
.fgrid .wide { grid-column: 1 / -1; }
.computed { height: 38px; display: flex; align-items: center; padding: 0 12px; background: #f6f5ff; border: 1px dashed #d8d3ff; border-radius: var(--radius-sm); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--brand-ink); }
.computed.big { font-size: 16px; }
.smart { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.smart a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink-2); font-size: 13px; text-decoration: none !important; }
.smart a:hover { border-color: var(--brand); color: var(--brand-ink); }
.smart b { font-size: 15px; color: var(--ink); }
.savebar { position: sticky; bottom: 0; z-index: 20; display: flex; gap: 8px; align-items: center; padding: 12px 22px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.dirty-dot { display: none; color: var(--amber); font-size: 12.5px; font-weight: 600; }
.is-dirty .dirty-dot { display: inline; }

/* combobox */
.combo { position: relative; }
.combo .input { padding-right: 30px; }
.combo-x { position: absolute; right: 8px; top: 9px; border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 14px; display: none; }
.combo.has .combo-x { display: block; }
.combo-pop { position: absolute; z-index: 40; left: 0; right: 0; top: 40px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 260px; overflow: auto; padding: 4px; }
.combo-pop div { padding: 7px 10px; border-radius: 7px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-pop div:hover, .combo-pop div.on { background: var(--brand-soft); }
.combo-pop .none { color: var(--faint); cursor: default; background: none !important; }
.combo-pop .create { color: var(--brand-ink); font-weight: 600; border-top: 1px solid var(--line-2); margin-top: 4px; }
.combo-open { position: absolute; right: -26px; top: 9px; font-size: 13px; opacity: .5; text-decoration: none !important; }
.combo-open:hover { opacity: 1; }

/* lines editor */
.lines { border: 1px solid var(--line); border-radius: 10px; overflow: visible; }
.lines table { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; background: #fafbfd; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lines th:first-child { border-radius: 10px 0 0 0; } .lines th:last-child { border-radius: 0 10px 0 0; }
.lines td { padding: 4px 6px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.lines td .input { height: 34px; border-color: transparent; background: transparent; }
.lines td .input:hover { border-color: var(--line); background: #fff; }
.lines td .input:focus { border-color: var(--brand); background: #fff; }
.lines td.num .input, .lines td.num { text-align: right; }
.lines td.calc { text-align: right; font-weight: 600; padding-right: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-2); }
.lines .del { border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.lines .del:hover { color: var(--red); background: var(--red-soft); }
.lines .add { display: inline-block; padding: 9px 12px; color: var(--brand-ink); font-weight: 600; cursor: pointer; border: 0; background: none; font: inherit; }
.lines .add:hover { text-decoration: underline; }
.lines td .combo-pop { min-width: 240px; }
.lines-ro td { padding: 8px 10px; }

/* chatter */
.chatter { position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.chatter .card-head { flex: none; }
.chatter form { padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.chatter textarea { min-height: 60px; }
.feed { overflow-y: auto; padding: 6px 14px 14px; }
.log { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.log:last-child { border-bottom: 0; }
.log .avatar { width: 28px; height: 28px; font-size: 11px; }
.log .avatar.sys { background: #eef0f6; color: var(--muted); }
.log .meta { font-size: 12px; color: var(--muted); }
.log .meta b { color: var(--ink); font-weight: 600; }
.log .msg { margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.log .comment { background: #f6f7fb; border-radius: 0 10px 10px 10px; padding: 8px 10px; margin-top: 4px; }
.log ul { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.log li { color: var(--ink-2); }
.log li s { color: var(--faint); }

/* ---------- dashboard ---------- */
.welcome { position: relative; overflow: hidden; border-radius: 16px; padding: 26px 28px; color: #fff; margin-bottom: 20px;
  background: radial-gradient(1200px 300px at 100% 0, rgba(255,255,255,.18), transparent 60%), linear-gradient(120deg, #3b2fc9, #6d5dfc 45%, #b04cfd); box-shadow: 0 20px 50px -24px rgba(90, 60, 230, .7); }
.welcome h2 { font-size: 22px; margin-bottom: 6px; }
.welcome p { opacity: .9; max-width: 640px; }
.welcome .btn { background: #fff; color: var(--brand-ink); border: 0; }
.welcome .btn.alt { background: rgba(255,255,255,.15); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; position: relative; }
.kpi .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi .val { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--faint); }
.kpi .x { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .15s; }
.kpi:hover .x, .chart-card:hover .x { opacity: 1; }
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.chart-card { position: relative; min-width: 0; }
.chart-card.s2 { grid-column: span 2; } .chart-card.s3 { grid-column: 1 / -1; }
.chart-card .card-head { padding: 12px 16px; }
.chart-box { position: relative; height: 240px; padding: 10px 14px 14px; }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.app-tile { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 12px; background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none !important; transition: box-shadow .15s, transform .15s, border-color .15s; }
.app-tile:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: #d9dcf0; }
.app-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 21px; flex: none; }
.app-tile b { display: block; font-weight: 650; }
.app-tile small { color: var(--muted); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.act { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.act:last-child { border-bottom: 0; }

/* ---------- builder ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; height: calc(100vh - 106px); }
.chat { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-feed { flex: 1; overflow-y: auto; padding: 22px; scroll-behavior: smooth; }
.chat-intro { text-align: center; max-width: 560px; margin: 30px auto; }
.chat-intro .orb { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; display: grid; place-items: center; font-size: 30px; background: linear-gradient(135deg, #6d5dfc, #c04cfd); box-shadow: 0 16px 40px -12px rgba(150, 80, 255, .7); }
.msg { display: flex; gap: 12px; margin-bottom: 18px; max-width: 860px; }
.msg.user { margin-left: auto; flex-direction: row-reverse; }
.msg .bubble { padding: 12px 15px; border-radius: 14px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.msg.user .bubble { background: var(--brand); color: #fff; border-color: var(--brand); border-top-right-radius: 4px; }
.msg.assistant .bubble { border-top-left-radius: 4px; }
.msg .ai-av { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center; background: linear-gradient(135deg, #6d5dfc, #c04cfd); color: #fff; font-size: 15px; }
.plan { margin-top: 10px; border: 1px solid #ddd8ff; background: #faf9ff; border-radius: 12px; overflow: hidden; white-space: normal; }
.plan-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-weight: 650; border-bottom: 1px solid #ebe8ff; }
.plan ol { margin: 0; padding: 10px 14px 10px 34px; font-size: 13px; color: var(--ink-2); }
.plan ol li { padding: 2px 0; }
.plan-foot { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-top: 1px solid #ebe8ff; background: #fff; }
.plan details { padding: 0 14px 10px; font-size: 12px; }
.plan pre { max-height: 300px; overflow: auto; background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; }
.composer { border-top: 1px solid var(--line); padding: 14px; background: #fff; }
.composer form { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 48px; max-height: 200px; resize: none; }
.thinking { display: inline-flex; gap: 4px; align-items: center; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: blink 1.2s infinite both; }
.thinking i:nth-child(2) { animation-delay: .2s; } .thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.sugg { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font: inherit; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; transition: border-color .15s, background .15s; }
.sugg:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }

/* ---------- studio ---------- */
.studio { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.tree a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px; color: var(--ink-2); text-decoration: none !important; font-size: 13.5px; }
.tree a:hover { background: #f1f2f8; }
.tree a.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.tree .app { font-weight: 650; font-size: 12px; color: var(--muted); padding: 12px 10px 4px; text-transform: uppercase; letter-spacing: .04em; }
.ftype { font-size: 11.5px; font-weight: 600; color: var(--muted); background: #eef0f6; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none !important; }
.tabs a.on { color: var(--brand-ink); border-color: var(--brand); }
dialog { border: 0; border-radius: 16px; padding: 0; box-shadow: var(--shadow-lg); width: min(560px, 94vw); }
dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
dialog .d-head { padding: 18px 20px 6px; } dialog .d-body { padding: 10px 20px; } dialog .d-foot { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- print ---------- */
.doc { max-width: 860px; margin: 24px auto; background: #fff; padding: 48px 54px; box-shadow: var(--shadow); border-radius: 6px; }
.doc table { width: 100%; border-collapse: collapse; }
.doc th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 2px solid var(--ink); padding: 8px 6px; }
.doc td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
@media print { .noprint { display: none !important; } body { background: #fff; } .doc { box-shadow: none; margin: 0; padding: 0; max-width: none; } }

/* ---------- platform (root host) ---------- */
.pnav { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 20px; height: 64px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); background: rgba(255,255,255,.8); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid rgba(15,23,42,.06); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: none !important; letter-spacing: -.02em; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: conic-gradient(from 210deg, #6d5dfc, #c04cfd, #ff7ab6, #6d5dfc); box-shadow: 0 6px 16px -6px rgba(140, 80, 255, .7); font-size: 16px; }
.pnav .links { display: flex; gap: 4px; margin-left: 12px; }
.pnav .links a { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 550; text-decoration: none; }
.pnav .links a:hover { background: rgba(15,23,42,.05); }
.pnav .end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.auth { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 40px 16px;
  background: radial-gradient(800px 400px at 15% 0%, rgba(109,93,252,.12), transparent 60%), radial-gradient(700px 400px at 100% 100%, rgba(192,76,253,.10), transparent 60%); }
.auth-card { width: min(430px, 100%); padding: 32px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.alert { padding: 10px 12px; border-radius: 9px; background: var(--red-soft); color: var(--red); font-size: 13px; margin-bottom: 14px; }
.alert.info { background: var(--blue-soft); color: var(--blue); }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.proj { display: block; padding: 20px; color: var(--ink); text-decoration: none !important; transition: box-shadow .15s, transform .15s; }
.proj:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.proj .mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; margin-bottom: 14px; }
.proj .host { font-size: 12.5px; color: var(--brand-ink); font-weight: 600; }
.proj.new { display: grid; place-items: center; text-align: center; border: 2px dashed #d4d7e6; background: transparent; box-shadow: none; color: var(--muted); min-height: 170px; }
.proj.new:hover { border-color: var(--brand); color: var(--brand-ink); background: #fbfaff; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tpl { position: relative; display: block; padding: 16px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; }
.tpl:hover { border-color: #cfd3e6; }
.tpl input { position: absolute; opacity: 0; }
.tpl .tick { position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid #cdd2e2; display: grid; place-items: center; color: #fff; font-size: 12px; }
.tpl:has(input:checked) { border-color: var(--brand); background: #fbfaff; box-shadow: 0 0 0 3px rgba(109,93,252,.12); }
.tpl:has(input:checked) .tick { background: var(--brand); border-color: var(--brand); }
.tpl .ic { font-size: 26px; margin-bottom: 6px; }
.tpl b { display: block; margin-bottom: 2px; }
.tpl p { font-size: 12.5px; color: var(--muted); margin: 0; }
.slug-field { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.slug-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109,93,252,.15); }
.slug-field span { display: flex; align-items: center; padding: 0 12px; color: var(--muted); background: #f6f7fb; border-left: 1px solid var(--line); white-space: nowrap; }
.slug-field span:first-child { border-left: 0; border-right: 1px solid var(--line); }
.slug-field input { border: 0; flex: 1; height: 40px; padding: 0 12px; font: inherit; outline: none; min-width: 0; }
.okmsg { color: var(--green); font-size: 12.5px; margin-top: 5px; font-weight: 600; }
.badmsg { color: var(--red); font-size: 12.5px; margin-top: 5px; font-weight: 600; }

/* ---------- responsive ---------- */
.sb-toggle { display: none; }
@media (max-width: 1100px) {
  .form-layout, .home-grid, .builder { grid-template-columns: 1fr; }
  .chatter { position: static; max-height: none; }
  .builder { height: auto; }
  .chat { height: calc(100vh - 140px); }
  .charts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .main { margin-left: 0; }
  .sidebar { z-index: 80; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sb-toggle { display: grid; }
  .topbar { padding: 0 14px; }
  .content { padding: 16px; }
  .fgrid, .charts { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; } .kpi .val { font-size: 19px; }
  .chart-card.s2 { grid-column: auto; }
  .studio { grid-template-columns: 1fr; }
  .search-box { width: auto; flex: 1; }
  .search-box kbd { display: none; }
  .pnav .links { display: none; }
  .crumbs { display: none; }
}

/* ---------- lines scroll, tabs, calendar, grouped lists ---------- */
.lines-scroll { overflow-x: auto; border-radius: 10px; }
.lines-scroll table { min-width: 100%; }
.lines-scroll th, .lines-ro td { white-space: nowrap; }
.ftabs { margin-top: 18px; }
.ftabs .tabs { margin-bottom: 4px; overflow-x: auto; }
.chip.off { background: #fff; border: 1px solid var(--line); color: var(--ink-2); padding-right: 10px; text-decoration: none; }
.chip.off:hover { border-color: var(--brand); color: var(--brand-ink); }
a.chip { text-decoration: none !important; }
.grp-h td { background: #f7f7fc; font-size: 13px; padding-top: 12px !important; }
.grp-t td { font-weight: 700; color: var(--ink-2); border-bottom: 1px solid var(--line) !important; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-h { padding: 8px 10px; font-size: 12px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); background: #fafbfd; }
.cal-d { min-height: 112px; padding: 6px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); min-width: 0; }
.cal-d:nth-child(7n) { border-right: 0; }
.cal-d.out { background: #fafbfd; } .cal-d.out .cal-n { color: var(--faint); }
.cal-n { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.cal-n a { color: inherit; }
.cal-d.today .cal-n { color: #fff; } .cal-d.today .cal-n a, .cal-d.today .cal-n span { color: #fff; }
.cal-d.today .cal-n { display: inline-block; background: var(--brand); border-radius: 6px; padding: 0 6px; }
.cal-ev { display: block; font-size: 12px; font-weight: 600; padding: 2px 6px; border-radius: 5px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none !important; }
@media (max-width: 860px) { .cal-d { min-height: 70px; padding: 3px; } .cal-ev { font-size: 10.5px; padding: 1px 3px; } }

/* ---------- approvals ---------- */
.approval { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 12px; border-left: 4px solid var(--line); }
.approval.waiting { border-left-color: #f59e0b; background: #fffbf2; }
.approval.ok { border-left-color: var(--green); } .approval.no { border-left-color: var(--red); }
.approval .ap-ic { font-size: 22px; } .approval .ap-body { flex: 1; min-width: 0; }
.approval .ap-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.access-grid td, .access-grid th { text-align: center; } .access-grid td:first-child, .access-grid th:first-child { text-align: left; }

/* ---------- navigation style: Apps home (Odoo-like) ---------- */
.nav-apps .main { margin-left: 0; }
.nav-apps .topbar { background: #fff; gap: 6px; padding: 0 18px; }
.nav-apps .content { margin: 0 auto; }
.app-home { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--ink-2); flex: none; text-decoration: none !important; }
.app-home:hover { background: #f1f2f8; color: var(--brand-ink); }
.app-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--ink); padding: 0 10px 0 4px; white-space: nowrap; text-decoration: none !important; }
.app-menu { display: flex; gap: 2px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.app-menu a { padding: 7px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 550; white-space: nowrap; text-decoration: none !important; }
.app-menu a:hover { background: #f4f5f9; }
.app-menu a.on { background: var(--brand-soft); color: var(--brand-ink); }
.launcher { min-height: calc(100vh - 106px); padding: 36px 0 60px; }
.nav-apps:has(.launcher) { background: radial-gradient(900px 500px at 10% 0%, rgba(109,93,252,.16), transparent 60%), radial-gradient(800px 500px at 100% 100%, rgba(192,76,253,.12), transparent 60%), #f6f7fb; }
.nav-apps:has(.launcher) .topbar { background: rgba(255,255,255,.6); }
.launch-grid { display: grid; grid-template-columns: repeat(auto-fill, 118px); justify-content: center; gap: 28px 22px; max-width: 900px; margin: 0 auto; }
.launch { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 4px; border-radius: 16px; color: var(--ink); text-decoration: none !important; transition: transform .15s; }
.launch:hover { transform: translateY(-3px); }
.launch-ic { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; font-size: 34px; background: linear-gradient(145deg, color-mix(in srgb, var(--c) 22%, white), color-mix(in srgb, var(--c) 42%, white)); box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--c) 80%, black), inset 0 1px 0 rgba(255,255,255,.6); }
.launch-ic.ai { background: linear-gradient(135deg, #6d5dfc, #c04cfd); color: #fff; font-size: 30px; }
.launch:hover .launch-ic { box-shadow: 0 16px 30px -12px color-mix(in srgb, var(--c) 85%, black), inset 0 1px 0 rgba(255,255,255,.6); }
.launch-name { font-size: 13.5px; font-weight: 600; text-align: center; line-height: 1.3; }
.navpick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.navopt { position: relative; display: block; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; background: #fff; }
.navopt input { position: absolute; opacity: 0; }
.navopt:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109,93,252,.12); }
.navopt .pv { height: 74px; border-radius: 8px; background: #f1f2f8; display: flex; overflow: hidden; margin-bottom: 8px; }
.navopt .pv .sb { width: 26%; background: #0f1222; }
.navopt .pv .grid { flex: 1; display: grid; grid-template-columns: repeat(4, 16px); gap: 8px; place-content: center; }
.navopt .pv .grid i { width: 16px; height: 16px; border-radius: 5px; background: var(--brand); opacity: .55; }
.navopt b { font-size: 13px; } .navopt small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 860px) { .launch-grid { grid-template-columns: repeat(auto-fill, 92px); gap: 20px 10px; } .launch-ic { width: 60px; height: 60px; font-size: 28px; border-radius: 17px; } .nav-apps .app-title { display: none; } }
dialog { overflow: visible; } dialog .d-body { max-height: 70vh; overflow: visible; }

/* ---------- custom pages ---------- */
.page-bar { display: flex; align-items: center; gap: 8px; margin: -8px 0 10px; }
.page-frame { width: 100%; height: calc(100vh - 140px); border: 1px solid var(--line); border-radius: 12px; background: #fff; display: block; }
.page-frame.full { position: fixed; inset: 0; height: 100vh; border: 0; border-radius: 0; }

.claude-cta { display: flex; align-items: center; gap: 14px; margin: 14px 18px 0; padding: 14px 16px; border-radius: 12px; background: linear-gradient(135deg, #f3f0ff, #fbefff); border: 1px solid #e3dcff; }

.gw { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.gw summary { cursor: pointer; display: flex; gap: 8px; align-items: center; }
