/* TaskFlow — Enterprise SaaS / real-time operations. RTL-first, dense, light+dark. */

:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF6FF;
  --accent: #059669;
  --accent-soft: #ECFDF5;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --warn: #F59E0B;
  --warn-soft: #FFFBEB;

  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --fg: #0F172A;
  --fg-2: #334155;
  --muted: #64748B;
  --line: #E4ECFC;
  --line-strong: #CBD5E1;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .06);
  --shadow-md: 0 4px 12px rgb(15 23 42 / .08);
  --shadow-lg: 0 12px 32px rgb(15 23 42 / .14);

  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-full: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --row-h: 40px;
  --fast: 150ms cubic-bezier(.2,.6,.3,1);
  --mid: 220ms cubic-bezier(.2,.6,.3,1);

  --st-todo: #94A3B8; --st-working: #2563EB; --st-stuck: #DC2626;
  --st-waiting: #F59E0B; --st-done: #059669; --st-cancelled: #64748B;
  --pr-critical: #DC2626; --pr-high: #F97316; --pr-medium: #2563EB; --pr-low: #94A3B8;
}

:root[data-theme="dark"], html.dark {
  --primary-soft: #17243F; --accent-soft: #08281E; --danger-soft: #2A1315; --warn-soft: #2A2110;
  --bg: #0B1220; --surface: #111C33; --surface-2: #16233D; --fg: #E2E8F0; --fg-2: #CBD5E1;
  --muted: #94A3B8; --line: #1E293B; --line-strong: #334155;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 4px 12px rgb(0 0 0 / .45);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / .55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary-soft: #17243F; --accent-soft: #08281E; --danger-soft: #2A1315; --warn-soft: #2A2110;
    --bg: #0B1220; --surface: #111C33; --surface-2: #16233D; --fg: #E2E8F0; --fg-2: #CBD5E1;
    --muted: #94A3B8; --line: #1E293B; --line-strong: #334155;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-md: 0 4px 12px rgb(0 0 0 / .45);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / .55);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.55 "Segoe UI", "Heebo", "Noto Sans Hebrew", system-ui, -apple-system, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1,h2,h3,h4 { margin: 0; font-weight: 650; line-height: 1.3; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
p { margin: 0 0 var(--s3); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-full); border: 3px solid var(--bg); }

/* ------------------------------------------------------------------ layout */
#app { min-height: 100%; }
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  background: var(--surface); border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s4); border-bottom: 1px solid var(--line); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
}
.brand b { font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; display: block; }
.nav { padding: var(--s2); overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em;
  padding: var(--s3) var(--s3) var(--s1); text-transform: uppercase; }
