/*
 * PVKhanh Auto — element defaults and components for the server-rendered apps
 * (the main site, Quét Nhạc). Colours and the shell come from shell.css.
 */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.55 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; text-underline-offset: 2px; }
img { max-width: 100%; }
::selection { background: var(--brand-soft-2); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 max(1.25rem, env(safe-area-inset-right)) 0 max(1.25rem, env(safe-area-inset-left)); }
.wrap.wide { max-width: none; }
main.wrap { padding-top: 1.75rem; padding-bottom: 4rem; }
@media (max-width: 640px) { main.wrap { padding-top: 1.1rem; } }

h1 { font-size: 1.5rem; line-height: 1.3; font-weight: 700; letter-spacing: -.015em; margin: 0; }
h2 { font-size: 1.02rem; line-height: 1.4; font-weight: 600; margin: 0 0 .75rem; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.grid > * { min-width: 0; }
.stack > * + * { margin-top: 1rem; }

/* page header: title + subtitle on the left, actions on the right */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head .sub { color: var(--muted); font-size: .88rem; margin-top: .3rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.page-head .actions form { margin: 0; }
.crumbs { display: flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .82rem; margin-bottom: .4rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2rem 0 .75rem; }
.section-title h2 { margin: 0; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }
.card-head h2 { margin: 0; }
.card.danger-zone { border-color: var(--err-line); background: var(--err-soft); }
.card.danger-zone h2 { color: var(--err-ink); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1.1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--row-hover); }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td a strong { color: var(--text); }
td a:hover strong { color: var(--brand); }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty .ux-ico { width: 32px; height: 32px; color: var(--subtle); display: block; margin: 0 auto .6rem; }
.empty strong { display: block; color: var(--text-2); margin-bottom: .2rem; }

/* definition list */
dl { display: grid; grid-template-columns: 140px 1fr; gap: .55rem 1rem; margin: 0; font-size: .9rem; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
@media (max-width: 520px) { dl { grid-template-columns: 1fr; gap: .1rem; } dd { margin-bottom: .5rem; } }

code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84em; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: .05rem .35rem; border-radius: 5px; color: var(--text-2); }
pre.log { background: #0b1220; border: 1px solid var(--line); color: #e2e8f0; padding: 1rem 1.1rem; border-radius: var(--radius); overflow: auto; max-height: 70vh; white-space: pre-wrap;
  word-break: break-all; margin: 0; font-size: .8rem; line-height: 1.6; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 38px; padding: 0 .95rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font: 500 .88rem/1 var(--font); cursor: pointer; text-decoration: none;
  white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn .ux-ico { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn.danger { color: var(--err-ink); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err-line); }
.btn.danger.solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 .7rem; font-size: .82rem; }
.btn.lg { height: 44px; padding: 0 1.3rem; font-size: .95rem; }
.btn.block { width: 100%; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
form.inline { display: inline; }

/* forms */
label { display: block; font-weight: 500; margin: 1rem 0 .35rem; font-size: .88rem; color: var(--text-2); }
label.check { display: flex; gap: .55rem; align-items: center; font-weight: 400; color: var(--text); margin: .5rem 0; cursor: pointer; }
label.check input { margin: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], textarea, select {
  width: 100%; min-height: 40px; padding: .5rem .75rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: 400 .92rem/1.4 var(--font); transition: border-color .12s, box-shadow .12s; }
input:hover, textarea:hover, select:hover { border-color: var(--subtle); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .16); }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--subtle); }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem; line-height: 1.55; }
select { -webkit-appearance: none; appearance: none; padding-right: 2.1rem; cursor: pointer; color-scheme: inherit;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right .7rem center / 12px; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; }
input[type=range] { accent-color: var(--brand); }
.hint { color: var(--muted); font-size: .8rem; margin-top: .35rem; line-height: 1.5; }
.error { color: var(--err-ink); font-size: .82rem; margin-top: .35rem; }
.form-actions { display: flex; gap: .5rem; align-items: center; margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.copy { display: flex; gap: .5rem; }
.copy input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }
.copy .btn { height: 40px; }
.checks { display: grid; gap: .5rem; }
.choice { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem .9rem; margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 400; transition: border-color .12s, background .12s; }
.choice:hover { border-color: var(--line-strong); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: .2rem; }
.choice strong { display: block; font-weight: 600; color: var(--text); font-size: .9rem; }
.choice span { color: var(--muted); font-size: .82rem; }

/* notices */
.flash { display: flex; gap: .65rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; font-size: .9rem;
  border: 1px solid var(--line); background: var(--info-soft); color: var(--text-2); }
