/* ═══════════════════════════════════════════════════════════════════════════
   Peedikas — Design System
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Palette */
  --ink:        #1a1a2e;
  --ink-soft:   #3d3d56;
  --muted:      #6b7280;
  --muted-soft: #9ca3af;
  --line:       #e4e4e7;
  --line-soft:  #f1f1f3;
  --surface:    #ffffff;
  --page:       #fafaf9;
  --page-alt:   #f4f4f5;

  --accent:      #0f766e;
  --accent-dark: #0b5f59;
  --accent-soft: #f0fdfa;
  --accent-line: #99e6d8;

  --success:     #059669;
  --success-soft:#ecfdf5;
  --warn:        #d97706;
  --warn-soft:   #fffbeb;
  --danger:      #dc2626;
  --danger-soft: #fef2f2;
  --info:        #2563eb;
  --info-soft:   #eff6ff;

  --wa:          #25d366;

  /* Shadows */
  --sh-sm: 0 1px 2px rgba(26,26,46,0.04);
  --sh:    0 1px 3px rgba(26,26,46,0.06), 0 1px 2px rgba(26,26,46,0.04);
  --sh-md: 0 4px 12px rgba(26,26,46,0.08);
  --sh-lg: 0 12px 32px rgba(26,26,46,0.10);
  --sh-xl: 0 24px 56px rgba(26,26,46,0.14);

  /* Radii */
  --r-sm: 6px;
  --r:    8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Spacing scale (8px grid) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  --s12: 48px; --s16: 64px;

  color-scheme: light;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
               BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Typography ────────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 650; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 620; line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 0.82rem; font-weight: 600; text-transform: uppercase;
     letter-spacing: 0.05em; color: var(--muted); }

.text-sm  { font-size: 0.875rem; }
.text-xs  { font-size: 0.78rem; }
.text-muted { color: var(--muted); }
.tabular  { font-variant-numeric: tabular-nums; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  height: 40px; padding: 0 var(--s4);
  border: 1px solid transparent; border-radius: var(--r);
  font-size: 0.9rem; font-weight: 560;
  cursor: pointer; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease,
              color .14s ease, box-shadow .14s ease, transform .06s ease;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: var(--sh-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }

.btn-ghost {
  background: var(--surface); color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--page-alt); border-color: var(--muted-soft); }

.btn-danger {
  background: var(--surface); color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover:not(:disabled) { background: #1fb855; }

.btn-sm  { height: 32px; padding: 0 var(--s3); font-size: 0.82rem; }
.btn-lg  { height: 46px; padding: 0 var(--s6); font-size: 0.95rem; }
.btn-block { width: 100%; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { display: grid; gap: var(--s2); }

.label {
  font-size: 0.82rem; font-weight: 560; color: var(--ink-soft);
}
.label .req { color: var(--danger); }

.input, .select, .textarea {
  width: 100%; height: 42px;
  padding: 0 var(--s3);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.textarea { height: auto; min-height: 88px; padding: var(--s3); resize: vertical; line-height: 1.55; }

.input:hover, .select:hover, .textarea:hover { border-color: var(--muted-soft); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.12);
}
.input:disabled, .input[readonly] {
  background: var(--page-alt); color: var(--muted); cursor: default;
}
.input.error { border-color: var(--danger); }

.field-error { font-size: 0.78rem; color: var(--danger); }
.field-hint  { font-size: 0.78rem; color: var(--muted); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s3) center;
  padding-right: var(--s8);
}

/* Checkbox / toggle */
.checkbox-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3); border: 1px solid var(--line);
  border-radius: var(--r); background: var(--surface);
  cursor: pointer; transition: border-color .14s ease, background .14s ease;
}
.checkbox-row:hover { border-color: var(--muted-soft); background: var(--page-alt); }
.checkbox-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer;
}
.checkbox-row.checked { border-color: var(--accent); background: var(--accent-soft); }

