:root {
  --navy: #0e2a47;
  --navy-active: #15395d;
  --teal: #0ea5a3;
  --teal-dark: #0b8886;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e4e8ee;
  --text: #16233a;
  --text-dim: #5b6b84;
  --yellow-bg: #fdf3d8;
  --yellow-text: #9a6d08;
  --green-bg: #e3f7ef;
  --green-text: #0f8a5f;
  --blue-bg: #e6f0ff;
  --blue-text: #1d5fd1;
  --purple-bg: #efe9fd;
  --purple-text: #6c3fc9;
  --red-bg: #fde8e8;
  --red-text: #c62828;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.ap-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.ap-sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--navy);
  color: #cfe0f0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.ap-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.ap-brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--teal), #5ad1c9);
  display: flex; align-items: center; justify-content: center;
  color: #06332f; font-weight: 800; font-size: 16px;
}
.ap-brand-name { font-weight: 700; font-size: 15px; line-height: 1.25; color: #fff; }

.ap-nav { list-style: none; margin: 0; padding: 0; flex: 1; }
.ap-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-bottom: 2px;
  border-radius: 8px; color: #b9cadf; text-decoration: none;
  font-size: 13.5px;
}
.ap-nav li a .ico { width: 18px; text-align: center; opacity: .85; }
.ap-nav li a:hover { background: rgba(255,255,255,.06); color: #fff; }
.ap-nav li a.active { background: var(--navy-active); color: #fff; font-weight: 600; }

.ap-sidebar-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; margin-top: 10px; }
.ap-command-card {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.06); border-radius: 8px; padding: 10px 12px;
  font-size: 12.5px; color: #b9cadf;
}
.ap-command-card:hover { background: rgba(255,255,255,.1); }
.ap-command-card span { color: inherit; }
.ap-command-dot { width: 7px; height: 7px; border-radius: 50%; background: #e05555; display: inline-block; margin-right: 6px; }

/* ---------- Main ---------- */
.ap-main { flex: 1; padding: 26px 30px 40px; max-width: 1480px; }

.ap-topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.ap-title { font-size: 28px; font-weight: 800; margin: 0; }
.ap-subtitle { color: var(--text-dim); margin: 4px 0 0; font-size: 14px; }
.ap-topbar-tag { font-size: 11px; letter-spacing: .06em; color: var(--text-dim); text-align: right; text-transform: uppercase; }

.ap-topbar-actions { display: flex; gap: 10px; align-items: center; margin-top: 2px; }
.ap-pill-select, .ap-pill-date {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; color: var(--text);
}
.ap-btn {
  border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer;
}
.ap-btn.outline { border-color: var(--teal); color: var(--teal-dark); background: #fff; }
.ap-btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.ap-btn.primary.disabled { opacity: .55; cursor: not-allowed; }

.ap-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin: 22px 0 20px; }
.ap-tabs a { padding-bottom: 10px; color: var(--text-dim); text-decoration: none; font-size: 14px; font-weight: 600; }
.ap-tabs a.active { color: var(--text); border-bottom: 2px solid var(--teal); }

/* ---------- Stat tiles ---------- */
.ap-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.ap-stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: center; gap: 14px;
}
.ap-stat-icon { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.ap-stat-icon.blue { background: var(--blue-bg); color: var(--blue-text); }
.ap-stat-icon.green { background: var(--green-bg); color: var(--green-text); }
.ap-stat-icon.yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.ap-stat-icon.purple { background: var(--purple-bg); color: var(--purple-text); }
.ap-stat-label { font-size: 12.5px; color: var(--text-dim); margin: 0 0 2px; }
.ap-stat-value { font-size: 22px; font-weight: 800; margin: 0; }

.ap-banner {
  background: var(--yellow-bg); color: #7a5a05; border: 1px solid #f1deac;
  border-radius: var(--radius); padding: 11px 16px; font-size: 13.5px;
  margin-bottom: 20px; display: flex; align-items: center; gap: 8px;
}
.ap-banner.connected { background: var(--green-bg); color: var(--green-text); border-color: #bfe8d4; }

/* ---------- Content grid ---------- */
.ap-grid { display: grid; grid-template-columns: 2.1fr 1fr; gap: 18px; align-items: start; }
.ap-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.ap-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.ap-card-title { font-size: 15.5px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; }

.ap-pipeline { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.ap-pipeline-stage { display: flex; align-items: center; gap: 7px; background: var(--bg); border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
.ap-pipeline-stage .count { background: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.ap-pipeline-arrow { color: var(--text-dim); }

.ap-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ap-table th { text-align: left; color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.ap-table td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ap-table tr:last-child td { border-bottom: none; }
.ap-row-thumb { width: 38px; height: 38px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 15px; margin-right: 10px; vertical-align: middle; }

.ap-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.ap-badge.yellow { background: var(--yellow-bg); color: var(--yellow-text); }
.ap-badge.blue { background: var(--blue-bg); color: var(--blue-text); }
.ap-badge.green { background: var(--green-bg); color: var(--green-text); }
.ap-badge.purple { background: var(--purple-bg); color: var(--purple-text); }
.ap-badge.gray { background: #eef1f5; color: var(--text-dim); }

.ap-empty { text-align: center; color: var(--text-dim); padding: 30px 10px; font-size: 13.5px; }
.ap-empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }

.ap-action-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.ap-action-item:last-of-type { border-bottom: none; }
.ap-action-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--blue-bg); color: var(--blue-text); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.ap-action-title { font-size: 13.5px; font-weight: 700; margin: 0 0 2px; }
.ap-action-sub { font-size: 12px; color: var(--text-dim); margin: 0; }
.ap-action-btn { border: 1px solid var(--teal); color: var(--teal-dark); background: #fff; border-radius: 7px; padding: 5px 12px; font-size: 12.5px; font-weight: 700; white-space: nowrap; cursor: pointer; }

.ap-schedule-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ap-schedule-item:last-of-type { border-bottom: none; }
.ap-schedule-time { font-size: 12px; color: var(--text-dim); width: 64px; flex-shrink: 0; }

.ap-qc-bar { display: flex; align-items: center; gap: 22px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 20px; font-size: 13px; }
.ap-qc-item { display: flex; align-items: center; gap: 7px; color: var(--text-dim); }
.ap-qc-dot { width: 8px; height: 8px; border-radius: 50%; background: #c7cedb; }
.ap-qc-item.active .ap-qc-dot { background: var(--green-text); }
.ap-qc-item.active { color: var(--text); font-weight: 600; }

.ap-footer-note { color: var(--text-dim); font-size: 12px; margin-top: 18px; }

/* ---------- Topbar user / tag variants ---------- */
.ap-topbar-right { display: flex; align-items: center; gap: 14px; }
.ap-user-chip { display: flex; align-items: center; gap: 8px; }
.ap-user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.ap-user-name { font-size: 13px; font-weight: 700; margin: 0; }
.ap-user-role { font-size: 11px; color: var(--text-dim); margin: 0; }

/* ---------- Filter bar ---------- */
.ap-filterbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.ap-filterbar select, .ap-filterbar .ap-pill-date { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--text); }
.ap-search { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--text-dim); }

/* ---------- Toggle switch ---------- */
.ap-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.ap-toggle { position: relative; width: 38px; height: 21px; flex-shrink: 0; }
.ap-toggle input { opacity: 0; width: 0; height: 0; }
.ap-toggle-track { position: absolute; inset: 0; background: #cdd5e0; border-radius: 999px; transition: .15s; }
.ap-toggle-track::before { content: ''; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.ap-toggle input:checked + .ap-toggle-track { background: var(--teal); }
.ap-toggle input:checked + .ap-toggle-track::before { transform: translateX(17px); }

/* ---------- Tabs (pill underline, reused for sub-sections) ---------- */
.ap-subtabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.ap-subtabs a { padding-bottom: 9px; color: var(--text-dim); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.ap-subtabs a.active { color: var(--text); border-bottom: 2px solid var(--teal); }

/* ---------- Progress bar ---------- */
.ap-progress { height: 6px; border-radius: 999px; background: #e7ebf1; overflow: hidden; margin: 8px 0; }
.ap-progress > span { display: block; height: 100%; background: var(--teal); border-radius: 999px; }

/* ---------- Kanban board (Editorial Pipeline) ---------- */
.ap-kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 220px; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.ap-kanban-col-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; padding: 8px 10px; border-radius: 8px; background: var(--bg); margin-bottom: 10px; }
.ap-kanban-col-head .count { background: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.ap-kcard { background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: 0 0 10px; margin-bottom: 10px; overflow: hidden; }
.ap-kcard-thumb { width: 100%; height: 72px; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 20px; }
.ap-kcard-body { padding: 8px 10px 0; }
.ap-kcard-title { font-size: 12.5px; font-weight: 700; margin: 0 0 3px; line-height: 1.3; }
.ap-kcard-domain { font-size: 11px; color: var(--text-dim); margin: 0 0 6px; }

/* ---------- Calendar grid ---------- */
.ap-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.ap-cal-day-head { font-size: 12px; font-weight: 700; color: var(--text-dim); text-align: left; padding: 0 4px 4px; }
.ap-cal-cell { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px; min-height: 90px; }
.ap-cal-slot { font-size: 11px; padding: 5px 6px; border-radius: 6px; margin-bottom: 5px; background: var(--bg); }
.ap-cal-slot .t { color: var(--text-dim); font-size: 10.5px; }

/* ---------- Split detail layout (Approvals / Activity Log / QA) ---------- */
.ap-split { display: grid; grid-template-columns: 1fr 1.1fr; gap: 16px; align-items: start; }
.ap-list-item { border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
.ap-list-item.selected { border-color: var(--teal); background: #f2fcfb; }
.ap-list-item-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.ap-list-item-title { font-size: 13.5px; font-weight: 700; margin: 2px 0; }
.ap-list-item-sub { font-size: 12px; color: var(--text-dim); }
.ap-detail-section { margin-bottom: 16px; }
.ap-detail-label { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.ap-checklist-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }

/* ---------- Step list (Aurora Command connection) ---------- */
.ap-step { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ap-step:last-child { border-bottom: none; }
.ap-step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--bg); color: var(--text-dim); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }

/* ---------- Image gallery card ---------- */
.ap-img-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.ap-img-card.selected { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.ap-img-thumb { width: 100%; height: 130px; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 26px; position: relative; }
.ap-img-thumb .ap-badge { position: absolute; top: 8px; left: 8px; }
.ap-img-card-body { padding: 10px 12px; }

.ap-icon-chip { width: 34px; height: 34px; border-radius: 8px; background: var(--bg); color: var(--text-dim); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }

/* ---------- Login ---------- */
.ap-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); }
.ap-login-card { background: #fff; border-radius: 14px; padding: 36px 34px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.ap-login-logo { text-align: center; margin-bottom: 24px; }
.ap-login-mark { width: 44px; height: 44px; border-radius: 11px; background: linear-gradient(135deg, var(--teal), #5ad1c9); display: flex; align-items: center; justify-content: center; color: #06332f; font-weight: 800; font-size: 20px; margin: 0 auto 10px; }
.ap-login-title { font-weight: 800; font-size: 18px; margin: 0; }
.ap-login-sub { font-size: 11px; letter-spacing: .06em; color: var(--text-dim); text-transform: uppercase; margin-top: 2px; }
.ap-login-error { background: var(--red-bg); color: var(--red-text); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 16px; }
.ap-field { margin-bottom: 16px; }
.ap-field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; }
.ap-field input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.ap-login-btn { width: 100%; background: var(--teal); color: #fff; border: none; border-radius: 8px; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer; }
