:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --line: #e2e6ee;
  --ink-1: #1c2433;
  --ink-2: #4a5568;
  --ink-3: #8892a3;
  --blue-500: #3a6ea5;
  --blue-600: #2f5c8a;
  --green-500: #279b60;
  --green-50: #e8f8ef;
  --red-500: #cc3338;
  --red-50: #fdecec;
  --amber-500: #d38a03;
  --amber-50: #fff6e5;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-sm: 0 2px 8px -2px rgba(20,30,50,.08);
  --shadow-md: 0 10px 30px -12px rgba(20,30,50,.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Vazirmatn", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink-1);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed; inset: -20% -10% auto -10%; height: 55vh; z-index: 0; pointer-events: none;
  background: radial-gradient(60% 60% at 30% 20%, rgba(58,110,165,.16), transparent 70%),
              radial-gradient(50% 50% at 80% 10%, rgba(39,155,96,.12), transparent 70%);
  filter: blur(10px);
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; backdrop-filter: blur(14px);
  background: rgba(255,255,255,.75); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-badge {
  width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: var(--shadow-sm);
}
.brand-title { font-weight: 800; font-size: 15px; line-height: 1.3; }
.brand-sub { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--blue-600); }
.icon-btn.spin svg { animation: spin .7s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

.wrap { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 18px 16px 60px; }

.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 560px) { .summary { grid-template-columns: repeat(4, 1fr); } }
.sum-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.sum-label { font-size: 11.5px; color: var(--ink-3); font-weight: 700; margin-bottom: 4px; }
.sum-value { font-size: 17px; font-weight: 800; color: var(--ink-1); }
.sum-value.good { color: var(--green-500); }
.sum-value.bad { color: var(--red-500); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-wrap {
  flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
  color: var(--ink-3);
}
.search-wrap input {
  border: none; outline: none; background: transparent; flex: 1; font-family: inherit; font-size: 13.5px; color: var(--ink-1);
}
.updated-at { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

.job-list { display: flex; flex-direction: column; gap: 12px; }
.loading, .empty { text-align: center; color: var(--ink-3); padding: 50px 10px; font-size: 13.5px; }

.job-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow-sm); transition: box-shadow .2s ease, transform .2s ease;
}
.job-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.job-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.job-id { font-size: 11px; color: var(--ink-3); font-weight: 700; }
.status-pill {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; color: #fff;
}
.status-pill.pending { background: linear-gradient(135deg, #ffb143, #d38a03); }
.status-pill.done { background: linear-gradient(135deg, #3fd08a, #259b60); }
.status-pill.canceled { background: linear-gradient(135deg, #f2696d, #cc3338); }

.job-client { font-size: 15.5px; font-weight: 800; color: var(--ink-1); margin-bottom: 2px; }
.job-project { font-size: 12.5px; color: var(--ink-3); font-weight: 600; margin-bottom: 10px; }

.job-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px;
  background: var(--surface-2); border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 10px;
}
.meta-row { display: flex; justify-content: space-between; font-size: 12px; gap: 6px; }
.meta-label { color: var(--ink-3); font-weight: 600; flex-shrink: 0; }
.meta-val { color: var(--ink-1); font-weight: 700; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.job-money { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; margin-bottom: 8px; }
.money-item {
  flex: 1; text-align: center; background: var(--surface-2); border-radius: 10px; padding: 8px 4px;
  display: flex; flex-direction: column; gap: 3px;
}
.money-item span { font-size: 10.5px; color: var(--ink-3); font-weight: 700; }
.money-item b { font-size: 12.5px; font-weight: 800; }
.money-item b.good { color: var(--green-500); }
.money-item b.bad { color: var(--red-500); }

.job-field { margin-top: 10px; }
.job-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.job-field-row .job-field { margin-top: 0; }
.job-field label {
  display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-3); margin-bottom: 5px;
}
.job-field .f-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
  color: var(--ink-1); font-family: inherit; font-size: 13px; padding: 8px 10px; outline: none;
  transition: border-color .15s ease, background .15s ease; box-sizing: border-box;
}
.job-field select.f-input { appearance: none; }
.job-field .f-input:focus { border-color: var(--blue-500); background: var(--surface); }
.job-field .f-textarea { resize: vertical; min-height: 40px; line-height: 1.6; }

.job-card-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px;
  padding-top: 10px; border-top: 1px dashed var(--line);
}
.save-status { font-size: 11px; color: var(--ink-3); font-weight: 600; flex: 1; min-width: 0; }
.save-status.saving { color: var(--blue-500); }
.save-status.saved { color: var(--green-500); }
.save-status.error { color: var(--red-500); }

.done-btn {
  display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, #3fd08a, #259b60); color: #fff; font-family: inherit;
  font-size: 12.5px; font-weight: 700; padding: 8px 16px; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 6px 16px -6px rgba(37,155,96,.55); transition: filter .15s ease, transform .12s ease;
}
.done-btn:hover { filter: brightness(1.06); }
.done-btn:active { transform: scale(.96); }
.done-btn.is-done {
  background: var(--surface-2); color: var(--green-500); box-shadow: none;
  border: 1.5px solid var(--green-500);
}
.done-btn:disabled { opacity: .65; cursor: not-allowed; }

.live-strip {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 8px;
  max-width: 760px; margin: 10px auto 0; padding: 8px 16px; font-size: 12px; font-weight: 700; color: var(--ink-3);
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.live-dot.online { background: var(--green-500); box-shadow: 0 0 0 3px var(--green-50); animation: pulse-dot 1.8s infinite; }
.live-dot.offline { background: var(--red-500); box-shadow: 0 0 0 3px var(--red-50); }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.config-btn {
  margin-inline-start: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  width: 26px; height: 26px; cursor: pointer; font-size: 13px; color: var(--ink-3);
}

.config-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(20,26,38,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.config-overlay.hidden { display: none; }
.config-box {
  background: var(--surface); border-radius: var(--radius-lg); padding: 20px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 8px;
}
.config-box h3 { margin: 0 0 2px; font-size: 15px; }
.config-box p { margin: 0 0 6px; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.config-box label { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-top: 4px; }
.config-box input {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-family: inherit; font-size: 13px;
  outline: none; background: var(--surface-2); color: var(--ink-1);
}
.config-actions { display: flex; gap: 8px; margin-top: 10px; }
.config-btn-ghost, .config-btn-primary {
  flex: 1; border: none; border-radius: 10px; padding: 10px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.config-btn-ghost { background: var(--surface-2); color: var(--ink-2); }
.config-btn-primary { background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); color: #fff; }
