/* ==== Premium Design System — AppFactory ==== */
/* Elevates all 20 apps to "full team of devs" quality.
   Import AFTER design.css. Sets --accent per app in css/app.css. */
:root {
  --brand: var(--accent, #2563eb);
  --brand-soft: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
  --brand-strong: color-mix(in srgb, var(--accent, #2563eb) 85%, #000);
  --ink: #0f172a;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --border: #e2e8f0;
  --ok: #15803d; --warn: #b45309; --danger: #dc2626;
  --radius: 14px; --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 4px 6px -1px rgba(15,23,42,.08), 0 2px 4px -1px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 15px -3px rgba(15,23,42,.10);
  --space: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", sans-serif;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f8fafc; --surface: #0f172a; --surface-2: #1e293b; --surface-3: #334155;
    --text: #f8fafc; --text-2: #cbd5e1; --muted: #64748b;
    --border: #334155;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 4px 6px -1px rgba(0,0,0,.5);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.55 var(--font); color: var(--text); background: var(--surface-2);
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}
h1,h2,h3 { color: var(--ink); line-height: 1.2; margin: 0 0 12px; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
p { margin: 0 0 10px; color: var(--text-2); }
a { color: var(--brand); text-decoration: none; font-weight: 600; }
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin: 0 0 6px; letter-spacing: 0.01em; text-transform: uppercase; }
input, textarea, select {
  width: 100%; min-height: 50px; padding: 0 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
textarea { min-height: 120px; resize: vertical; }
button {
  border: none; border-radius: var(--radius); font: inherit; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: all var(--transition); min-height: 50px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 20px; min-height: 50px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 700; font-size: 15px; cursor: pointer;
  transition: all var(--transition); width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #ffffff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn:disabled { opacity: 0.55; pointer-events: none; }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
}
.appbar .brand-row { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.appbar .brand-mark { width: 30px; height: 30px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; font-size: 13px; }
.appbar .brand-text { font-size: 16px; font-weight: 800; color: var(--ink); flex: 1; min-width: 0; }
.appbar .brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 18px; box-shadow: var(--shadow-sm); margin-bottom: 14px;
}

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; height: calc(72px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar button {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: 44px; color: var(--muted); font-size: 11.5px; font-weight: 700; padding-top: env(safe-area-inset-top, 0);
}
.tabbar button[aria-selected="true"] { color: var(--brand); }
.tabbar svg { width: 22px; height: 22px; }

/* List items */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 56px; border-bottom: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .lead { font-weight: 700; color: var(--ink); font-size: 15px; }
.list-item .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Chips & status */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; background: var(--surface-3); font-size: 11.5px; font-weight: 700; color: var(--text-2);
}
.chip-accent { background: var(--brand-soft); color: var(--brand-strong); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }

/* Buttons row */
.row { display: flex; align-items: center; gap: 10px; }
.row.gap-2 { gap: 8px; }
.grow { flex: 1; min-width: 0; }

/* Feedback */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(72px + 18px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--surface); padding: 8px 16px;
  border-radius: 999px; font-size: 13px; font-weight: 700; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 180ms ease;
}
.toast.show { opacity: 1; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty-state .headline { font-weight: 700; color: var(--text-2); font-size: 16px; margin-bottom: 4px; }

/* Skeleton & loading */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px;
  min-height: 16px; width: 100%;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner {
  width: 18px; height: 18px; border: 2.5px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Section headings */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 0 12px; }
.section-head h3 { margin: 0; font-size: 16px; }
.section-head .note { font-size: 12px; color: var(--muted); font-weight: 600; }

/* RTL */
[dir="rtl"] .appbar .brand-row { flex-direction: row-reverse; }

/* Utility */
.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mt-6{margin-top:24px}
.text-muted{color:var(--muted)}.text-small{font-size:13px}
.view{display:none}.view.active{display:block}
.card h3{margin-top:0}
