/* MSCQ admin panel */
:root {
  --navy: #14213D;
  --navy-2: #1c2c4f;
  --blue: #1E4C9A;
  --gold: #C9A23F;
  --bg: #F4F6FA;
  --line: #DDE3EC;
  --ink: #14213D;
  --muted: #5A6578;
  --ok-bg: #E7F4EC; --ok: #166534;
  --err-bg: #FDECEC; --err: #991b1b;
  --warn-bg: #FFF4DB; --warn: #8a5a00;
  --info-bg: #E8EFFB; --info: #1E4C9A;
  font-family: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); }
h1, h2 { margin: 0; color: var(--navy); }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline { display: inline; margin: 0; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand img { border-radius: 50%; background: #fff; }
.brand strong { display: block; font-size: 17px; letter-spacing: .04em; }
.brand small { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #aebbd6; }
.sidebar nav { padding: 8px 12px 16px; flex: 1; }
.nav-group { margin: 18px 10px 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #8fa0c2; }
.sidebar nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; color: #e3e9f5; text-decoration: none; font-weight: 600;
}
.sidebar nav a:hover { background: var(--navy-2); color: #fff; }
.sidebar nav a.is-active { background: var(--blue); color: #fff; }
.badge { background: var(--gold); color: var(--navy); border-radius: 999px; font-size: 12px; padding: 1px 8px; font-weight: 700; }
.signout { border-top: 1px solid rgba(255,255,255,.08); padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { font-size: 14px; }
.who small { display: block; color: #8fa0c2; font-size: 12px; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 32px; background: #fff; border-bottom: 1px solid var(--line); }
.crumb { margin: 0; flex: 1; color: var(--muted); }
.crumb strong { color: var(--ink); }
.menu-btn { display: none; }
.main { padding: 28px 32px 64px; max-width: 1280px; width: 100%; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; max-width: 720px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
  padding: 0 18px; border-radius: 8px; border: 1px solid var(--blue); background: var(--blue); color: #fff;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); border-color: #c4ccd9; }
.btn.danger { color: var(--err); }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; text-decoration: underline; }
.btn-link.danger { color: var(--err); }
.btn-link.light { color: #cfd9ee; }
.btn-icon { background: #fff; border: 1px solid var(--line); border-radius: 6px; width: 32px; height: 32px; cursor: pointer; font-size: 15px; }
.btn-icon:hover { border-color: var(--ink); }

/* Cards and stats */
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; margin-bottom: 22px; }
.card > h2 { margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--blue); }
.stat-label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-num { font-size: 34px; font-weight: 700; line-height: 1.1; color: var(--navy); }
.stat-alert { border-color: var(--gold); box-shadow: inset 4px 0 0 var(--gold); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 22px; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 22px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.card .table { margin: 0 -4px; width: calc(100% + 8px); }
.table th { text-align: left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 8px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.unread td { font-weight: 600; background: #fbfcff; }
.table tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.muted-row td { color: var(--muted); }
.clip { max-width: 360px; color: var(--muted); font-weight: 400 !important; }
.thumb { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.thumb-empty { background: #eef1f6; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; object-position: center 22%; display: block; }
.avatar-lg { width: 96px; height: 96px; margin: 6px 0; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f6; color: var(--muted); border: 0; font-family: inherit; }
button.tag { cursor: pointer; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs a { padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.tabs a.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.err { background: var(--err-bg); color: var(--err); }
.alert.info { background: var(--info-bg); color: var(--info); }

/* Forms */
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; margin-bottom: 16px; flex: 1 1 260px; }
.form .label { font-weight: 600; display: block; margin-bottom: 6px; }
.form .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.form input:not([type=checkbox]):not([type=file]), .form select, .form textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: #fff;
  border: 1px solid #c4ccd9; border-radius: 8px; padding: 10px 12px; min-height: 42px; width: 100%;
}
.form textarea { resize: vertical; line-height: 1.5; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.form .row { display: flex; flex-wrap: wrap; gap: 0 20px; }
.form .upload { flex: 1 1 260px; margin-bottom: 16px; }
.form .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.form .preview { max-width: 260px; max-height: 160px; object-fit: cover; border-radius: 8px; display: block; margin: 6px 0 8px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 14px 0; border-top: 1px solid var(--line); }
.narrow { max-width: 640px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 24px; margin: 0 0 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.meta dt { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.meta dd { margin: 2px 0 0; }
.message-body { font-size: 16px; max-width: 760px; }

/* Sign-in and installer */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: var(--navy); }
.auth-card { background: #fff; border-radius: 16px; padding: 36px 34px; width: 100%; max-width: 420px; text-align: center; }
.auth-card img { border-radius: 50%; margin: 0 auto 12px; display: block; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card form { text-align: left; margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.auth-card input { font: inherit; border: 1px solid #c4ccd9; border-radius: 8px; padding: 10px 12px; min-height: 44px; }
.auth-card .btn { width: 100%; margin-top: 4px; }
.auth-card .alert { text-align: left; }

/* Small screens */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .menu-btn { display: inline-flex; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
  .topbar { padding: 12px 16px; }
  .topbar .btn-ghost { display: none; }
  .main { padding: 20px 16px 48px; }
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; overflow-x: auto; }
  .table { min-width: 560px; }
}
