:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #f59e0b;
  --danger: #dc2626;
  --success: #16a34a;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 0.75rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100%;
  overflow-x: hidden;
}

[dir="rtl"] { direction: rtl; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 1.1rem; margin: 0; font-weight: 700; }
header .actions { display: flex; gap: 0.5rem; align-items: center; }

.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-block { width: 100%; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card-title { font-size: 1rem; font-weight: 700; margin: 0 0 0.25rem; }
.card-subtitle { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.75rem; }

.list { list-style: none; padding: 0; margin: 0; }
.list-item {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.list-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.list-item:last-child { border-bottom: none; border-radius: 0 0 var(--radius) var(--radius); }

.form-group { margin-bottom: 1rem; }
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
}
input, textarea, select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
textarea { min-height: 5rem; resize: vertical; }
.help-text { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }

.chip {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.chip-assigned { background: #dbeafe; color: #1e40af; }
.chip-completed { background: #dcfce7; color: #166534; }
.chip-pending { background: #fef3c7; color: #92400e; }
.chip-synced { background: #dcfce7; color: #166534; }
.chip-unsynced { background: #fee2e2; color: #991b1b; }

#offline-banner {
  background: var(--danger);
  color: #fff;
  text-align: center;
  padding: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
}
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.p-1 { padding: 0.75rem; }
.full { flex: 1; }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }

.spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.preview-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 100;
  font-size: 0.9rem;
  max-width: 90%;
  text-align: center;
}
