:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #16181d;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --brand-primary: #4f46e5;
  --brand-primary-hover: #4338ca;
  --brand-secondary: #e05d36;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 28px -10px rgba(15, 23, 42, 0.16);
}

[data-theme="dark"] {
  --bg: #121317;
  --surface: #1b1d23;
  --text: #eef0f3;
  --text-muted: #9aa0ab;
  --border: #2b2e37;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 28px -10px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

.skip-link {
  position: absolute; left: 8px; top: -48px;
  background: var(--brand-primary); color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 200;
  transition: top 0.15s;
}
.skip-link:focus { top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.4rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }

.icon { width: 18px; height: 18px; display: inline-block; vertical-align: -4px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon-lg { width: 22px; height: 22px; }

/* Fixed accent colors for icons that should read as "their own colour"
   regardless of the surrounding text color (sidebar sections, platform
   glyphs, stat tiles) -- these win over inherited color since they're set
   directly on the icon element, not just on an ancestor. */
.icon-indigo { color: var(--brand-primary); }
.icon-blue { color: #2563eb; }
.icon-amber { color: #d97706; }
.icon-teal { color: #0d9488; }
.icon-purple { color: #7c3aed; }
.icon-pink { color: #db2777; }
.icon-slate { color: #64748b; }
.icon-red { color: #dc2626; }
.icon-orange { color: #ea580c; }
.icon-green { color: #16a34a; }
/* Real platform brand colors for the Android/Apple glyphs specifically. */
.icon-android { color: #3ddc84; }
.icon-apple { color: #8e8e93; }
[data-theme="dark"] .icon-apple { color: #d1d5db; }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* Header / nav */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 3px solid var(--brand-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-logo { height: 32px; width: auto; object-fit: contain; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.site-nav a { color: var(--text-muted); font-weight: 500; font-size: 0.9rem; }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.nav-user { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.85rem; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-primary); color: #fff; font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0; object-fit: cover;
}
.avatar-lg { width: 84px; height: 84px; font-size: 2rem; }
.profile-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }

.role-pill {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.72rem;
  text-transform: capitalize;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-muted); text-decoration: none; }

.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 24px;
}
.site-footer .dot { margin: 0 6px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, filter 0.15s;
}
.btn:hover { text-decoration: none; border-color: var(--brand-primary); }
.btn-primary { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.btn-primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 0.82rem; }
.link-btn { background: none; border: none; color: var(--brand-primary); cursor: pointer; padding: 0; font-size: inherit; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.row-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.platform-icons { display: inline-flex; gap: 6px; align-items: center; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 20px;
}
.card.narrow { max-width: 520px; }
.card.wide { max-width: 780px; }
.card.compact { padding: 14px; }
/* For standalone full-page cards (login, etc.) that aren't already
   positioned by flowing next to other content -- centers horizontally and
   drops it a bit from the top, matching the landing page's hero placement. */
.card.centered { margin: 8vh auto 0; }
.card-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.card-row .card { flex: 1 1 220px; margin-bottom: 0; }

/* Store front */
.store-hero { padding: 32px 0 20px; }
.store-hero h1 { margin-bottom: 4px; font-size: 1.8rem; }
.search-form { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.search-form input, .search-form select { flex: 1 1 200px; }
.store-hero.landing {
  text-align: center;
  max-width: 560px;
  margin: 10vh auto 0;
  padding: 0;
}
.store-hero.landing .btn { margin-top: 12px; }
.store-hero.landing code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

/* Public app page: a compact identity + a loud download CTA, everything else tucked away */
/* Keeps the hero card and the What's New / Version history cards below it
   sharing one consistent column width, so a compact hero doesn't look
   orphaned above much wider cards. */
.app-detail-container { max-width: 640px; margin: 0 auto; }

.app-hero { text-align: left; margin: 20px auto; padding: 20px 22px; box-shadow: var(--shadow-md); }
.app-hero-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.app-hero-info { min-width: 0; }
.app-hero-logo {
  width: 52px; height: 52px; border-radius: 14px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.2rem;
  overflow: hidden; border: 1px solid var(--border); flex-shrink: 0;
}
.app-hero-logo img { width: 100%; height: 100%; object-fit: cover; }
.app-hero-name { font-size: 1rem; font-weight: 600; margin: 0; }
.app-hero-meta { margin: 2px 0 6px; font-size: 0.76rem; }
.app-hero-owner { font-size: 0.72rem; margin: 0 0 6px; }
.app-hero-desc { margin-top: 14px; font-size: 0.82rem; color: var(--text-muted); }

.platform-badges { display: flex; justify-content: flex-start; gap: 5px; flex-wrap: wrap; }
.platform-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 0.68rem; color: var(--text-muted); font-weight: 500;
}

.download-buttons { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; }
.download-buttons .btn-download { flex: 1 1 200px; }
.btn-download {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--brand-primary); border-color: var(--brand-primary); color: #fff;
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, 0.45);
}
.btn-download:hover { text-decoration: none; background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.btn-download .icon-lg { width: 17px; height: 17px; }
.btn-download-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.download-label { font-size: 0.85rem; font-weight: 700; }
.download-version { font-size: 0.68rem; opacity: 0.85; }

/* Microsoft's own multi-color sign-in button convention: neutral background/border, full brand color kept only in the four-square logo. */
.btn-microsoft {
  width: 100%; justify-content: center; gap: 10px;
  background: var(--surface); color: var(--text); border-color: var(--border);
}
.btn-microsoft:hover { border-color: var(--text-muted); background: var(--surface); }
.btn-microsoft .icon { width: 18px; height: 18px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--text-muted); font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Secondary info lives in <details> so the download CTA stays the focus */
.details-section summary {
  cursor: pointer; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.details-section summary::-webkit-details-marker { display: none; }
.details-section summary .chevron { color: var(--text-muted); transition: transform 0.15s; margin-left: auto; }
.details-section[open] summary .chevron { transform: rotate(180deg); }
.details-section summary ~ * { margin-top: 14px; }
.release-notes-list { margin: 0; padding-left: 20px; }
.release-notes-list li { margin-bottom: 4px; }

/* Version history as an expandable list, one row per release */
.release-list { display: flex; flex-direction: column; gap: 8px; }
.release-row { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.release-row summary {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  cursor: pointer; list-style: none; font-weight: 500;
}
.release-row summary::-webkit-details-marker { display: none; }
.release-row-version { font-weight: 600; min-width: 56px; }
.release-row-badges { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; }
.release-row-date { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.release-row summary .chevron { color: var(--text-muted); transition: transform 0.15s; }
.release-row[open] summary .chevron { transform: rotate(180deg); }
.release-row-body { padding: 0 14px 14px; color: var(--text-muted); font-size: 0.9rem; border-top: 1px solid var(--border); margin-top: 0; padding-top: 12px; }
.release-row-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Forms */
.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 600; }
.stack-form label.checkbox { flex-direction: row; align-items: center; font-weight: 500; }
.stack-form .hint { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }

/* Wider variant for forms with several short fields (e.g. application/user
   create-edit) so they use the available card width instead of stacking
   everything into one narrow column. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 600; }
.form-grid label.checkbox { flex-direction: row; align-items: center; font-weight: 500; }
.form-grid .hint { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-grid .form-actions { grid-column: 1 / -1; }
.checkbox-group {
  border: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.checkbox-group legend { font-size: 0.9rem; font-weight: 600; padding: 0; margin-bottom: 4px; }
.checkbox-group .checkbox { font-weight: 500; }
input, select, textarea {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 1px;
}
/* Let the browser render the actual color swatch instead of painting our
   surface background over it. */
input[type="color"] { background: none; padding: 3px; width: 64px; height: 38px; }
.form-actions { display: flex; gap: 10px; }

/* Tables */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table th { background: var(--bg); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }

/* Badges: tinted dot-pill, no border, reads status at a glance without relying on color alone */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; text-transform: capitalize;
  background: var(--bg); color: var(--text-muted);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-draft, .badge-inactive, .badge-archived { color: var(--text-muted); }
.badge-pending_approval, .badge-changes_requested { color: var(--warning); background: rgba(217, 119, 6, 0.12); }
.badge-approved, .badge-published, .badge-active { color: var(--success); background: rgba(22, 163, 74, 0.12); }
.badge-rejected, .badge-failed { color: var(--danger); background: rgba(220, 38, 38, 0.12); }

/* Misc */
.muted { color: var(--text-muted); }
.empty-state { color: var(--text-muted); padding: 16px 0; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert-error { background: rgba(220,38,38,0.1); color: var(--danger); }
.alert-info { background: rgba(217,119,6,0.1); color: var(--warning); }
.plain-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.info-list dt { color: var(--text-muted); }
.info-list dd { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-top: 20px; }
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px; text-align: center; }
.stat-warning { border-color: var(--danger); }
.stat-value { display: block; font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; }
/* Colored icon chip: a light tint of the icon's own color as background,
   the icon itself at full color -- the color is set once (icon-* class) on
   .stat-icon and both the tint and the icon inherit it via currentColor. */
.stat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: color-mix(in srgb, currentColor 15%, transparent);
  margin-bottom: 8px;
}
.stat-icon .icon { width: 18px; height: 18px; }
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.review-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.notification-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.notification-list li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }

/* Toasts */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 12px 14px; max-width: 340px; font-size: 0.88rem;
  animation: toast-in 0.2s ease-out;
}
.toast-hide { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }
.toast-success { color: var(--success); }
.toast-error { color: var(--danger); }
.toast-warning { color: var(--warning); }
.toast span { color: var(--text); flex: 1; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 2px; display: flex; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* Notification bell badge */
.bell-btn { position: relative; }
.bell-badge {
  position: absolute; top: -3px; right: -3px;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 0.65rem; font-weight: 700; line-height: 1;
  min-width: 15px; height: 15px; display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* Admin layout: sidebar + content */
.admin-layout { display: flex; gap: 28px; align-items: flex-start; }
.admin-sidebar { width: 220px; flex-shrink: 0; position: sticky; top: 76px; }
.admin-sidebar-group { margin-bottom: 18px; }
.admin-sidebar-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); padding: 0 10px; margin-bottom: 6px; }
.admin-sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
}
.admin-sidebar a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.admin-sidebar a.active { background: rgba(79, 70, 229, 0.1); color: var(--brand-primary); }
.admin-content { flex: 1; min-width: 0; }

/* Category chips */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 8px 5px 12px; font-size: 0.85rem;
}
.chip form { display: inline-flex; }
.chip .link-btn { color: var(--text-muted); display: flex; }
.chip .link-btn:hover { color: var(--danger); }

.pagination { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 600; color: var(--text-muted); }
.filter-bar input, .filter-bar select { min-width: 140px; }

/* Branded status pages */
.status-page { text-align: center; max-width: 420px; margin: 8vh auto 0; padding: 40px 28px; }
.status-page .icon-lg { width: 40px; height: 40px; color: var(--text-muted); margin-bottom: 12px; }
.status-page h1 { font-size: 1.25rem; }

@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; position: static; }
}
