/* Palette sampled from the design mockup (button, title, orange underline, info box). */
:root {
  --bg: #f7f5fe;
  --card: #ffffff;
  --text: #2d2442;
  --muted: #6b6280;
  --border: #e6e0f8;
  --accent: #4f1694;
  --accent-hover: #3e0f78;
  --accent-soft: #ece6fd;
  --on-accent: #ffffff;
  --title: #45128a;
  --orange: #f0a660;
  --box: #ddd2fa;
  --divider: #4b2883;
  --danger: #b4232f;
  --danger-soft: #fbecee;
  --high: #b4232f;
  --medium: #a8620f;
  --low: #2f7a52;
  color-scheme: light;
}

/* The survey page (html.survey) stays light like the design; the admin page follows the OS theme. */
@media (prefers-color-scheme: dark) {
  :root:not(.survey) {
    --title: #d6c2f8;
    --box: #2f2545;
    --divider: #c4a7f5;
    --bg: #141019;
    --card: #1d1726;
    --text: #ece8f3;
    --muted: #a49bb5;
    --border: #332a40;
    --accent: #c4a7f5;
    --accent-hover: #d6c2f8;
    --accent-soft: #2a2138;
    --on-accent: #1d1726;
    --danger: #ff8a8f;
    --danger-soft: #3a2026;
    --high: #ff8a8f;
    --medium: #f0b44c;
    --low: #6fcf9a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, "Segoe UI", Arial, sans-serif;
  border-top: 4px solid var(--accent);
}

[hidden] { display: none !important; }

.wrap { max-width: 760px; margin: 0 auto; padding: 28px 16px 64px; }
.wrap.wide { max-width: 1100px; }

h1 { font-size: 1.6rem; margin: 0 0 8px; color: var(--title); font-weight: 700; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
h3 { font-size: 1.05rem; margin: 0; }
h4 { font-size: 1rem; margin: 0; }

.intro p { margin: 0 0 12px; }
.meta { margin: 0 0 12px; padding-inline-start: 20px; color: var(--muted); }
.warn { color: var(--danger); margin: 0 0 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 16px;
}
.notice { text-align: center; }

.field { margin-bottom: 20px; }
.field.invalid .label { color: var(--danger); }
.label { font-weight: 600; margin-bottom: 6px; }
.req { color: var(--danger); }
.hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.err { color: var(--danger); font-size: 0.875rem; margin-top: 4px; }

.choices { display: grid; gap: 6px; }
.choice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 4px; flex: none; accent-color: var(--accent); }

input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.choices + input, .choices + textarea, input + input { margin-top: 8px; }
select + input { margin-top: 8px; }

.type-group { margin-bottom: 24px; }
.type-group + .type-group { border-top: 1px solid var(--border); padding-top: 20px; }
.type-title { margin-bottom: 12px; color: var(--accent); }

.process { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.process-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sub { border-inline-start: 3px solid var(--accent-soft); padding-inline-start: 14px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--on-accent); padding: 9px 20px;
}
button:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--accent); }
button.secondary:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: 4px 8px; }
button.link:hover:not(:disabled) { background: none; text-decoration: underline; }
button.link.del { color: var(--danger); }

.actions { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.err-banner { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 10px 14px; width: 100%; margin-bottom: 12px; }
.ok-banner { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }

.identity { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0 0 12px; }
.identity dt { color: var(--muted); }
.identity dd { margin: 0; font-weight: 600; }

/* ---------- ממשק ניהול ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.toolbar .group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar h1 { margin: 0; }
.status-pill { padding: 3px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.status-pill.open { background: color-mix(in srgb, var(--low) 15%, transparent); color: var(--low); }
.status-pill.closed { background: var(--danger-soft); color: var(--danger); }

.part-title {
  font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted);
  margin: 32px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}

/* דשבורד */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 600px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px; text-align: start;
}
.tile:hover:not(:disabled) { background: var(--card); border-color: var(--accent); }
.tile[aria-expanded="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile .num { font-size: 2.2rem; font-weight: 700; line-height: 1.1; color: var(--accent); }
.tile .cap { color: var(--muted); font-size: 0.95rem; }
.tile .more { color: var(--accent); font-size: 0.8rem; margin-top: 6px; }

.breakdown { margin-top: 12px; }
.bar { height: 6px; border-radius: 3px; background: var(--accent-soft); min-width: 80px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.warn-bar > span { background: var(--medium); }
td.bar-cell { width: 40%; vertical-align: middle; }

/* טבלאות */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; font-size: 0.85rem; }
tr:last-child td { border-bottom: none; }
tr.row { cursor: pointer; }
tr.row:hover { background: var(--accent-soft); }

.lvl { font-weight: 700; }
.lvl.high { color: var(--high); }
.lvl.medium { color: var(--medium); }
.lvl.low { color: var(--low); }

.detail td { background: var(--bg); }
.detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.detail h4 { margin: 12px 0 6px; }

/* קבוצות לפי מחלקה */
details.dept { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--card); }
details.dept > summary {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 11px 14px; cursor: pointer; list-style: none; border-radius: 10px;
}
details.dept > summary::-webkit-details-marker { display: none; }
details.dept > summary::before { content: "‹"; color: var(--muted); transition: transform 0.15s; }
details.dept[open] > summary::before { transform: rotate(90deg); }
details.dept > summary:hover { background: var(--accent-soft); }
details.dept > summary .name { font-weight: 600; flex: 1; }
details.dept > summary .meta-line { color: var(--muted); font-size: 0.9rem; }
details.dept > .table-wrap { border-top: 1px solid var(--border); padding: 4px 6px 6px; }

