:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-2: #eef6ff;
  --text: #172033;
  --muted: #697386;
  --border: #dce6f1;
  --primary: #2f80ed;
  --primary-2: #12a594;
  --amber: #f59e0b;
  --red: #ef5350;
  --shadow: 0 18px 45px rgba(30, 60, 90, 0.10);
  --radius: 8px;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  direction: rtl;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
}

body.dark {
  --bg: #111827;
  --surface: #1f2937;
  --surface-2: #223044;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --border: #334155;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
}

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

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-shell {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  direction: ltr;
}

.sidebar {
  direction: rtl;
  background: rgba(255, 255, 255, 0.82);
  border-left: 1px solid var(--border);
  padding: 22px 16px;
  backdrop-filter: blur(18px);
}

body.dark .sidebar {
  direction: rtl;
  background: rgba(31, 41, 55, 0.86);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  font-size: 22px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 24px rgba(47, 128, 237, 0.28);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  margin-bottom: 8px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  text-align: right;
}

.nav-item.active,
.nav-item:hover {
  color: var(--primary);
  background: var(--surface-2);
}

.main {
  direction: rtl;
  min-width: 0;
  padding: 22px 26px 32px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 72px;
  gap: 18px;
  margin-bottom: 16px;
}

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

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

#page-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.toolbar-actions,
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.primary,
.ghost,
.row-actions button,
.settings-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 12px 22px rgba(47, 128, 237, 0.22);
}

.ghost {
  min-height: 40px;
  padding: 0 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  outline: none;
}

textarea {
  min-height: 86px;
  padding-top: 10px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.12);
}

.table-panel {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: rgba(238, 246, 255, 0.72);
  font-weight: 650;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

tbody tr:hover {
  background: rgba(47, 128, 237, 0.04);
}

tbody tr.cat-row {
  background: color-mix(in srgb, var(--cat-color) 7%, transparent);
}

tbody tr.cat-row:hover {
  background: color-mix(in srgb, var(--cat-color) 13%, transparent);
}

tbody tr.cat-row td:first-child {
  border-inline-start: 3px solid var(--cat-color);
}

.quick-add-row td {
  padding: 8px 12px;
  background: var(--surface-2);
}

.quick-add {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-add-plus {
  display: inline-grid;
  place-items: center;
  color: var(--primary);
}

#quick-add-input {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
}

#quick-add-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.quick-add-button {
  min-height: 34px;
  padding: 0 14px;
  box-shadow: none;
  flex-shrink: 0;
}

.due-cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.due-quick-chips {
  display: none;
  gap: 4px;
  flex-shrink: 0;
}

.due-cell:focus-within .due-quick-chips {
  display: flex;
}

.modal-due-chips {
  display: flex;
  margin-top: 2px;
}

.due-chip {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.due-chip:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.due-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.due-overdue {
  color: #b91c1c;
  background: #fee2e2;
}

.due-today {
  color: #b45309;
  background: #fef3c7;
}

.due-tomorrow {
  color: #2563eb;
  background: #dbeafe;
}

tr.row-pending-complete td {
  opacity: 0.55;
}

tr.row-pending-complete .quick-task-name {
  text-decoration: line-through;
}

/* --- Read-mode cells (3.1) --- */

.read-cell {
  cursor: pointer;
}

.read-cell:hover,
.read-cell:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.cell-primary {
  font-weight: 600;
}

.cell-muted {
  color: var(--muted);
}

.cell-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-inline-end: 7px;
  border-radius: 50%;
  background: var(--dot);
  vertical-align: middle;
}

.select-col {
  width: 36px;
  text-align: center;
}

.select-col input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

/* --- Saved views (4.2) --- */

