/* QNF Dashboard stylesheet  [qnf-dash]
   Brand: purple #552684, orange #f79031 (from QNF logo) */
:root {
  --purple: #552684;
  --purple-dark: #3f1c63;
  --purple-light: #ede6f5;
  --orange: #f79031;
  --orange-dark: #d9741a;
  --orange-light: #fff1e3;
  --ink: #23202b;
  --muted: #6d6878;
  --line: #e4e0ea;
  --bg: #f6f4f9;
  --card: #ffffff;
  --green: #1f9d55;
  --amber: #e0a100;
  --red: #d33b3b;
  --nav-w: 232px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(35,32,43,.08), 0 4px 14px rgba(85,38,132,.06);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; font-weight: 650; color: var(--purple-dark); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- shell ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 60px; background: var(--purple); color: #fff; display: flex; align-items: center; padding: 0 1rem 0 .75rem; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.topbar .brand { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; }
.topbar .brand .logo { background: #fff; border-radius: 8px; padding: 4px 10px; display: flex; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.topbar .brand .logo img { height: 40px; width: auto; display: block; }
.topbar .brand span { font-weight: 600; font-size: 1.05rem; letter-spacing: .01em; }
.topbar .brand small { display: block; font-size: .7rem; font-weight: 500; opacity: .8; letter-spacing: .08em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: .9rem; font-size: .9rem; }
.topbar .user .pill { background: var(--orange); color: #fff; border-radius: 999px; padding: .15rem .6rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.topbar .user a { color: #fff; opacity: .9; }
.topbar .menu-btn { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; margin-right: .5rem; cursor: pointer; }

.sidenav { position: fixed; top: 60px; bottom: 0; left: 0; width: var(--nav-w); background: #fff; border-right: 1px solid var(--line); overflow-y: auto; padding: .75rem 0 1.5rem; z-index: 10; }
.sidenav .sec { padding: .9rem 1rem .3rem; font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sidenav a { display: block; padding: .42rem 1rem .42rem 1.1rem; color: var(--ink); border-left: 3px solid transparent; font-size: .92rem; }
.sidenav a:hover { background: var(--purple-light); text-decoration: none; }
.sidenav a.active { border-left-color: var(--orange); background: var(--purple-light); color: var(--purple-dark); font-weight: 600; }
.sidenav .empty { padding: .3rem 1.1rem; font-size: .8rem; color: var(--muted); font-style: italic; }

.main { margin-left: var(--nav-w); padding: 76px 1.5rem 2.5rem; min-height: 100vh; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head .desc { color: var(--muted); font-size: .9rem; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; margin: 0 0 1.1rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1.1rem; border-top: 3px solid var(--purple); }
.card.orange { border-top-color: var(--orange); }
.card .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.card .value { font-size: 1.5rem; font-weight: 650; margin-top: .15rem; color: var(--purple-dark); font-variant-numeric: tabular-nums; }
.card .sub { font-size: .8rem; color: var(--muted); margin-top: .1rem; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; margin-bottom: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* health */
.health { display: flex; align-items: center; gap: .9rem; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #bbb; flex: none; box-shadow: 0 0 0 4px rgba(0,0,0,.05); }
.dot.green { background: var(--green); box-shadow: 0 0 0 4px rgba(31,157,85,.15); }
.dot.amber { background: var(--amber); box-shadow: 0 0 0 4px rgba(224,161,0,.15); }
.dot.red { background: var(--red); box-shadow: 0 0 0 4px rgba(211,59,59,.15); }
.health .title { font-weight: 650; }
.health .meta { color: var(--muted); font-size: .85rem; }

/* ---------- filter bar ---------- */
.filterbar { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1.1rem; margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: .8rem 1.1rem; align-items: flex-end; }
.filterbar .f { display: flex; flex-direction: column; gap: .25rem; min-width: 150px; }
.filterbar label { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.filterbar .range { display: flex; gap: .4rem; align-items: center; }
.filterbar .quick { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.filterbar .quick button { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--purple); cursor: pointer; }
.filterbar .quick button:hover { background: var(--purple-light); }
.filterbar .actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
input[type=text], input[type=date], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit; padding: .42rem .6rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(85,38,132,.25); border-color: var(--purple); }
select[multiple] { min-height: 92px; min-width: 180px; }
.ms-tools { display: flex; gap: .4rem; }
.ms-tools button { font-size: .7rem; border: 0; background: none; color: var(--purple); cursor: pointer; padding: 0; }
.ms-tools button:hover { text-decoration: underline; }

.btn { font: inherit; font-weight: 600; padding: .5rem 1rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; line-height: 1.2; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover { background: var(--purple-dark); }
.btn-ghost { background: #fff; color: var(--purple); border-color: var(--line); }
.btn-ghost:hover { background: var(--purple-light); }
.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-danger { background: #fff; color: var(--red); border-color: #f1c4c4; }

/* ---------- table ---------- */
.tablewrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 150px); }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .88rem; }
table.data th { position: sticky; top: 0; background: var(--purple); color: #fff; text-align: left; padding: .55rem .7rem; font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; z-index: 2; }
table.data th:hover { background: var(--purple-dark); }
table.data th .arrow { opacity: .6; font-size: .7rem; margin-left: .25rem; }
table.data td { padding: .45rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data tbody tr:nth-child(even) td { background: #faf8fc; }
table.data tbody tr:hover td { background: var(--orange-light); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { position: sticky; bottom: 0; background: var(--purple-light); font-weight: 650; border-top: 2px solid var(--purple); }
table.plain { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.plain th, table.plain td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plain th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: #eee; color: #444; }
.badge-ok { background: #def5e7; color: #156d3b; }
.badge-error { background: #fbe0e0; color: #9b2222; }
.badge-running { background: var(--orange-light); color: var(--orange-dark); }
.badge-sage { background: var(--purple-light); color: var(--purple-dark); }
.badge-magento { background: var(--orange-light); color: var(--orange-dark); }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid transparent; }
.flash-ok { background: #def5e7; color: #156d3b; border-color: #b9e6c9; }
.flash-error { background: #fbe0e0; color: #9b2222; border-color: #f1bcbc; }
.flash-info { background: var(--purple-light); color: var(--purple-dark); border-color: #d8c9ea; }

.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
pre.log { background: #1f1b26; color: #e8e3f0; padding: .9rem 1rem; border-radius: 8px; font-size: .78rem; line-height: 1.4; overflow: auto; max-height: 60vh; }
code { background: var(--purple-light); padding: .05rem .35rem; border-radius: 4px; font-size: .88em; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-grid label input, .form-grid label select { font-weight: 400; color: var(--ink); }
.check { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }

/* loading overlay */
#overlay { position: fixed; inset: 0; background: rgba(246,244,249,.75); display: none; align-items: center; justify-content: center; z-index: 50; flex-direction: column; gap: .8rem; color: var(--purple-dark); font-weight: 600; }
#overlay.on { display: flex; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--purple-light); border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 60%, #2b1346 100%); padding: 1rem; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); width: 100%; max-width: 400px; padding: 2rem 2rem 1.6rem; border-top: 5px solid var(--orange); }
.login-card img { display: block; height: 72px; margin: 0 auto 1rem; }
.login-card h1 { text-align: center; font-size: 1.15rem; color: var(--purple-dark); margin-bottom: 1.2rem; }
.login-card label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin: .8rem 0 .25rem; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 1.2rem; padding: .65rem; }
.login-card .foot { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 1.2rem; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .sidenav { transform: translateX(-100%); transition: transform .2s; }
  .sidenav.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .main { margin-left: 0; padding: 72px .9rem 2rem; }
  .topbar .menu-btn { display: block; }
  .topbar .brand small { display: none; }
}
@media print {
  .topbar, .sidenav, .filterbar, .btn, #overlay { display: none !important; }
  .main { margin: 0; padding: 0; }
  .tablewrap { box-shadow: none; max-height: none; overflow: visible; }
}

/* ---------- sync admin  [qnf-dash] ---------- */
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; border: 0; background: #cfc9d9; cursor: pointer; padding: 0; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on { background: var(--green); }
.switch.on span { left: 19px; }
tr.dim td { opacity: .55; }
tr.dim td:first-child, tr.dim td:last-child { opacity: 1; }
.chip { display: inline-block; padding: .05rem .45rem; border-radius: 5px; font-size: .7rem; font-weight: 700; letter-spacing: .04em; background: var(--purple-light); color: var(--purple-dark); }
.chip-full { background: #e8eefc; color: #2b4a9b; }
.chip-incremental { background: #def5e7; color: #156d3b; }
.chip-window { background: var(--orange-light); color: var(--orange-dark); }
table.sync-grid td { white-space: normal; vertical-align: middle; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.seg { border: 1px solid var(--line); border-radius: 9px; padding: .6rem .8rem; cursor: pointer; display: flex; flex-direction: column; gap: .1rem; background: #fff; }
.seg input { display: none; }
.seg b { font-size: .9rem; color: var(--ink); }
.seg span { font-size: .75rem; color: var(--muted); }
.seg.on { border-color: var(--orange); background: var(--orange-light); box-shadow: 0 0 0 2px rgba(247,144,49,.25); }
.steps ol { padding-left: 1.2rem; margin: 0; }
.steps li { margin: .45rem 0; font-size: .92rem; }
.colgrid td, .colgrid th { padding: .3rem .5rem; }
