/* ============================================================
   WorkerAI — Complete Stylesheet
   ============================================================ */

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

:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #e0e7ff;
  --secondary:     #0ea5e9;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #0ea5e9;
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --surface2:      #f1f5f9;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.05);
  --shadow:        0 4px 6px -1px rgba(0,0,0,.07),0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.08),0 4px 6px -4px rgba(0,0,0,.04);
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --sidebar-w:     252px;
  --header-h:      60px;
  --font:          'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; overflow-x: hidden; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

a { text-decoration: none; color: inherit; }
button { cursor: pointer; }
code { font-family: 'Menlo','Consolas',monospace; font-size: .82rem; }

/* ── Layout shell ─────────────────────────────────────────── */
#app-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; flex-direction: column; gap: 16px;
  background: var(--bg);
}
.logo-mark {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #0ea5e9);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.5rem; font-weight: 800; flex-shrink: 0;
}

/* auth screen */
#auth-screen {
  display: none; min-height: 100vh;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.auth-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 40px 36px; width: 100%; max-width: 460px;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand { font-size: 1.25rem; font-weight: 800; color: var(--text); }
.auth-tagline { font-size: .75rem; color: var(--text-muted); }
.auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { font-size: .875rem; color: var(--text-muted); margin-bottom: 24px; }
.auth-form { margin-top: 8px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--text-light); font-size: .8rem; }
.auth-divider::before, .auth-divider::after { content:''; flex:1; height:1px; background: var(--border); }
.auth-switch { font-size: .875rem; color: var(--text-muted); text-align: center; margin-top: 16px; }
.auth-switch a { color: var(--primary); font-weight: 600; }
.auth-legal { font-size: .72rem; color: var(--text-light); text-align: center; margin-top: 16px; line-height: 1.4; }
.auth-error { background: #fee2e2; color: #991b1b; border-radius: var(--radius-sm); padding: 10px 12px; font-size: .82rem; margin-bottom: 12px; }
.auth-demo { text-align: center; margin-top: 12px; }

/* app shell */
#app-shell { display: none; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 199; }
.sidebar-overlay.open { display: block; }

.sidebar {
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200; overflow-y: auto;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  flex-shrink: 0;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-logo .logo-mark { width: 34px; height: 34px; font-size: 1rem; border-radius: 10px; }
.sidebar-brand-text { display: flex; flex-direction: column; }
.sidebar-brand { font-weight: 800; font-size: .95rem; line-height: 1.2; }
.sidebar-plan { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; width: fit-content; }
.plan-starter      { background: #e0e7ff; color: #4f46e5; }
.plan-professional { background: #fef3c7; color: #b45309; }
.plan-enterprise   { background: #d1fae5; color: #065f46; }
.sidebar-close-btn { display: none; background: none; border: none; color: var(--text-muted); font-size: 1rem; padding: 4px; border-radius: 6px; }
.sidebar-close-btn:hover { background: var(--surface2); }

.workspace-info { padding: 10px 16px 8px; border-bottom: 1px solid var(--border); }
.ws-name { font-weight: 600; font-size: .875rem; }
.ws-meta { font-size: .72rem; color: var(--text-muted); margin-top: 1px; }

.sidebar-nav { padding: 10px 10px; flex: 1; }
.nav-section-label { font-size: .63rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-light); padding: 8px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: .84rem; font-weight: 500; color: var(--text-muted);
  transition: all .13s; position: relative; cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.nav-item i { width: 16px; text-align: center; font-size: .875rem; flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); margin-top: auto; }
.user-pill { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-sm); transition: background .13s; }
.user-pill:hover { background: var(--surface2); }
.user-pill-info { flex: 1; min-width: 0; }
.user-pill-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pill-role  { font-size: .7rem; color: var(--text-muted); text-transform: capitalize; }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.top-bar {
  height: var(--header-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; flex-shrink: 0; position: relative; z-index: 10;
}
.hamburger { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; color: var(--text-muted); font-size: .9rem; }
.hamburger:hover { background: var(--surface2); }
.top-bar-title { font-size: 1rem; font-weight: 700; flex: 1; }
.top-bar-actions { display: flex; align-items: center; gap: 6px; }

.page-content { flex: 1; overflow-y: auto; padding: 0; }
.page-inner { padding: 24px; max-width: 1400px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: .84rem; font-weight: 600; border: none;
  transition: all .13s; white-space: nowrap; font-family: var(--font);
}
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--surface2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm  { padding: 6px 12px; font-size: .78rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  background: transparent; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .875rem; transition: all .13s; flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-danger-icon:hover { background: #fee2e2; color: var(--danger); }
.notification-btn { position: relative; }
.notif-dot { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; background: var(--danger); border-radius: 50%; border: 2px solid var(--surface); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-hint { font-weight: 400; color: var(--text-muted); font-size: .75rem; }
.form-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .875rem; font-family: var(--font); color: var(--text);
  background: var(--surface); outline: none; transition: border-color .13s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
textarea.form-input { resize: vertical; min-height: 72px; }
.input-with-icon { position: relative; }
.input-with-icon .form-input { padding-right: 38px; }
.input-icon-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); font-size: .85rem; padding: 4px; }

/* ── Cards ────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: .9rem; font-weight: 700; }
.card-body { }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 99px; font-size: .71rem; font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #e0f2fe; color: #0c4a6e; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-outline { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-role-owner   { background: #ede9fe; color: #5b21b6; }
.badge-role-manager { background: #fef3c7; color: #92400e; }
.badge-role-member  { background: #e0f2fe; color: #0c4a6e; }
.badge-role-viewer  { background: var(--surface2); color: var(--text-muted); }

/* ── Avatars ──────────────────────────────────────────────── */
.avatar-sm {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .75rem;
}
.avatar-lg { width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg,#6366f1,#0ea5e9); display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:.9rem; }
.avatar-xl { width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg,#6366f1,#0ea5e9); display:flex;align-items:center;justify-content:center;color:#fff;font-weight:800;font-size:1rem; }

/* ── Status dots ──────────────────────────────────────────── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-online  { background: var(--success); box-shadow: 0 0 0 2px rgba(16,185,129,.2); }
.status-paused  { background: var(--warning); }
.status-offline { background: var(--text-light); }

/* ── Spinner ──────────────────────────────────────────────── */
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-sm { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-loading { display: flex; align-items: center; justify-content: center; padding: 60px; }

/* ── Toasts ───────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--primary); border-radius: var(--radius-sm);
  padding: 11px 14px; box-shadow: var(--shadow-lg); max-width: 320px;
  display: flex; align-items: flex-start; gap: 9px; font-size: .84rem;
  animation: toastIn .3s ease; pointer-events: all;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error   { border-left-color: var(--danger); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(3px); z-index: 500; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; max-width: 540px; width: 100%; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body { }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Page toolbar ─────────────────────────────────────────── */
.page-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-heading { font-size: 1.2rem; font-weight: 700; }
.page-subheading { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

/* ── Stats grid ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; align-items: flex-start; gap: 14px; box-shadow: var(--shadow-sm); }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.stat-body { }
.stat-value { font-size: 1.65rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 3px; }
.bg-primary-light { background: var(--primary-light); }
.bg-success-light { background: #d1fae5; }
.bg-warning-light { background: #fef3c7; }
.bg-info-light    { background: #e0f2fe; }

/* KPI cards */
.stats-grid-lg { grid-template-columns: repeat(4,1fr); }
.kpi-card { flex-direction: column; align-items: flex-start; gap: 4px; }
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--text); }
.kpi-label { font-size: .78rem; color: var(--text-muted); }
.kpi-trend { font-size: .75rem; display: flex; align-items: center; gap: 5px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.neutral { color: var(--text-muted); }

/* ── Two-col layout ──────────────────────────────────────── */
.two-col-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.right-panel { display: flex; flex-direction: column; gap: 14px; }

/* ── Feed ─────────────────────────────────────────────────── */
.feed-list { display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.feed-item { display: flex; align-items: flex-start; gap: 11px; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .13s; }
.feed-item:hover { border-color: var(--primary); }
.feed-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: .85rem; flex-shrink: 0; }
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: .82rem; font-weight: 600; }
.feed-time  { font-size: .7rem; color: var(--text-light); margin-top: 2px; }
.live-dot { display: inline-block; width: 8px; height: 8px; background: var(--success); border-radius: 50%; animation: pulse 1.5s infinite; vertical-align: middle; margin-right: 2px; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.6;transform:scale(1.3)} }

/* ── Approval mini ───────────────────────────────────────── */
.approval-mini-list { display: flex; flex-direction: column; gap: 8px; }
.approval-mini-item { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.approval-mini-body { flex: 1; min-width: 0; }
.approval-mini-title { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.approval-mini-meta  { font-size: .72rem; color: var(--text-muted); margin-top: 1px; display: flex; align-items: center; gap: 5px; }
.approval-mini-actions { display: flex; gap: 4px; }
.btn-approve-sm { width: 26px; height: 26px; border-radius: 6px; border: none; background: #d1fae5; color: #065f46; font-size: .75rem; display: flex; align-items: center; justify-content: center; }
.btn-approve-sm:hover { background: #10b981; color: #fff; }
.btn-reject-sm  { width: 26px; height: 26px; border-radius: 6px; border: none; background: #fee2e2; color: #991b1b; font-size: .75rem; display: flex; align-items: center; justify-content: center; }
.btn-reject-sm:hover  { background: var(--danger); color: #fff; }

/* ── Worker status list ──────────────────────────────────── */
.worker-status-list { display: flex; flex-direction: column; gap: 8px; }
.worker-status-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); transition: background .13s; }
.worker-status-item:hover { background: var(--surface2); }
.worker-status-body { flex: 1; min-width: 0; }
.worker-status-name { font-size: .82rem; font-weight: 600; }
.worker-status-stat { font-size: .72rem; color: var(--text-muted); }
.worker-emoji { font-size: 1.1rem; flex-shrink: 0; }
.worker-emoji-lg { font-size: 2rem; }

/* ── Usage bar ────────────────────────────────────────────── */
.usage-bar-wrap { }
.usage-bar { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.usage-fill { height: 100%; border-radius: 99px; background: var(--primary); transition: width .5s ease; }
.usage-fill.usage-warning { background: var(--warning); }
.usage-fill.usage-danger  { background: var(--danger); }
.usage-meta { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text-muted); }

/* ── Workers grid ─────────────────────────────────────────── */
.workers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.worker-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); transition: box-shadow .15s; }
.worker-card:hover { box-shadow: var(--shadow); }
.worker-paused { opacity: .7; }
.worker-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.worker-card-status  { display: flex; align-items: center; gap: 5px; font-size: .72rem; color: var(--text-muted); }
.worker-status-text  { text-transform: capitalize; }
.worker-card-name    { font-size: .95rem; font-weight: 700; margin-bottom: 2px; }
.worker-card-role    { font-size: .78rem; color: var(--text-muted); margin-bottom: 12px; }
.worker-card-stats   { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.worker-stat         { text-align: center; }
.worker-stat-val     { font-size: .9rem; font-weight: 700; }
.worker-stat-lbl     { font-size: .65rem; color: var(--text-muted); }
.worker-card-actions { display: flex; gap: 8px; }

/* ── Approval cards ───────────────────────────────────────── */
.approvals-list { display: flex; flex-direction: column; gap: 12px; }
.approval-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.approval-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.approval-card-meta   { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-muted); flex: 1; }
.approval-badges      { display: flex; gap: 5px; margin-left: auto; }
.approval-card-title  { font-size: .95rem; font-weight: 600; margin-bottom: 4px; }
.approval-card-desc   { font-size: .82rem; color: var(--text-muted); margin-bottom: 10px; }
.approval-card-output { background: var(--surface2); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; border-left: 3px solid var(--primary); }
.approval-card-output pre { font-size: .78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: auto; }
.approval-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.worker-name { font-size: .82rem; font-weight: 600; }

/* ── Workflow cards ───────────────────────────────────────── */
.template-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 20px; }
.template-card  { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: all .15s; }
.template-card:hover { border-color: var(--primary); background: #fafafe; box-shadow: var(--shadow-sm); }
.template-icon  { font-size: 1.5rem; flex-shrink: 0; }
.template-name  { font-size: .85rem; font-weight: 600; }
.template-desc  { font-size: .75rem; color: var(--text-muted); }
.workflows-list { display: flex; flex-direction: column; gap: 10px; }
.workflow-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm); }
.workflow-card-body { flex: 1; min-width: 0; }
.workflow-trigger-badge { font-size: .7rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.workflow-name  { font-size: .9rem; font-weight: 600; }
.workflow-desc  { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.workflow-meta  { font-size: .72rem; color: var(--text-light); margin-top: 4px; }
.workflow-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── Filter pills ─────────────────────────────────────────── */
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-pill { padding: 5px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); font-size: .8rem; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all .13s; display: flex; align-items: center; gap: 5px; }
.filter-pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pill-count { background: rgba(255,255,255,.25); border-radius: 99px; padding: 0 5px; font-size: .68rem; min-width: 18px; text-align: center; }
.filter-pill.active .pill-count { background: rgba(255,255,255,.25); }
.filter-pill:not(.active) .pill-count { background: var(--surface2); color: var(--text-muted); }

/* ── Tasks ────────────────────────────────────────────────── */
.tasks-list { display: flex; flex-direction: column; gap: 8px; }
.task-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 14px; display: flex; align-items: center; gap: 12px; transition: border-color .13s; }
.task-row:hover { border-color: var(--primary); }
.task-row-body { flex: 1; min-width: 0; }
.task-row-title { font-size: .84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-row-meta  { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ── Channels / Claw ──────────────────────────────────────── */
.channel-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 20px; }
.channel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; transition: box-shadow .15s; }
.channel-card:hover { box-shadow: var(--shadow); }
.channel-card.connected { border-color: var(--success); }
.channel-icon { font-size: 1.5rem; }
.channel-name { font-size: .9rem; font-weight: 600; }
.channel-status { }
.code-block { background: var(--surface2); border-radius: var(--radius-sm); padding: 10px 14px; font-family: 'Menlo','Consolas',monospace; font-size: .78rem; word-break: break-all; color: var(--text-muted); border: 1px solid var(--border); }
.claw-list { display: flex; flex-direction: column; gap: 8px; }
.claw-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; gap: 12px; align-items: flex-start; }
.claw-item.processed { opacity: .6; }
.claw-channel-badge { background: var(--primary-light); color: var(--primary-dark); border-radius: 99px; font-size: .68rem; font-weight: 700; padding: 2px 8px; flex-shrink: 0; text-transform: capitalize; }
.channel-email    { background: #e0f2fe; color: #0c4a6e; }
.channel-form     { background: #ede9fe; color: #5b21b6; }
.channel-linkedin { background: #dbeafe; color: #1e40af; }
.channel-whatsapp { background: #d1fae5; color: #065f46; }
.claw-body  { flex: 1; min-width: 0; }
.claw-sender  { font-size: .8rem; font-weight: 600; }
.claw-subject { font-size: .8rem; margin-top: 2px; }
.claw-preview { font-size: .75rem; color: var(--text-muted); margin-top: 3px; }
.claw-meta    { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.claw-time    { font-size: .7rem; color: var(--text-light); }

/* ── Teams ────────────────────────────────────────────────── */
.users-list { display: flex; flex-direction: column; gap: 10px; }
.user-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 14px; }
.user-card-body { flex: 1; min-width: 0; }
.user-card-name  { font-size: .9rem; font-weight: 600; }
.user-card-email { font-size: .78rem; color: var(--text-muted); }
.user-card-meta  { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.user-card-last  { font-size: .72rem; color: var(--text-light); }
.invite-result   { background: #d1fae5; border-radius: var(--radius-sm); padding: 12px; font-size: .82rem; line-height: 1.6; margin-top: 8px; }
.invite-link     { word-break: break-all; background: var(--surface); padding: 2px 6px; border-radius: 4px; }

/* ── Drive / Docs ─────────────────────────────────────────── */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.doc-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; transition: box-shadow .15s; }
.doc-card:hover { box-shadow: var(--shadow); }
.doc-icon  { font-size: 1.5rem; color: var(--primary); }
.doc-name  { font-size: .85rem; font-weight: 600; }
.doc-meta  { font-size: .72rem; color: var(--text-muted); }
.doc-actions { display: flex; gap: 6px; margin-top: 4px; }
.empty-state-categories { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.category-placeholder { display: flex; align-items: center; gap: 6px; background: var(--surface2); border-radius: 99px; padding: 5px 12px; font-size: .78rem; color: var(--text-muted); }

/* ── Settings ─────────────────────────────────────────────── */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 20px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: var(--radius-sm); border: none; background: none; font-size: .84rem; font-weight: 500; color: var(--text-muted); cursor: pointer; text-align: left; font-family: var(--font); transition: all .13s; }
.settings-nav-item:hover { background: var(--surface2); color: var(--text); }
.settings-nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.settings-content { }
.settings-section { display: none; }
.settings-section.active { display: block; }
.settings-section-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.profile-avatar-row { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--surface2); border-radius: var(--radius); }
.gdpr-info { display: flex; flex-direction: column; gap: 12px; }
.gdpr-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: var(--surface2); border-radius: var(--radius-sm); }
.gdpr-item i { font-size: 1.1rem; margin-top: 2px; flex-shrink: 0; }
.gdpr-item strong { font-size: .85rem; }
.gdpr-item p { font-size: .78rem; margin-top: 2px; }

/* Pricing table */
.plan-card { background: var(--primary-light); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.plan-name { font-weight: 700; font-size: 1rem; color: var(--primary-dark); }
.plan-limits { font-size: .82rem; color: var(--text-muted); margin-top: 4px; display: flex; gap: 16px; }
.pricing-table { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.price-card.current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(99,102,241,.15); }
.price-name { font-weight: 700; font-size: .9rem; margin-bottom: 4px; }
.price-val  { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: 10px; }
.price-val span { font-size: .8rem; font-weight: 500; color: var(--text-muted); }
.price-features { list-style: none; margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.price-features li { font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.price-features li i { color: var(--success); font-size: .75rem; }
.integration-list { display: flex; flex-direction: column; gap: 8px; }
.integration-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.integration-icon { font-size: 1.2rem; color: var(--text-muted); width: 28px; text-align: center; }
.integration-body { flex: 1; min-width: 0; }
.integration-name { font-size: .85rem; font-weight: 600; }
.integration-desc { font-size: .75rem; color: var(--text-muted); }
.integration-action { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.table th { text-align: left; padding: 9px 14px; font-size: .71rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafe; }
.history-table { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

/* ── Search ───────────────────────────────────────────────── */
.search-input-wrap { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.search-icon { color: var(--text-muted); font-size: .9rem; flex-shrink: 0; }
.search-box { flex: 1; border: none; outline: none; font-size: .95rem; font-family: var(--font); color: var(--text); background: transparent; }
.search-results { padding-top: 4px; max-height: 300px; overflow-y: auto; }
.search-hint { font-size: .82rem; color: var(--text-muted); padding: 12px 4px; }
.search-result-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background .13s; }
.search-result-item:hover { background: var(--surface2); }
.search-result-icon { font-size: 1.2rem; flex-shrink: 0; }

/* ── Chart placeholder ────────────────────────────────────── */
.chart-placeholder { height: 160px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--text-light); font-size: .85rem; background: var(--surface2); border-radius: var(--radius-sm); }
.chart-placeholder i { font-size: 2rem; }

/* ── PWA Prompt ───────────────────────────────────────────── */
.pwa-prompt { position: fixed; bottom: 20px; right: 20px; z-index: 400; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none; max-width: 300px; }
.pwa-prompt.show { display: block; animation: toastIn .3s ease; }
.pwa-prompt-body { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }

/* ── Empty states ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state i { color: var(--text-light); }
.empty-state h3 { color: var(--text-muted); font-size: .95rem; }
.empty-state p { font-size: .82rem; max-width: 300px; }
.empty-state-sm { padding: 24px; text-align: center; color: var(--text-muted); font-size: .82rem; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state-sm i { font-size: 1.5rem; color: var(--text-light); }

/* ── Section header ───────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; }
.section-title  { font-size: .875rem; font-weight: 700; }

/* ── Misc ─────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* ── Dark mode ────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0f172a;
    --surface:       #1e293b;
    --surface2:      #263347;
    --border:        #334155;
    --text:          #f1f5f9;
    --text-muted:    #94a3b8;
    --text-light:    #64748b;
    --shadow-sm:     0 1px 2px rgba(0,0,0,.2);
    --shadow:        0 4px 6px -1px rgba(0,0,0,.3);
    --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.4);
    --primary-light: rgba(99,102,241,.2);
  }
  .badge-success { background: rgba(16,185,129,.2); color: #6ee7b7; }
  .badge-warning { background: rgba(245,158,11,.2);  color: #fcd34d; }
  .badge-danger  { background: rgba(239,68,68,.2);    color: #fca5a5; }
  .badge-info    { background: rgba(14,165,233,.2);   color: #7dd3fc; }
  .badge-outline { background: rgba(255,255,255,.05); color: var(--text-muted); }
  .form-input    { background: var(--surface2); color: var(--text); }
  .table tr:hover td { background: var(--surface2); }
  .auth-card     { background: #1e293b; }
  .modal         { background: #1e293b; }
  .plan-card     { background: rgba(99,102,241,.15); }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid, .stats-grid-lg { grid-template-columns: repeat(2,1fr); }
  .two-col-layout { grid-template-columns: 1fr; }
  .right-panel { display: grid; grid-template-columns: repeat(2,1fr); }
  .pricing-table { grid-template-columns: 1fr; }
  .template-cards { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 16px; }
  .channel-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 268px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex; }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .stats-grid, .stats-grid-lg { grid-template-columns: repeat(2,1fr); }
  .two-col-layout { grid-template-columns: 1fr; }
  .right-panel { display: flex; flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .page-inner { padding: 14px; }
  .workers-grid { grid-template-columns: 1fr; }
  .channel-grid { grid-template-columns: 1fr 1fr; }
  .template-cards { grid-template-columns: 1fr; }
  .pricing-table { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
}
@media (max-width: 480px) {
  .stats-grid, .stats-grid-lg { grid-template-columns: 1fr 1fr; }
  .channel-grid { grid-template-columns: 1fr; }
  #toast-container { right: 10px; left: 10px; }
  .toast { max-width: none; }
}

/* ── Phase 2 additions ─────────────────────────────────────── */

/* Worker card — two-button action row */
.worker-card-actions { display: flex; gap: .5rem; padding-top: .75rem; }
.worker-card-actions .btn { flex: 1; justify-content: center; }

/* Chart canvas responsive */
canvas { display: block; }

/* Claw stats mini-grid override */
#claw-list .claw-item:last-child { border-bottom: none; }

/* Edit-approve modal textarea */
#ea-output { font-family: 'Roboto Mono', monospace; font-size: .8rem; resize: vertical; }

/* Worker detail modal stats bar */
.worker-detail-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: .5rem 0; }

/* Approval card — edit button outline style */
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }

/* ── Phase 3: AI Generate output ──────────────────────────────── */
.ai-output {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}
.ai-output-header {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.ai-output-text {
  white-space: pre-wrap;
  font-family: 'Inter', sans-serif;
  font-size: .875rem;
  color: var(--text-primary);
  margin: 0 0 .75rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: .25rem;
}

/* ── Phase 3: Drive docs grid ──────────────────────────────────── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.doc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  cursor: pointer;
  transition: border-color .2s;
}
.doc-card:hover { border-color: var(--primary); }
.doc-card-icon { font-size: 1.75rem; }
.doc-card-name { font-weight: 600; font-size: .9rem; color: var(--text-primary); }
.doc-card-meta { font-size: .75rem; color: var(--text-muted); }
.category-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--text-muted);
}
.empty-state-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 640px;
}