.saved-views {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.view-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.view-chip-add {
  padding: 0 12px;
  color: var(--primary);
  border-style: dashed;
}

.view-chip-remove {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
}

.view-chip-remove:hover {
  color: var(--red);
  background: var(--surface-2);
}

.view-chip-remove svg {
  width: 12px;
  height: 12px;
}

/* --- Bulk actions (2.6) --- */

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-actions select {
  min-height: 36px;
  min-width: 160px;
}

.bulk-actions .ghost {
  min-height: 36px;
  padding: 0 12px;
}

/* --- Group by category (3.4) --- */

.group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.group-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

tr.group-header-row td {
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.group-count {
  margin-inline-start: 8px;
  color: var(--muted);
  font-weight: 600;
}

/* --- Empty states (3.3) --- */

.empty-state {
  height: auto;
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state p {
  margin-bottom: 12px;
}

.empty-emoji {
  font-size: 16px;
}

/* --- Quick-add smart parsing preview (2.3) --- */

.quick-add-preview {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.parse-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

/* --- Dashboard flexibility (4.7) --- */

.dashboard-options-ordered {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.dashboard-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.dashboard-option-size {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.dashboard-option-size input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.dashboard-grid-full {
  grid-column: 1 / -1;
}

/* --- Settings: display + sidebar (4.4, 4.5) --- */

.display-option {
  display: grid;
  gap: 7px;
}

.settings-hint {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.check-inline {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.check-inline input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* --- Density + font size (4.4) --- */

body[data-density="compact"] th,
body[data-density="compact"] td {
  padding: 8px 10px;
}

body[data-density="spacious"] th,
body[data-density="spacious"] td {
  padding: 20px 16px;
}

body[data-font-size="large"] {
  font-size: 17px;
}

body[data-font-size="large"] table {
  font-size: 15px;
}

/* --- Micro-animations (3.5) --- */

@keyframes fadeInRow {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

tbody tr {
  animation: fadeInRow 160ms ease;
}

.item-card,
.row-actions button,
.primary,
.ghost,
.due-chip,
.view-chip,
.nav-item {
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Mobile FAB + bottom sheet (2.2) --- */

.fab {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 5;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 14px 28px rgba(47, 128, 237, 0.35);
}

.fab svg {
  width: 26px;
  height: 26px;
}

.sheet-backdrop {
  align-items: flex-end;
  padding: 0;
}

.bottom-sheet {
  width: 100%;
  max-height: 80vh;
  padding: 12px 18px 22px;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  box-shadow: 0 -18px 45px rgba(15, 23, 42, 0.28);
  animation: slideUpSheet 180ms ease;
}

@keyframes slideUpSheet {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: var(--border);
}

.sheet-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.sheet-save {
  width: 100%;
  justify-content: center;
  min-height: 46px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast-action {
  flex-shrink: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #7dd3fc;
  font-weight: 700;
  text-decoration: underline;
}

.shortcuts-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shortcuts-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}

.shortcuts-list kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
}

.column-picker {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

.column-picker-list {
  display: grid;
  gap: 6px;
}

.column-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px;
  border-radius: var(--radius);
}

.column-picker-row:hover {
  background: var(--surface-2);
}

.order-buttons {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-mini {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
}

.icon-mini:hover:not(:disabled) {
  color: var(--primary);
  border-color: var(--primary);
}

.icon-mini:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-mini svg {
  width: 14px;
  height: 14px;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 0;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.check-option:hover {
  background: var(--surface-2);
}

.check-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

.quick-input,
.quick-select {
  min-width: 132px;
  min-height: 36px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
}

.quick-task-name {
  min-width: 190px;
}

.quick-date {
  min-width: 142px;
}

.quick-input:hover,
.quick-select:hover,
.quick-input:focus,
.quick-select:focus {
  border-color: var(--border);
  background: var(--surface);
}

.quick-input:focus,
.quick-select:focus {
  border-color: var(--primary);
}

.link-title {
  border: 0;
  padding: 0;
  color: var(--text);
  background: transparent;
  font-weight: 650;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.status-open,
.priority-medium {
  color: #2563eb;
  background: #dbeafe;
}

.status-in_progress,
.priority-high {
  color: #b45309;
  background: #fef3c7;
}

.status-completed,
.priority-low {
  color: #047857;
  background: #d1fae5;
}

.status-blocked,
.priority-urgent {
  color: #b91c1c;
  background: #fee2e2;
}

.project-dot,
.color-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--dot);
}

.row-actions button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
}

.row-actions button:hover {
  color: var(--primary);
  background: var(--surface-2);
}

.dashboard-preferences {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 14px;
  padding: 18px;
}

.dashboard-preferences h2 {
  margin-bottom: 6px;
}

.dashboard-preferences p {
  color: var(--muted);
  line-height: 1.5;
}

.dashboard-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.dashboard-option {
  display: flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.dashboard-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.empty-panel {
  padding: 22px;
  color: var(--muted);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.stat {
  min-height: 120px;
  padding: 18px;
  border-radius: var(--radius);
  color: #fff;
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  opacity: 0.9;
  margin-bottom: 18px;
}

.stat strong {
  font-size: 34px;
}

.stat.blue { background: linear-gradient(135deg, #2f80ed, #56ccf2); }
.stat.green { background: linear-gradient(135deg, #11998e, #38ef7d); }
.stat.red { background: linear-gradient(135deg, #ef5350, #ff8a65); }
.stat.amber { background: linear-gradient(135deg, #f59e0b, #fbbf24); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-grid .panel {
  padding: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 30px;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.bar-row div {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

.activity {
  display: grid;
  gap: 12px;
}

.activity div {
  display: grid;
  gap: 4px;
}

.activity span {
  color: var(--muted);
  font-size: 13px;
}

.customer-card {
  gap: 10px;
}

.customer-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.customer-card-head h3 {
  margin: 0;
}

.stage-badge {
  flex-shrink: 0;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
}

.customer-card strong {
  font-size: 20px;
}
.cards-list,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.item-card,
.settings-card {
  min-height: 168px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.item-card {
  display: grid;
  gap: 10px;
}

.item-card p,
.item-card small {
  color: var(--muted);
  line-height: 1.55;
}

.settings-card {
  text-align: right;
  font-size: 17px;
  font-weight: 650;
}

.settings-card:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.36);
  z-index: 10;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 20px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
}

.modal-head,
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-head {
  margin-bottom: 18px;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.modal-head-actions .primary {
  min-height: 36px;
  white-space: nowrap;
}

.modal-head [data-close] {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 22px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

.modal-actions {
  justify-content: flex-start;
  margin-top: 18px;
}

.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  transform: translateY(16px);
  opacity: 0;
  padding: 13px 16px;
  border-radius: var(--radius);
  color: #fff;
  background: #172033;
  box-shadow: var(--shadow);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  height: 160px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .brand strong,
  .nav-item span {
    display: none;
  }

  .brand,
  .nav-item {
    justify-content: center;
  }

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

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
  direction: rtl;
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    border-left: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar nav {
    display: flex;
    gap: 8px;
  }

  .main {
  direction: rtl;
    padding: 18px 14px 28px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters,
  .stats-grid,
  .dashboard-grid,
  .dashboard-preferences,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .table-panel {
    overflow-x: visible;
  }

  .fab {
    display: flex;
  }

  .quick-add-row,
  .quick-add-preview {
    display: none;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
    width: 100%;
  }

  .table-panel thead {
    display: none;
  }

  .table-panel tbody tr:not(.group-header-row) {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .table-panel tbody tr.cat-row {
    border-inline-start: 3px solid var(--cat-color);
  }

  .table-panel tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 2px;
    border-bottom: 0;
  }

  .table-panel tbody td[data-label]::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
  }

  .table-panel tbody td.select-col {
    justify-content: flex-start;
    padding-bottom: 2px;
  }

  .table-panel tbody td.select-col::before {
    content: none;
  }

  .row-actions {
    justify-content: flex-end;
    width: 100%;
  }

  .saved-views {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}


.login-screen {
  min-height: 100vh;
  width: 100vw;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  grid-column: 1 / -1;
}


.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card p,
.login-card small {
  color: var(--muted);
  line-height: 1.55;
}

.login-brand {
  margin-bottom: 4px;
}

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.text-button {
  border: 0;
  padding: 0;
  color: var(--primary);
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
}
.icon-command {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}

.icon-command:hover {
  color: var(--primary);
  background: var(--surface-2);
}


.settings-section {
  display: grid;
  gap: 14px;
  padding: 18px;
  margin-top: 14px;
}

.integration-intro {
  display: grid;
  gap: 16px;
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.integration-intro h2 { margin: 6px 0; font-size: 1.45rem; }
.integration-intro p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--primary); font-size: .82rem; font-weight: 700; }
.integration-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); }
.integration-flow span { padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--background); }
.integration-flow b { color: var(--primary); }
.integration-help { margin-bottom: 16px; }
.integration-help-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.help-tab { padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface); cursor: pointer; }
.help-tab:hover { border-color: var(--primary); color: var(--primary); }
.help-tab.active { border-color: var(--primary); color: #fff; background: var(--primary); }
.help-panel { max-width: 900px; }
.help-panel h3 { margin: 0 0 8px; }
.help-panel p { color: var(--muted); line-height: 1.6; }
.help-panel ol { display: grid; gap: 8px; margin: 12px 0; padding-inline-start: 22px; line-height: 1.55; }
.help-tip { padding: 12px 14px; border-inline-start: 4px solid var(--primary); border-radius: 6px; color: var(--muted); background: var(--background); line-height: 1.55; }
.integration-provider-actions { display: flex; justify-content: flex-start; margin-bottom: 12px; }

.automation-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.automation-list { display: grid; gap: 8px; }
.automation-row, .automation-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.automation-row strong { display: block; }
.automation-row span { color: var(--muted); font-size: .85rem; }
.automation-row-actions { display: flex; align-items: center; gap: 8px; }
.automation-logs { margin-top: 20px; }
.automation-logs h3 { margin: 0 0 10px; }
.automation-log-row { justify-content: flex-start; font-size: .9rem; }
.automation-log-row small { color: var(--muted); margin-inline-start: auto; }
.automation-status.success { color: #047857; }
.automation-status.failed { color: #b91c1c; }

@media (max-width: 900px) {
  .automation-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .automation-form { grid-template-columns: 1fr; }
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-list {
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.compact-card {
  min-height: 132px;
}
