:root {
  --bg: #f3f5f9; --card: #fff; --ink: #172033; --muted: #667085; --line: #e5e8ef; --soft: #f7f8fb;
  --navy: #13284b; --navy-2: #1d3d6e; --blue: #1d4ed8; --blue-soft: #e8eefb;
  --ok: #157347; --ok-soft: #e5f4ec; --warn: #a15c00; --warn-soft: #fff4e2; --bad: #b42318; --bad-soft: #fdecea;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Heebo, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 20px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
button, input, select, textarea { font: inherit; color: inherit; }

/* header */
.top { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; }
.top-in { display: flex; align-items: center; gap: 12px; padding-block: 14px 10px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.logo svg { width: 24px; height: 24px; color: #fff; }
.brand b { display: block; font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.brand span { font-size: 12px; opacity: .75; }
.top-end { margin-inline-start: auto; display: flex; align-items: center; gap: 14px; }
.seg { display: inline-flex; background: rgba(255,255,255,.12); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; color: #fff; padding: 3px 11px; border-radius: 999px; cursor: pointer; font-size: 12px; opacity: .8; }
.seg button.on { background: #fff; color: var(--navy); opacity: 1; font-weight: 600; }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; color: rgba(255,255,255,.72); padding: 10px 14px 12px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 500; }
.tabs button:hover { color: #fff; }
.tabs button.on { color: #fff; border-bottom-color: #7fb0ff; }

main { padding-block: 18px 70px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 16px; cursor: pointer; font-weight: 500; transition: background .15s, box-shadow .15s, transform .05s; }
.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(29,78,216,.25); }
.btn.primary:hover { background: #1a43bd; }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.success:hover { background: #10603a; }
.btn.ghost { background: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn.danger { color: var(--bad); }
.sparkle { font-size: 13px; }
.icon-btn { border: 1px solid var(--line); background: #fff; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 18px; line-height: 1; }
.icon-btn:hover { background: var(--soft); }
[dir=rtl] .icon-btn { transform: scaleX(-1); }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; }
.toolbar label { color: var(--muted); }
.datebox { display: flex; align-items: center; gap: 6px; }
input[type=date], input[type=text], input[type=number], select, textarea { border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #93b4f5; box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.daylabel { font-weight: 600; margin-inline-start: 6px; }
.chips { display: flex; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 12px; }
.chip:hover { background: var(--blue-soft); border-color: #c9d7f6; }

/* hero */
.hero { margin-top: 16px; padding: 34px 28px; text-align: center; }
.hero-ic svg { width: 64px; height: 64px; }
.hero h2 { margin: 10px 0 4px; font-size: 21px; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 24px auto 10px; max-width: 860px; text-align: start; }
.how div { background: var(--soft); border-radius: 12px; padding: 14px 16px; }
.how b { display: block; margin: 6px 0 2px; }
.how p { margin: 0; color: var(--muted); font-size: 13px; }
.num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; }
.privacy { margin-top: 16px; color: var(--muted); font-size: 12px; }

/* progress */
.progress { margin-top: 16px; padding: 14px 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.pstep { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--soft); color: var(--muted); }
.pstep .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #fff; }
.pstep .ic svg { width: 17px; height: 17px; }
.pstep b { display: block; color: var(--ink); font-weight: 500; font-size: 13px; }
.pstep.run { background: var(--blue-soft); }
.pstep.done .state { color: var(--ok); }
.pstep.fail .state { color: var(--bad); }
.spin { width: 14px; height: 14px; border: 2px solid #b9cbf3; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { margin: 12px 2px; color: var(--muted); min-height: 18px; }
.status.err { color: var(--bad); }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 26px; color: var(--navy); font-weight: 700; }
.tile span { color: var(--muted); font-size: 12px; }
.tile.accent { background: linear-gradient(135deg, #1d4ed8, #2f6be6); border: 0; }
.tile.accent b, .tile.accent span { color: #fff; }
.bulk { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }

/* entries */
.entry { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 12px; margin-bottom: 12px; overflow: hidden; }
.entry::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: #c5d3ef; }
.entry.c-high::before { background: var(--ok); }
.entry.c-medium::before { background: #3b82f6; }
.entry.c-low::before { background: #f59e0b; }
.entry.approved { border-color: #9fd3b6; background: #fbfefc; }
.entry.rejected { opacity: .5; }
.grp-hd { margin: 22px 2px 10px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.carrybox { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 8px 10px; background: var(--soft); border-radius: 8px; font-size: 13px; }
.carrybox.hidden { display: none; }
.carrybox input { width: auto; }
.carried-card { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 8px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13px; color: var(--muted); }
.carried-card .btn { margin-inline-start: auto; }
.e-top { display: grid; grid-template-columns: minmax(240px, 1.1fr) auto; gap: 14px; align-items: start; }
.e-matter { position: relative; }
.mchip { display: flex; align-items: center; gap: 8px; border: 1px dashed #c9d2e3; border-radius: 10px; padding: 7px 10px; cursor: text; min-height: 40px; background: var(--soft); }
.mchip.set { border-style: solid; border-color: #c9d7f6; background: var(--blue-soft); }
.mchip.none { border-color: #f3c47a; background: var(--warn-soft); color: var(--warn); }
.mchip .mno { font-weight: 700; color: var(--navy); white-space: nowrap; }
.mchip .mname { font-size: 13px; }
.mchip .mcl { font-size: 12px; color: var(--muted); }
.mchip input { border: 0; background: transparent; padding: 0; box-shadow: none !important; flex: 1; min-width: 120px; }
/* The list is placed on <body> with position:fixed (see placeDd in app.js), so the entry card (overflow:hidden) can't clip it. */
.dd { position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(16,24,40,.18); max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }
.dd .opt.hl { background: var(--blue-soft); }
.dd .star { float: inline-end; padding: 0 6px; font-size: 16px; line-height: 1; color: #c3cad8; cursor: pointer; }
.dd .star.on, .dd .star:hover { color: #f5a623; }
.mergesel { width: auto; max-width: 190px; padding: 4px 8px; font-size: 12px; border-radius: 8px; }
.dd .grp { padding: 6px 10px; font-size: 11px; color: var(--muted); background: var(--soft); }
.dd .opt { padding: 7px 10px; cursor: pointer; border-top: 1px solid #f1f3f7; }
.dd .opt:hover { background: var(--blue-soft); }
.dd .opt b { color: var(--navy); }
.dd .opt small { display: block; color: var(--muted); }
.hours { display: flex; align-items: center; gap: 4px; }
.hours button { width: 30px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 16px; }
.hours button:hover { background: var(--soft); }
.hours input { width: 70px; text-align: center; font-weight: 700; font-size: 16px; }
.hours .u { color: var(--muted); font-size: 12px; margin-inline-start: 4px; }
.e-narr { margin-top: 10px; }
.e-narr textarea { width: 100%; min-height: 62px; resize: vertical; line-height: 1.5; }
.e-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.pill { border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 500; }
.pill.high { background: var(--ok-soft); color: var(--ok); }
.pill.medium { background: var(--blue-soft); color: var(--blue); }
.pill.low { background: var(--warn-soft); color: var(--warn); }
.pill.nb { background: #eef0f4; color: var(--muted); }
.pill.ok { background: var(--ok); color: #fff; }
.linkbtn { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; font-size: 12px; }
.e-actions { margin-inline-start: auto; display: flex; gap: 6px; }
.sources { display: none; margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.entry.open .sources { display: block; }
.src { display: flex; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.src .ic { width: 26px; height: 26px; border-radius: 7px; background: var(--soft); display: grid; place-items: center; flex: none; }
.src .ic svg { width: 15px; height: 15px; color: var(--navy-2); }
.src .when { color: var(--muted); font-size: 12px; min-width: 42px; }
.src .min { color: var(--muted); font-size: 12px; min-width: 40px; }
.src a { color: var(--ink); text-decoration: none; }
.src a:hover { color: var(--blue); text-decoration: underline; }
.src .note { color: var(--muted); font-size: 12px; }

/* folds & tables */
.fold { margin-top: 16px; padding: 4px 16px; }
.fold summary { cursor: pointer; padding: 10px 0; font-weight: 600; color: var(--navy); }
.count { background: var(--soft); border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--muted); font-weight: 500; }
.table-card { overflow: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
table.list th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--soft); }
table.list tr:last-child td { border-bottom: 0; }
.ltr { direction: ltr; unicode-bidi: plaintext; }
.hint { display: inline-block; background: var(--blue-soft); color: var(--blue); border-radius: 6px; padding: 1px 6px; font-size: 11px; margin: 1px 2px; }

/* forms */
.form { padding: 18px 20px; margin-bottom: 14px; }
.form h3 { margin: 0 0 12px; font-size: 16px; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.field { display: grid; grid-template-columns: 220px 1fr; gap: 10px; align-items: center; margin-bottom: 12px; }
.field label { color: var(--muted); }
.checks { display: flex; gap: 18px; flex-wrap: wrap; }
.actions { margin-top: 8px; }
.note { padding: 14px 18px; color: #3b4660; font-size: 13px; background: #f3f7ff; border-color: #dbe5fb; }
.ref-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 14px; }
.ref-info div { background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.ref-info b { display: block; font-size: 20px; color: var(--navy); }
.bar-wrap { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar-fill { height: 100%; width: 0; background: var(--blue); transition: width .3s; }

.toast { position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
[dir=rtl] .toast { transform: translateX(50%) translateY(20px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
[dir=rtl] .toast.show { transform: translateX(50%) translateY(0); }

@media (max-width: 820px) {
  .how, .tiles { grid-template-columns: 1fr 1fr; }
  .e-top, .field { grid-template-columns: 1fr; }
  .user span#who { display: none; }
}
