/* ── CSS custom properties (overridden per-app) ── */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.site-header .inner { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; display: flex; align-items: center; gap: 1rem; height: 56px; }
.site-header .logo { font-weight: 700; font-size: 1.1rem; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.site-header .logo img { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; }
.site-header nav { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.site-header nav a,
.site-header nav button.btn { font-size: .85rem; font-weight: 500; color: #fff; background: #1e3a8a; padding: .3rem .75rem; border-radius: var(--radius); text-decoration: none; transition: background .15s; border: none; cursor: pointer; }
.site-header nav a:hover,
.site-header nav button.btn:hover { background: #1e40af; text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem; }
.narrow { max-width: 480px; margin: 3rem auto; padding: 0 1.25rem; }

/* ── Flash messages ── */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: .9rem; }
.flash.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.flash.success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.flash.info { background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
.card + .card { margin-top: 1rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; color: var(--text); }
input[type=text], input[type=password], input[type=email], input[type=color], select, textarea {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9rem; background: var(--surface); color: var(--text); transition: border-color .15s;
}
input[type=color] { height: 2.4rem; padding: .2rem .3rem; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { resize: vertical; min-height: 80px; }
.hint { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; border: none; cursor: pointer; transition: background .15s, opacity .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-success { background: #166534; color: #fff; }
.btn-success:hover { opacity: .85; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Badges / status ── */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-open     { background: #dc2626; color: #fff; }
.badge-read     { background: #f3f4f6; color: #374151; }
.badge-pending  { background: #1e3a8a; color: #fff; }
.badge-completed{ background: #dcfce7; color: #166534; }
.badge-closed   { background: #166534; color: #fff; }
.badge-crash    { background: #fee2e2; color: #991b1b; }
.badge-bug      { background: #ffedd5; color: #9a3412; }
.badge-ui       { background: #ede9fe; color: #5b21b6; }
.badge-improvement { background: #d1fae5; color: #065f46; }
.badge-missingfeature { background: #e0f2fe; color: #075985; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: .6rem .75rem; border-bottom: 2px solid var(--border); font-weight: 600; color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
td { padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── Page headings ── */
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 1.5rem; }
.page-header .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Search bar ── */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.search-bar input { flex: 1; }

/* ── Status indicator ── */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.status-dot.ok { background: var(--success); }
.status-dot.error { background: var(--danger); }

/* ── Auth card ── */
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.auth-card h1 { margin: 0 0 1.5rem; font-size: 1.4rem; text-align: center; }
.auth-footer { text-align: center; font-size: .875rem; color: var(--text-muted); margin-top: 1rem; }

/* ── Article sections preview ── */
.section-block { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; margin-bottom: .5rem; background: var(--bg); display: flex; gap: .5rem; align-items: flex-start; }
.section-block .section-type { font-size: .75rem; font-weight: 600; color: var(--text-muted); min-width: 80px; padding-top: .1rem; text-transform: uppercase; }
.section-block .section-body { flex: 1; }
.section-block pre { margin: 0; font-size: .8rem; white-space: pre-wrap; }

/* ── Colour preview swatch ── */
.colour-swatch { width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; vertical-align: middle; }

/* ── Response thread ── */
.response-thread { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; }
.response-item { padding: .75rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); }
.response-item.developer { background: #eff6ff; border-color: #bfdbfe; }
.response-item.user { background: var(--bg); }
.response-meta { font-size: .75rem; color: var(--text-muted); margin-bottom: .35rem; }

/* ── App icon preview ── */
#icon-preview { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); display: none; margin-top: .5rem; }

/* ── Profile picture & dropdown ── */
.profile-pic { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.4); display: block; }
.profile-btn { background: none; border: none; padding: 2px; cursor: pointer; border-radius: 50%; transition: opacity .15s; line-height: 0; }
.profile-btn:hover { opacity: .85; }
.profile-menu { position: relative; }
.profile-dropdown { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); width: 280px; z-index: 200; max-height: calc(100vh - 80px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.profile-dropdown-inner { padding: .75rem; }
.profile-section { margin-bottom: .75rem; padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.profile-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.profile-section-title { font-size: .7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4rem; }
.profile-msg { font-size: .75rem; margin-top: .3rem; }
.profile-msg.ok { color: var(--success); }
.profile-msg.err { color: var(--danger); }

/* ── Drag handle ── */
.drag-handle { cursor: grab; color: var(--text-muted); margin-right: .4rem; user-select: none; font-size: 1rem; }
.drag-handle:active { cursor: grabbing; }

/* ── Site warnings ── */
.site-warning { background: #fef3c7; border-bottom: 1px solid #f59e0b; color: #92400e; padding: .6rem 1.25rem; font-size: .9rem; text-align: center; }

/* ── Burger menu (hidden on desktop) ── */
.burger-btn { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text); padding: .2rem .4rem; margin-left: auto; line-height: 1; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .burger-btn { display: flex; align-items: center; }
  .site-header nav { display: none; flex-direction: column; align-items: stretch; gap: .4rem; position: absolute; top: 56px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); padding: .75rem 1.25rem; z-index: 100; }
  .site-header nav.open { display: flex; }
  .site-header nav a,
  .site-header nav button.btn { text-align: center; justify-content: center; width: 100%; }
  .profile-menu { width: 100%; }
  .profile-dropdown { position: fixed; left: 0; right: 0; top: 56px; bottom: 0; width: 100%; max-height: none; border-radius: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .article-detail-grid { grid-template-columns: 1fr !important; }
}
