/* מערכת תיקים — עיצוב RTL נקי, מותאם למחשב ולנייד */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1c2330;
  --muted: #5e6a7d;
  --primary: #1f4fd1;
  --primary-soft: #e8eefc;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #9a6400;
  --warn-soft: #fff4dc;
  --ok: #1e7b4f;
  --ok-soft: #e4f5ec;
  --demo: #7a3fb5;
  --demo-soft: #f3eafb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d; --surface: #1a2029; --surface-2: #222a35; --border: #2e3846; --text: #e6e9ef; --muted: #9aa5b5;
    --primary: #6e97ff; --primary-soft: #1f2b47; --danger: #ff7a6b; --danger-soft: #3a1f1d; --warn: #f0b74f; --warn-soft: #3a2f17;
    --ok: #5fd39a; --ok-soft: #17332a; --demo: #c49cf0; --demo-soft: #2d2140;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", "Rubik", "Assistant", Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }

/* מבנה */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--surface); border-inline-start: 1px solid var(--border); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.brand { font-weight: 700; font-size: 1.15rem; padding: .25rem .5rem 1rem; display: flex; align-items: center; gap: .5rem; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: .9rem; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: .5rem .65rem; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav .sep { height: 1px; background: var(--border); margin: .6rem .4rem; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar form.search { flex: 1; max-width: 460px; }
.topbar input[type=search] { width: 100%; }
.content { padding: 1.25rem; max-width: 1400px; width: 100%; }
.menu-btn { display: none; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth .card { width: 100%; max-width: 420px; }

/* רכיבים */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; display: block; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat .num { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat.alert .num { color: var(--danger); }
.stat.warn .num { color: var(--warn); }

.btn, button { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .45rem .85rem; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.btn:hover, button:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-wa { background: #1f8f4e; border-color: #1f8f4e; color: #fff; }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: .2rem .55rem; font-size: .85rem; }
.btn-link { border: 0; background: none; color: var(--primary); padding: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .75rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.check { display: flex; align-items: center; gap: .4rem; color: var(--text); font-size: .95rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters > * { flex: 1 1 150px; }
.filters .btn, .filters button { flex: 0 0 auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; font-size: .75rem; padding: .08rem .45rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.src-manual { background: var(--surface-2); color: var(--muted); }
.src-imported { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.src-synced { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.src-system { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-demo { background: var(--demo-soft); color: var(--demo); border-color: transparent; font-weight: 600; }
.st-not_connected { background: var(--surface-2); color: var(--muted); }
.st-configured { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.st-connected { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.st-error, .badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.notice { padding: .7rem 1rem; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--border); color: var(--muted); }
.demo-banner { background: var(--demo-soft); color: var(--demo); padding: .55rem 1.25rem; font-weight: 600; font-size: .9rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .55rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .6rem; align-items: flex-start; justify-content: space-between; }
.list li:last-child { border-bottom: 0; }
.list .meta { color: var(--muted); font-size: .82rem; }
.empty { color: var(--muted); padding: .75rem 0; }
.overdue { color: var(--danger); font-weight: 600; }

/* ציר זמן */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding-inline-start: 1.6rem; padding-bottom: .9rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 2px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline li.src-imported-dot::before { border-color: var(--warn); }
.timeline li.src-synced-dot::before { border-color: var(--ok); }
.timeline .when { font-size: .8rem; color: var(--muted); }

/* לוח שנה */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { text-align: center; font-size: .8rem; color: var(--muted); padding: .25rem; }
.cal .day { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; min-height: 100px; padding: .3rem; font-size: .8rem; overflow: hidden; }
.cal .day.empty-day { background: transparent; border-color: transparent; }
.cal .day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal .num { font-weight: 600; margin-bottom: .2rem; }
.cal .item { display: block; border-radius: 4px; padding: 1px 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.cal .k-hearing { background: var(--primary-soft); }
.cal .k-deadline { background: var(--danger-soft); }
.cal .k-meeting { background: var(--ok-soft); }
.cal .k-decision { background: var(--warn-soft); }
.cal .k-task { background: var(--surface-2); border: 1px dashed var(--border); }

details.dropdown { position: relative; }
details.dropdown summary { list-style: none; cursor: pointer; }
details.dropdown summary::-webkit-details-marker { display: none; }
details.dropdown .menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); min-width: 190px; padding: .35rem; z-index: 20; }
details.dropdown .menu a, details.dropdown .menu button { display: block; width: 100%; text-align: start; padding: .45rem .6rem; border: 0; border-radius: 6px; background: none; color: var(--text); }
details.dropdown .menu a:hover, details.dropdown .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu-label { padding: .3rem .6rem; }
ol.steps { padding-inline-start: 1.3rem; margin: .5rem 0 1rem; }
ol.steps li { margin-bottom: .6rem; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }
.bell { position: relative; }
.bell .count { position: absolute; top: -6px; inset-inline-start: -6px; background: var(--danger); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .35rem; }
details.collapsible > summary { cursor: pointer; color: var(--primary); margin-bottom: .5rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
pre.ocr { white-space: pre-wrap; background: var(--surface-2); padding: .75rem; border-radius: 8px; max-height: 320px; overflow: auto; font-size: .85rem; }
.qr { background: #fff; padding: .5rem; border-radius: 8px; width: 200px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* נייד */
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-main { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; z-index: 30; transform: translateX(100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 1rem; }
  .topbar { padding: .5rem 1rem; }
  .cal .day { min-height: 64px; }
  .cal .item { font-size: .7rem; }
  .hide-mobile { display: none; }
}