/* ── Cards / panels ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh);
}
.card-pad { padding: var(--s5); }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s4); padding: var(--s5); border-bottom: 1px solid var(--line-soft);
}
.card-head-title { font-size: 1rem; font-weight: 620; }
.card-head-sub   { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.card-body { padding: var(--s5); }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface);
  padding: var(--s3) var(--s3);
  font-size: 0.72rem; font-weight: 620; text-transform: uppercase;
  letter-spacing: 0.045em; color: var(--muted);
  text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--line);
}
.table td {
  padding: var(--s3);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.875rem; vertical-align: middle;
}
.table tbody tr { transition: background .1s ease; }
.table tbody tr:hover { background: var(--page-alt); }
.table tbody tr:last-child td { border-bottom: none; }

.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { color: var(--accent); }
.sort-icon { font-size: 0.65rem; opacity: 0.45; margin-left: 2px; }
.th-sortable.active .sort-icon { opacity: 1; color: var(--accent); }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 580; white-space: nowrap;
}
.badge-accent  { background: var(--accent-soft); color: var(--accent-dark); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn    { background: var(--warn-soft); color: var(--warn); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-info    { background: var(--info-soft); color: var(--info); }
.badge-muted   { background: var(--page-alt); color: var(--muted); }

/* ── Toast notifications ───────────────────────────────────────────────── */
#toast-stack {
  position: fixed; top: var(--s5); right: var(--s5);
  display: grid; gap: var(--s2); z-index: 9999;
  max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--line); border-left-width: 3px;
  border-radius: var(--r); box-shadow: var(--sh-lg);
  font-size: 0.875rem;
  animation: toastIn .22s cubic-bezier(.16,1,.3,1);
}
.toast.out { animation: toastOut .18s ease forwards; }
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warn    { border-left-color: var(--warn); }
.toast-info    { border-left-color: var(--info); }
.toast-icon    { flex-shrink: 0; font-size: 1rem; line-height: 1.4; }
.toast-body    { flex: 1; }
.toast-title   { font-weight: 600; }
.toast-msg     { color: var(--muted); font-size: 0.82rem; margin-top: 1px; }

@keyframes toastIn  { from { opacity:0; transform: translateX(20px) } to { opacity:1; transform:none } }
@keyframes toastOut { to { opacity:0; transform: translateX(20px) } }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(26,26,46,0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s5);
  animation: fadeIn .15s ease;
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xl);
  width: min(560px, 100%);
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn .2s cubic-bezier(.16,1,.3,1);
}
.modal-lg { width: min(760px, 100%); }
.modal-head {
  padding: var(--s5); border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4);
}
.modal-title { font-size: 1.05rem; font-weight: 620; }
.modal-sub   { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.modal-body  { padding: var(--s5); overflow-y: auto; display: grid; gap: var(--s4); }
.modal-foot  {
  padding: var(--s4) var(--s5); border-top: 1px solid var(--line-soft);
  display: flex; gap: var(--s3); justify-content: flex-end;
  background: var(--page);
}
.modal-x {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1.3rem; line-height: 1;
  padding: 2px 6px; border-radius: var(--r-sm);
}
.modal-x:hover { background: var(--page-alt); color: var(--ink); }

@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes modalIn { from { opacity:0; transform: translateY(8px) scale(.99) } to { opacity:1; transform:none } }

/* ── Empty states ──────────────────────────────────────────────────────── */
.empty {
  padding: var(--s10) var(--s5); text-align: center;
  color: var(--muted);
}
.empty-icon  { font-size: 2rem; opacity: 0.35; margin-bottom: var(--s3); }
.empty-title { font-weight: 560; color: var(--ink-soft); margin-bottom: var(--s1); }
.empty-msg   { font-size: 0.875rem; }

/* ── Loading ───────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--page-alt) 25%, var(--line-soft) 50%, var(--page-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0 } }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Utilities ─────────────────────────────────────────────────────────── */
.hidden       { display: none !important; }
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--s1); } .gap-2 { gap: var(--s2); }
.gap-3 { gap: var(--s3); } .gap-4 { gap: var(--s4); }
.grid  { display: grid; }
.w-full { width: 100%; }
.mt-2 { margin-top: var(--s2); } .mt-4 { margin-top: var(--s4); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-danger  { color: var(--danger); }
.text-warn    { color: var(--warn); }
.text-success { color: var(--success); }
.text-accent  { color: var(--accent); }
.font-semi { font-weight: 600; }
