:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #d8deea;
  --text: #182230;
  --muted: #667085;
  --accent: #1d4ed8;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Noto Sans Hebrew", "Heebo", sans-serif;
}

body { min-height: 100vh; }
button, input, select, a { font: inherit; }

a { text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 247, 251, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(216, 222, 234, 0.9);
}

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

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

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

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card, .filters-card, .table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.stat-card { padding: 18px; }
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 800; line-height: 1; }

.filters-card { padding: 16px; margin-bottom: 16px; }
.filters-row {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 180px 180px;
  gap: 12px;
  align-items: end;
}

.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 700; }
.field input, .field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.filters-meta {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.table-card { overflow: hidden; }
.table-wrap { overflow: auto; }
.drafts-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

.drafts-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  z-index: 1;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.drafts-table tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(216, 222, 234, 0.7);
  vertical-align: middle;
}

.drafts-table tbody tr:hover { background: rgba(29, 78, 216, 0.03); }
.client-cell { font-weight: 700; }
.fid-cell {
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}
.badge-draft {
  background: rgba(180, 83, 9, 0.10);
  color: var(--warning);
  border-color: rgba(180, 83, 9, 0.18);
}
.badge-final {
  background: rgba(21, 128, 61, 0.10);
  color: var(--success);
  border-color: rgba(21, 128, 61, 0.18);
}
.badge-danger {
  background: rgba(220, 38, 38, 0.10);
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.20);
}
.muted { color: #94a3b8; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  background: rgba(255,255,255,0.96);
  color: #111827;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.btn:disabled { opacity: .7; cursor: default; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: #2563eb; color: #fff; }
.btn-secondary { background: #0f766e; color: #fff; }
.btn-light { background: #fff; color: #111827; box-shadow: none; }

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px !important;
}

.toast {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 40px));
  background: rgba(17, 24, 39, 0.96);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  white-space: pre-wrap;
  word-break: break-word;
}
.toast.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.toast.error { background: rgba(180, 35, 24, 0.96); }

@media (max-width: 1000px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-row, .filters-meta { grid-template-columns: 1fr; }
  .topbar-inner { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page { padding: 12px; }
  h1 { font-size: 23px; }
}

.btn-danger {
  background: #b42318;
  color: #fff;
}

.drafts-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
}
