:root {
  color-scheme: light;
  --bg: #eef3f7;
  --bg-strong: #dfe8ef;
  --surface: #ffffff;
  --surface-raised: rgba(255, 255, 255, 0.92);
  --surface-soft: #f7fafc;
  --text: #162033;
  --text-strong: #0f172a;
  --muted: #65758b;
  --line: #d7e0ea;
  --line-strong: #c7d3df;
  --primary: #0e6f8f;
  --primary-dark: #0a526c;
  --accent: #b46b2a;
  --success: #16714a;
  --danger: #b42318;
  --warning: #9a5a00;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 18px 48px rgba(23, 32, 51, 0.13);
  --shadow-lg: 0 28px 80px rgba(23, 32, 51, 0.18);
  --radius: 8px;
  --radius-sm: 6px;
  --control-h: 42px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  direction: rtl;
  text-align: right;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(238, 243, 247, 0.92) 38%, #e9f0f5),
    var(--bg);
  color: var(--text);
  font-family: Arial, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.boot-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(14, 111, 143, 0.14), transparent 42%),
    linear-gradient(315deg, rgba(180, 107, 42, 0.1), transparent 36%),
    var(--bg);
}

.boot-panel {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  color: var(--text-strong);
}

.boot-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #d7e0ea;
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-view {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(14, 111, 143, 0.16), transparent 42%),
    linear-gradient(315deg, rgba(180, 107, 42, 0.14), transparent 36%),
    var(--bg);
}

.login-panel {
  width: min(460px, 100%);
  background: var(--surface-raised);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  backdrop-filter: blur(18px);
}

.login-panel h1 {
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  color: var(--text-strong);
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 18px;
  color: var(--text-strong);
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin: 18px 0 10px;
  color: var(--text-strong);
  font-size: 16px;
}

