:root {
  --ink: #1B2430;
  --ink-soft: #4A5568;
  --paper: #EEF1F5;
  --panel: #FFFFFF;
  --line: #D8DEE6;
  --accent: #2F6F6B;
  --accent-soft: #DCEBE9;
  --gold: #C98A2C;
  --gold-soft: #F5E7D0;
  --danger: #B4432E;
  --danger-soft: #F7E3DF;
  --radius: 10px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Vazirmatn', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 16px 70px;
}
@media (min-width: 640px) {
  .page { padding: 40px 20px 80px; }
}

/* ---------- ورود ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}
.login-card h1 {
  margin: 6px 0 4px;
  font-size: 24px;
}
.login-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 18px;
}
.login-card .field { text-align: right; }

/* ---------- هدر ---------- */
.page-head { margin-bottom: 22px; }
.page-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.page-head-mark {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 20px;
}
.logout-link {
  font-size: 13.5px;
  color: var(--ink-soft);
  text-decoration: none;
}
.logout-link:hover { color: var(--danger); }
.page-head h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
@media (min-width: 640px) {
  .page-head h1 { font-size: 32px; }
}
.page-head-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14.5px;
  max-width: 60ch;
}

/* ---------- تب‌های پروژه ---------- */
.project-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 22px;
  -webkit-overflow-scrolling: touch;
}
.project-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.project-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.project-tab-new {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}
.project-tab-new input {
  font-family: var(--sans);
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 20px;
  border: 1px dashed var(--line);
  background: transparent;
  width: 190px;
  max-width: 42vw;
}
.project-tab-new button {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

.empty-state {
  color: var(--ink-soft);
  font-size: 15px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.page-flash {
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 0 0 18px;
}
.page-flash.ok { background: var(--accent-soft); color: var(--accent); }
.page-flash.error { background: var(--danger-soft); color: var(--danger); }

/* ---------- لینک آخرین نسخه ---------- */
.latest-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 24px;
}
.latest-strip-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.latest-strip-label {
  font-size: 12.5px;
  color: #B9C2CE;
}
.latest-strip-text code {
  font-family: var(--mono);
  font-size: 13px;
  background: rgba(255,255,255,0.08);
  padding: 5px 10px;
  border-radius: 6px;
  word-break: break-all;
}
.latest-strip-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- چیدمان ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 760px) {
  .layout { grid-template-columns: 1fr 1.2fr; align-items: start; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
@media (min-width: 640px) {
  .panel { padding: 24px; }
}
.panel h2 {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 600;
}

/* ---------- فرم ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="date"],
.field input[type="password"],
.field textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 16px; /* جلوگیری از زوم خودکار سافاری روی موبایل */
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #FBFCFD;
  color: var(--ink);
  resize: vertical;
}
.field input[type="file"] {
  display: block;
  font-family: var(--sans);
  font-size: 14px;
  width: 100%;
  padding: 6px 0;
}
.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field-hint {
  display: block;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 6px;
  font-family: var(--mono);
  word-break: break-all;
}

/* ---------- تقویم شمسی ---------- */
.jalali-field {
  display: flex;
  gap: 8px;
}
.jalali-display {
  flex: 1;
  cursor: pointer;
}
.jalali-today-btn {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}
.jalali-calendar {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #FBFCFD;
}
.jcal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.jcal-title { font-size: 14.5px; font-weight: 600; }
.jcal-nav {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 16px;
  color: var(--ink-soft);
  cursor: pointer;
}
.jcal-nav:hover { background: var(--accent-soft); color: var(--accent); }
.jcal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.jcal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.jcal-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  min-height: 36px;
}
.jcal-day:hover { background: var(--accent-soft); }
.jcal-day.is-today { border: 1px solid var(--gold); }
.jcal-day.is-selected { background: var(--accent); color: #fff; }
.jcal-empty { cursor: default; }

.filter-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  background: #FBFCFD;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  min-height: 44px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover { opacity: 0.92; }
.btn-ghost {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  min-height: 40px;
  padding: 9px 16px;
  font-size: 13.5px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.18); }

.form-msg { margin: 12px 0 0; font-size: 13.5px; }
.form-msg.error { color: var(--danger); }

/* ---------- تاریخچه ---------- */
.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.history-head h2 { margin: 0; }
.history-count { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }

.history-list {
  position: relative;
  padding-inline-start: 16px;
  border-inline-start: 2px solid var(--line);
}
.history-empty {
  color: var(--ink-soft);
  font-size: 14px;
  border-inline-start: none;
  padding-inline-start: 0;
}

.entry { position: relative; padding: 2px 0 20px 4px; }
.entry::before {
  content: "";
  position: absolute;
  inset-inline-start: -21px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
  border: 2px solid var(--panel);
}
.entry.is-latest::before { background: var(--gold); }
.entry-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.entry-date { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }
.badge-latest {
  font-size: 11px;
  font-weight: 600;
  color: #8A5A16;
  background: var(--gold-soft);
  padding: 2px 8px;
  border-radius: 20px;
}
.entry-desc { font-size: 14.5px; margin: 4px 0 8px; word-break: break-word; }
.entry-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--mono);
  word-break: break-all;
}
.entry-actions { margin-top: 8px; display: flex; gap: 16px; flex-wrap: wrap; }
.entry-actions form { margin: 0; }
.entry-actions a,
.entry-actions button {
  font-size: 13.5px;
  font-family: var(--sans);
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  min-height: 30px;
}
.entry-actions .delete-link { color: var(--danger); }