.import-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.import-row input[type="file"] { max-width: 100%; }
.pending { color: var(--medium); font-weight: 600; }
.filled { color: var(--low); font-weight: 600; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; background: var(--accent-soft); color: var(--accent); margin-inline-start: 6px; font-weight: 600; }
.muted { color: var(--muted); }

.mail-actions { display: grid; gap: 10px; margin-bottom: 8px; }
.mail-action { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.mail-action .what { flex: 1; min-width: 220px; }
.mail-action .what .hint { margin: 2px 0 0; }
.mail-log-title { margin: 24px 0 10px; }
.mode { border-radius: 8px; padding: 9px 14px; margin-bottom: 14px; font-size: 0.9rem; font-weight: 600; }
.mode.graph { background: color-mix(in srgb, var(--low) 12%, transparent); color: var(--low); }
.mode.dry-run { background: color-mix(in srgb, var(--medium) 14%, transparent); color: var(--medium); }
.mode.off { background: var(--danger-soft); color: var(--danger); }
.preview { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

.login { max-width: 380px; margin: 60px auto; }
.login form { display: grid; gap: 12px; }

/* ---------- Survey page: the design mockup (html.survey) ---------- */

.survey body { border-top: 0; background: var(--bg); }

/* Decorative top band and left strip, cropped from the mockup (public/img). */
.survey .hero-band {
  height: clamp(56px, 9vw, 112px);
  background: url(/img/header.jpg) left top / cover no-repeat;
}
@media (min-width: 1240px) {
  .survey body::before {
    content: "";
    position: fixed;
    left: 0;
    top: clamp(56px, 9vw, 112px);
    width: 213px;
    height: 554px;
    background: url(/img/side.jpg) left top / 213px 554px no-repeat;
    pointer-events: none;
  }
}

.survey .wrap { position: relative; padding-top: 8px; }

.survey .hero-title {
  display: inline-block;
  margin: 18px 0 22px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--orange);
  font-size: 1.9rem;
  color: var(--title);
}

/* Light purple box with the calendar icon and divider, like the deadline box. */
.survey .info-box {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--box);
  color: var(--title);
  font-weight: 700;
}
.survey .info-box img { width: 40px; height: 40px; flex: none; }
.survey .info-box .vbar { width: 2px; height: 30px; background: var(--divider); flex: none; }

/* Paragraph with the clipboard icon in its circle. */
.survey .icon-para { display: flex; align-items: flex-start; gap: 14px; margin: 0 0 24px; }
.survey .icon-para img { width: 56px; height: 56px; flex: none; }
.survey .icon-para p { margin: 6px 0 0; }

.survey .card {
  border-radius: 16px;
  border-color: var(--border);
  box-shadow: 0 2px 14px rgba(79, 22, 148, 0.06);
}
.survey .card h2 { color: var(--title); }
.survey .warn { color: var(--text); margin: 0; }

/* Pill buttons with the chevron, like the mockup's call to action. */
.survey button { border-radius: 999px; }
.survey #submit { padding: 12px 44px; font-size: 1.1rem; font-weight: 700; }
.survey .actions { align-items: center; }
.survey .chev { width: 12px; height: 18px; margin-inline-start: 16px; vertical-align: middle; }