.muted {
  color: var(--muted);
  line-height: 1.65;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: #344256;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--control-h);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position: left 16px center, left 10px center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-left: 34px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(14, 111, 143, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: var(--control-h);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 9px 15px;
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-button {
  background: var(--primary);
  color: white;
  box-shadow: 0 12px 26px rgba(14, 111, 143, 0.22);
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.secondary-button {
  background: #eef4f7;
  border-color: var(--line);
  color: #2d3b4d;
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: var(--line-strong);
  background: #f8fbfd;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.86);
  border-color: var(--line);
  color: var(--text);
}

.error-text {
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.demo-users {
  display: grid;
  gap: 7px;
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(247, 250, 252, 0.84);
  color: var(--muted);
  font-size: 13px;
}

.demo-users strong {
  color: var(--text);
}

.dashboard {
  flex: 1;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1740px;
  margin: 0 auto 18px;
}

.topbar h1 {
  margin: 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.breadcrumbs span,
.breadcrumbs button {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  background: #eef6f9;
  color: var(--primary-dark);
  padding: 5px 10px;
  font: inherit;
}

.breadcrumbs button:hover {
  background: #dff1f7;
}

.breadcrumbs span:not(:first-child)::before,
.breadcrumbs button:not(:first-child)::before {
  content: "›";
  margin-inline-end: 8px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(14, 111, 143, 0.18);
  border-radius: 999px;
  padding: 7px 12px;
  background: #e6f3f7;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  max-width: 1740px;
  margin: 0 auto 14px;
}

.stats-grid article {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.stats-grid article::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.stats-grid article:nth-child(2)::before {
  background: var(--warning);
}

.stats-grid article:nth-child(3)::before {
  background: #0ea5e9;
}

.stats-grid article:nth-child(4)::before {
  background: var(--success);
}

.stats-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-strong);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.stats-grid small {
  color: var(--muted);
  font-weight: 800;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(128px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  max-width: 1740px;
  margin: 0 auto 14px;
  padding: 14px;
  background: var(--surface-raised);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.work-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  max-width: 1740px;
  margin: 0 auto;
}

.table-wrap,
.task-panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.table-wrap {
  height: calc(100vh - 250px);
  min-height: 460px;
  overflow: auto;
}

.task-panel {
  min-height: 520px;
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

tbody tr {
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

tbody tr:hover {
  background: #f5fbfd;
}

tbody tr.selected {
  background: #edf8fb;
  box-shadow: inset -4px 0 0 var(--primary);
}

.task-title {
  display: grid;
  gap: 4px;
}

.task-title strong {
  max-width: 430px;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}

.task-title small {
  color: var(--muted);
  line-height: 1.45;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-select,
.status-filter {
  border-width: 2px;
  font-weight: 900;
}

.status-select option,
.status-filter option {
  background: #ffffff;
  color: var(--text);
  font-weight: 800;
}

.status-select option.status-open,
.status-filter option.status-open {
  color: #8a4b00;
  background: #fff3bf;
}

.status-select option.status-done,
.status-filter option.status-done {
  color: #12623d;
  background: #d9fbe8;
}

.status-select option.status-cancelled,
.status-filter option.status-cancelled {
  color: #991b1b;
  background: #ffe1e1;
}

.status-select option.status-unsent,
.status-filter option.status-unsent {
  color: #075985;
  background: #dff4ff;
}

.status-open {
  color: #8a4b00;
  background: #fff3bf;
  border-color: #f6c343;
}

.status-done {
  color: #12623d;
  background: #d9fbe8;
  border-color: #55c985;
}

.status-cancelled {
  color: #991b1b;
  background: #ffe1e1;
  border-color: #f26a6a;
}

.status-unsent {
  color: #075985;
  background: #dff4ff;
  border-color: #38bdf8;
}

.task-panel {
  position: sticky;
  top: 18px;
  padding: 20px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.panel-placeholder {
  display: grid;
  min-height: 480px;
  place-items: center;
  color: var(--muted);
  text-align: center;
  line-height: 1.65;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.panel-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.detail-page {
  flex: 1;
  padding: 24px;
}

.detail-topbar,
.detail-content {
  max-width: 1180px;
  margin-inline: auto;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-topbar h1 {
  margin: 0;
}

.site-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.detail-content {
  display: grid;
  gap: 14px;
}

.detail-hero,
.detail-section,
.detail-edit-form {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-hero h2 {
  margin: 12px 0 8px;
  font-size: clamp(24px, 4vw, 36px);
  overflow-wrap: anywhere;
}

.detail-hero p {
  max-width: 840px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.detail-edit-form {
  box-shadow: var(--shadow-sm);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
  align-items: start;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 14px 0;
}

.meta-item {
  min-width: 0;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px;
  overflow-wrap: anywhere;
}

.meta-item small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-weight: 900;
}

.description-box,
.comment-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px;
  background: #fff;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.description-box {
  background: #fbfdff;
}

.comments {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.comment-card {
  box-shadow: var(--shadow-sm);
}

.comment-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 7px;
}

.comment-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.comment-edit {
  margin-top: 10px;
}

.comment-edit summary {
  width: fit-content;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: #eef4f7;
  border: 1px solid var(--line);
  color: #2d3b4d;
  font-weight: 800;
  cursor: pointer;
}

.comment-edit form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.file-upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.file-upload-form input[type="file"] {
  min-height: var(--control-h);
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: #f8fbfd;
}

.file-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
  box-shadow: var(--shadow-sm);
}

.file-card strong,
.file-card small {
  display: block;
  overflow-wrap: anywhere;
}

.file-card small {
  margin-top: 3px;
  color: var(--muted);
}

.file-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

dialog {
  width: min(860px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(3px);
}

.dialog-form {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 18px;
}

.empty-state,
.import-preview {
  padding: 18px;
  color: var(--muted);
}

.users-list {
  display: grid;
  gap: 10px;
}

.user-row,
.user-create-form {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-soft);
}

.user-create-form {
  background: #f2fbfd;
  border-color: #b9dbe6;
}

.user-create-form h3 {
  margin: 0;
}

.user-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.user-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

.danger-button {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff1f1;
}

.hidden {
  display: none !important;
}

@media (max-width: 1240px) {
  .filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .work-area {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body {
    background: #eef3f7;
  }

  .dashboard {
    padding: 12px;
  }

  .detail-page {
    padding: 10px;
  }

  .detail-topbar {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 10px;
    margin-bottom: 10px;
  }

  .detail-topbar h1 {
    font-size: 26px;
  }

  .detail-hero {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }

  .detail-hero h2 {
    margin: 8px 0 0;
    font-size: 22px;
    line-height: 1.18;
  }

  .detail-hero p {
    display: none;
  }

  .detail-content,
  .detail-grid {
    gap: 10px;
  }

  .detail-section,
  .detail-edit-form {
    padding: 12px;
  }

  .detail-section h3 {
    margin-top: 0;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .role-badge {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stats-grid article {
    padding: 12px;
  }

  .stats-grid span {
    font-size: 24px;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .filters label:first-child,
  .filters button {
    grid-column: 1 / -1;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .user-edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-edit-form .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .detail-edit-form .wide {
    grid-column: 1 / -1;
  }

  .detail-edit-form label {
    gap: 5px;
    font-size: 12px;
  }

  .detail-edit-form input,
  .detail-edit-form select {
    min-height: 38px;
    padding: 8px 10px;
  }

  .detail-edit-form textarea {
    min-height: 96px;
    padding: 9px 10px;
  }

  .detail-edit-form .dialog-actions {
    position: sticky;
    bottom: 8px;
    z-index: 2;
    margin-top: 10px;
    padding-top: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface) 34%);
  }

  .table-wrap {
    background: transparent;
    border: 0;
    box-shadow: none;
    min-height: 0;
    height: auto;
    max-height: 58vh;
    overflow: auto;
    padding: 1px;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    border-spacing: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 8px;
  }

  tbody tr {
    border: 1px solid rgba(255, 255, 255, 0.86);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 11px;
  }

  tbody tr.selected {
    box-shadow: inset -4px 0 0 var(--primary), var(--shadow-sm);
  }

  td {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    border-bottom: 0;
    padding: 5px 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }

  td[data-label="משימה"] {
    grid-template-columns: 1fr;
    padding-top: 0;
  }

  td[data-label="משימה"]::before {
    display: none;
  }

  td[data-label="מבקש"],
  td[data-label="תאריך בקשה"],
  td[data-label="עדכון אחרון"] {
    display: none;
  }

  .task-title strong {
    max-width: none;
    font-size: 16px;
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .comment-form textarea {
    min-height: 86px;
  }

  .comment-card {
    padding: 10px;
  }

  .comment-card header {
    flex-direction: column;
    gap: 2px;
  }

  .file-upload-form,
  .file-card,
  .file-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .login-panel,
  .dialog-form {
    padding: 18px;
  }

  .panel-header {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .login-view {
    padding: 14px;
  }

  .stats-grid,
  .topbar-actions,
  .filters,
  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters label:first-child,
  .filters button,
  .role-badge {
    grid-column: 1 / -1;
  }

  .topbar-actions .primary-button,
  .topbar-actions .secondary-button,
  .topbar-actions .ghost-button {
    width: auto;
  }

  .dialog-actions {
    flex-direction: column;
  }

  .user-edit-grid,
  .user-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .detail-edit-form .dialog-actions {
    flex-direction: row;
  }
}