.flash .ux-ico { margin-top: .12rem; color: var(--info); }
.flash.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-ink); }
.flash.ok .ux-ico { color: var(--ok); }
.flash.err { background: var(--err-soft); border-color: var(--err-line); color: var(--err-ink-2); }
.flash.err .ux-ico { color: var(--err); }
.flash.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.flash.warn .ux-ico { color: var(--warn); }
.flash > div { flex: 1; min-width: 0; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; height: 22px; padding: 0 .55rem; border-radius: 99px; font-size: .74rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.success, .badge.done, .badge.online { background: var(--ok-bg); color: var(--ok); }
.badge.failed, .badge.offline { background: var(--err-bg); color: var(--err-ink); }
.badge.running, .badge.processing { background: var(--info-bg); color: var(--info); }
.badge.queued, .badge.pending, .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.off { background: var(--surface-2); color: var(--muted); }
.badge.brand { background: var(--brand-soft); color: var(--brand-ink); }

/* segmented control (from <select data-seg>) */
.seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.seg button { border: 0; background: transparent; color: var(--muted); padding: .38rem .75rem; border-radius: 7px; font: 500 .84rem/1.3 var(--font); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }

/* quick command buttons */
.quick { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.quick form { margin: 0; }

/* login (the core's /login and each module's own <module address>/login). Safe areas: an app
   installed on the iPhone draws under the notch and the home bar (viewport-fit=cover). */
.auth { min-height: 100dvh; display: grid; place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left)); background:
  radial-gradient(60rem 30rem at 10% -10%, var(--glow-1) 0, transparent 60%), radial-gradient(50rem 30rem at 110% 110%, var(--glow-2) 0, transparent 60%), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 2rem 1.9rem 1.7rem; }
.auth-card .ux-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 1.2rem; }
.auth-card h1 { margin-top: 1.1rem; font-size: 1.35rem; }
.auth-card .sub { color: var(--muted); font-size: .88rem; margin-top: .25rem; }
.auth-card form { margin-top: 1.1rem; }
.auth-foot { margin-top: 1.25rem; text-align: center; color: var(--subtle); font-size: .78rem; }
/* a module's login: its icon in the tile, and its own colour when config/modules.php gives one
   (<div class="auth accent" style="--accent: #16a34a">) in place of PVKhanh Auto's indigo */
.auth-app { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--brand); box-shadow: 0 6px 16px -6px var(--brand); }
.auth-app .ux-ico { width: 26px; height: 26px; }
.auth.accent { --brand: var(--accent); --brand-hover: color-mix(in srgb, var(--accent) 85%, #000);
  --brand-soft: color-mix(in srgb, var(--accent) 10%, var(--surface)); --brand-soft-2: color-mix(in srgb, var(--accent) 20%, var(--surface));
  --brand-ink: color-mix(in srgb, var(--accent) 70%, var(--text)); --brand-line: color-mix(in srgb, var(--accent) 40%, var(--surface));
  --glow-1: color-mix(in srgb, var(--accent) 16%, transparent); --glow-2: color-mix(in srgb, var(--accent) 9%, transparent); }
:root[data-theme="dark"] .auth.accent { --brand-hover: color-mix(in srgb, var(--accent) 80%, #fff); }
.auth.accent .btn.primary { box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.auth.accent input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
/* phones: 16px fields (smaller ones make iOS zoom in on focus), a button easy to tap */
@media (max-width: 640px), (pointer: coarse) {
  .auth-card input[type=text], .auth-card input[type=password] { min-height: 46px; font-size: 16px; }
  .auth-card .btn.lg { height: 48px; font-size: 1rem; }
}
@media (max-width: 480px) { .auth-card { padding: 1.6rem 1.25rem 1.4rem; border-radius: 16px; } }

/* home: app tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
a.tile { display: flex; flex-direction: column; gap: .9rem; padding: 1.3rem 1.35rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.tile:hover { border-color: var(--brand-line); box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }
.tile-top { display: flex; align-items: center; gap: .85rem; }
.tile-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.tile-ico .ux-ico { width: 22px; height: 22px; }
.tile h2 { margin: 0; font-size: 1.02rem; color: var(--text); }
.tile p { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.tile-meta { margin-top: auto; padding-top: .8rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; font-size: .8rem; color: var(--muted); }
.tile-go { margin-left: auto; color: var(--subtle); transition: color .15s, transform .15s; }
a.tile:hover .tile-go { color: var(--brand); transform: translateX(2px); }

/* pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1rem; }