.nav a {
  display: flex; align-items: center; gap: var(--s2); padding: 8px var(--s3); border-radius: var(--r);
  color: var(--fg-2); font-size: 14px; text-decoration: none; transition: background var(--fast), color var(--fast);
  min-height: 38px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav a .dot { width: 8px; height: 8px; border-radius: var(--r-full); flex: none; }
.nav a .count { margin-inline-start: auto; font-size: 11px; background: var(--surface-2); color: var(--muted);
  padding: 1px 7px; border-radius: var(--r-full); font-weight: 600; }
.nav a.active .count { background: var(--primary); color: #fff; }
.nav a .count.alert { background: var(--danger); color: #fff; }
.sidebar-foot { border-top: 1px solid var(--line); padding: var(--s3); display: flex; align-items: center; gap: var(--s2); }
.avatar { width: 30px; height: 30px; border-radius: var(--r-full); display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700; flex: none; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5); min-height: 60px;
}
.topbar .grow { flex: 1; min-width: 0; }
.content { padding: var(--s5); max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.sub { color: var(--muted); font-size: 13px; }

/* ----------------------------------------------------------------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); }
.card-pad { padding: var(--s4); }
.card-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line); }
.card-head h3 { flex: 1; }
.grid { display: grid; gap: var(--s4); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; align-items: center; gap: var(--s2); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.hr { height: 1px; background: var(--line); margin: var(--s4) 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.btn-group button { border: 0; border-radius: 0; min-height: 34px; padding: 0 12px; background: var(--surface);
  color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-group button + button { border-inline-start: 1px solid var(--line); }
.btn-group button.on { background: var(--primary-soft); color: var(--primary); }

/* ------------------------------------------------------------------- inputs */
.field { display: block; margin-bottom: var(--s3); }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--fg-2); margin-bottom: 5px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number],
input[type=email], input[type=tel], input[type=search], select, textarea {
  width: 100%; min-height: 38px; padding: 7px 11px; background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: var(--r); transition: border-color var(--fast), box-shadow var(--fast);
}
textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.search { position: relative; max-width: 380px; flex: 1; }
.search input { padding-inline-start: 34px; background: var(--surface); }
.search svg { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none; }

/* -------------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--fg-2);
}
.chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: var(--r-full); background: currentColor; }
.chip.st-todo { color: var(--st-todo); background: color-mix(in srgb, var(--st-todo) 14%, transparent); }
.chip.st-working { color: var(--st-working); background: color-mix(in srgb, var(--st-working) 14%, transparent); }
.chip.st-stuck { color: var(--st-stuck); background: color-mix(in srgb, var(--st-stuck) 14%, transparent); }
.chip.st-waiting { color: var(--st-waiting); background: color-mix(in srgb, var(--st-waiting) 16%, transparent); }
.chip.st-done { color: var(--st-done); background: color-mix(in srgb, var(--st-done) 14%, transparent); }
.chip.st-cancelled { color: var(--st-cancelled); background: color-mix(in srgb, var(--st-cancelled) 14%, transparent); }
.chip.pr-critical { color: var(--pr-critical); background: color-mix(in srgb, var(--pr-critical) 13%, transparent); }
.chip.pr-high { color: var(--pr-high); background: color-mix(in srgb, var(--pr-high) 15%, transparent); }
.chip.pr-medium { color: var(--pr-medium); background: color-mix(in srgb, var(--pr-medium) 13%, transparent); }
.chip.pr-low { color: var(--pr-low); background: color-mix(in srgb, var(--pr-low) 16%, transparent); }
.chip.overdue { color: var(--danger); background: var(--danger-soft); }
.chip.type { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }

/* -------------------------------------------------------------------- table */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tbl th { text-align: start; font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 8px var(--s3); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
  background: var(--surface); z-index: 1; }
.tbl td { padding: 6px var(--s3); border-bottom: 1px solid var(--line); height: var(--row-h); vertical-align: middle; }
.tbl tbody tr { transition: background var(--fast); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.done .ttl { color: var(--muted); text-decoration: line-through; }
.tbl .ttl { font-weight: 550; cursor: pointer; }
.tbl .ttl:hover { color: var(--primary); }
.group-bar { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4) 6px; font-weight: 700; font-size: 14px; }
.group-bar .bar { width: 4px; height: 16px; border-radius: 2px; }
.group-bar .n { color: var(--muted); font-weight: 500; font-size: 12px; }

/* ------------------------------------------------------------------- kanban */
.kanban { display: flex; gap: var(--s3); overflow-x: auto; padding-bottom: var(--s3); align-items: flex-start; }
.kcol { flex: 0 0 288px; background: var(--surface-2); border-radius: var(--r-lg); padding: var(--s2); }
.kcol h4 { display: flex; align-items: center; gap: 6px; padding: 6px var(--s2) var(--s2); font-size: 13px; }
.kcol h4 .n { color: var(--muted); font-weight: 500; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: var(--s3); margin-bottom: var(--s2); cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform var(--fast), box-shadow var(--fast); }
.kcard:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kcard .t { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.kcard .meta { display: flex; gap: 5px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.cal .hd { background: var(--surface); padding: 7px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal .cell { background: var(--surface); min-height: 108px; padding: 5px; }
.cal .cell.out { background: var(--surface-2); }
.cal .cell.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal .d { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.cal .ev { font-size: 11.5px; padding: 2px 5px; border-radius: var(--r-sm); margin-bottom: 2px;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-inline-start: 3px solid var(--primary); background: var(--surface-2); }
.cal .ev.done { opacity: .5; text-decoration: line-through; }

/* ----------------------------------------------------------------- timeline */
.gantt { position: relative; overflow-x: auto; }
.gantt .grid-head { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.gantt .day { flex: 0 0 34px; text-align: center; font-size: 11px; color: var(--muted); padding: 5px 0; }
.gantt .lane { display: flex; align-items: center; height: 34px; border-bottom: 1px solid var(--line); position: relative; }
.gantt .bar { position: absolute; height: 20px; border-radius: var(--r-full); background: var(--primary);
  color: #fff; font-size: 11px; padding: 0 8px; display: flex; align-items: center; white-space: nowrap;
  cursor: pointer; }
.gantt .label { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 2;
  width: 200px; flex: none; padding-inline-end: var(--s2); font-size: 13px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------- drawer */
.scrim { position: fixed; inset: 0; background: rgb(15 23 42 / .45); z-index: 60;
  animation: fade var(--fast) both; }
.drawer {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: min(560px, 100%);
  background: var(--surface); z-index: 61; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide var(--mid) both;
}
.drawer-head { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s4);
  border-bottom: 1px solid var(--line); }
.drawer-body { padding: var(--s4); overflow-y: auto; flex: 1; }
@keyframes slide { from { transform: translateX(-24px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
[dir="ltr"] .drawer { animation-name: slide-ltr; }
@keyframes slide-ltr { from { transform: translateX(24px); opacity: 0 } to { transform: none; opacity: 1 } }

.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: var(--s4); }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: min(520px, 100%); max-height: 90vh; overflow-y: auto; animation: pop var(--mid) both; }
@keyframes pop { from { transform: scale(.97); opacity: 0 } to { transform: none; opacity: 1 } }

/* -------------------------------------------------------------------- misc */
.stat { padding: var(--s4); }
.stat .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat .v { font-size: 27px; font-weight: 700; line-height: 1.15; margin-top: 3px; }
.stat .n { font-size: 12px; color: var(--muted); }
.bar-track { height: 7px; background: var(--surface-2); border-radius: var(--r-full); overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: var(--r-full); transition: width var(--mid); }
.hero { background: linear-gradient(135deg, var(--primary) 0%, #4F46E5 100%); color: #fff;
  border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-md); }
.hero h2 { font-size: 20px; margin-bottom: 6px; }
.hero .sub { color: rgb(255 255 255 / .8); }
.hero .btn { background: rgb(255 255 255 / .16); border-color: rgb(255 255 255 / .3); color: #fff; }
.hero .btn:hover { background: rgb(255 255 255 / .26); }
.hero.empty { background: linear-gradient(135deg, #B45309 0%, #DC2626 100%); }
.hero.done { background: linear-gradient(135deg, #047857 0%, #059669 100%); }
.alert { border-radius: var(--r); padding: var(--s3) var(--s4); font-weight: 600; font-size: 14px;
  border: 1px solid; display: flex; gap: var(--s2); align-items: flex-start; }
.alert.warn { background: var(--warn-soft); border-color: var(--warn); color: #92400E; }
.alert.err { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert.ok { background: var(--accent-soft); border-color: var(--accent); color: #065F46; }
:root[data-theme="dark"] .alert.warn, :root[data-theme="dark"] .alert.ok { color: var(--fg); }
.empty-state { text-align: center; padding: var(--s6) var(--s4); color: var(--muted); }
.empty-state h3 { color: var(--fg); margin-bottom: 6px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.spark i { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.toast-wrap { position: fixed; inset-block-end: var(--s4); inset-inline-start: var(--s4); z-index: 90;
  display: flex; flex-direction: column; gap: var(--s2); }
.toast { background: var(--fg); color: var(--bg); padding: 10px var(--s4); border-radius: var(--r);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600; animation: pop var(--fast) both; max-width: 380px; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--accent); color: #fff; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2));
  background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); height: 14px; }
@keyframes sk { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* -------------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s4);
  background: radial-gradient(1000px 500px at 70% -10%, var(--primary-soft), var(--bg)); }
.login { width: min(400px, 100%); }
.login .card-pad { padding: var(--s5); }

/* --------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 65;
    transform: translateX(100%); transition: transform var(--mid); }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .content { padding: var(--s4) var(--s3); }
  .topbar { padding: var(--s2) var(--s3); }
  .menu-btn { display: inline-flex !important; }
  .tbl .hide-sm { display: none; }
}
.menu-btn { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print { .sidebar, .topbar { display: none; } .content { padding: 0; } }

/* ------------------------------------------------------------- food menu */
.food-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--s4); }
.food-col { padding: 0; overflow: hidden; }
.food-col-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.food-col-h b { font-size: 15px; }
.food-day { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.food-day:last-child { border-bottom: 0; }
.food-day-h { display: flex; align-items: baseline; gap: var(--s2); font-weight: 700; font-size: 13px;
  color: var(--fg-2); margin-bottom: var(--s2); }
.food-day-h .muted { font-weight: 400; font-size: 11px; }
.food-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2);
  border-radius: var(--r); cursor: pointer; min-height: 44px; }
.food-row:hover { background: var(--primary-soft); }
.food-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary);
  min-width: 48px; font-size: 14px; }
.food-title { font-weight: 600; }
.food-note { font-size: 12px; color: var(--muted); }
.chip.sm { font-size: 11px; padding: 2px 7px; }
.muted { color: var(--muted); }
.empty { padding: var(--s5) var(--s4); text-align: center; color: var(--muted); font-size: 14px; }
