/* design.css - portal components (client + admin pages).
   Loaded AFTER index.css: the homepage file supplies the base look (font, colours,
   headings, header, buttons, section titles, icon boxes, footer), so every page matches it.
   Contents: 1 tokens, 2 shell, 3 header extras, 4 buttons, 5 forms, 6 alerts, 7 badges,
   8 layout + cards, 9 stat cards, 10 tables, 11 helpers, small screens. */

/* 1. Extra tokens. The base tokens (--bg --ink --mut --line --ac --f --r --px ...) come from index.css. */
:root {
  --ac-line: #d9e0ff;
  --line-strong: #cfd6e4;
  --ok-text: #11803a;
  --ok-soft: #e8f7ee;
  --warn-text: #a76500;
  --warn-soft: #fff6e5;
  --bad-text: #b42332;
  --bad-soft: #fff1f2;
  --bad-line: #ffd2d7;
  --r-sm: 10px;
  --shadow: 0 24px 56px rgba(16, 24, 40, .09);
}

/* 2. Page shell: footer always sits at the bottom */
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; min-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 3. Header extras (logo, nav, .btn, .menu come from index.css) */
.user-chip { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .95rem; }
.credit-chip { cursor: default; user-select: none; display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 8px; background: var(--ac-soft); border: 1px solid var(--ac-line); color: var(--ac); font-size: .95rem; font-weight: 700; white-space: nowrap; }
.credit-chip b { font-weight: 700; }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--ac-soft); color: var(--ac); display: grid; place-items: center; font-size: .85rem; font-weight: 700; }
.nav-btn { display: block; width: 100%; padding: 14px 0; border: 0; background: none; text-align: left; font: inherit; font-weight: 600; color: var(--bad-text); cursor: pointer; }

/* 4. Button variants (base .btn and .btn.p come from index.css) */
.btn-sm { height: 38px; padding: 0 16px; border-radius: 8px; font-size: .95rem; }
.btn-danger { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-text); }
.btn-danger:hover { border-color: var(--bad-text); }
.btn-success { background: var(--ok-soft); border-color: #bfe8cf; color: var(--ok-text); }
.btn-success:hover { border-color: var(--ok-text); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--line); }
.btn.p[disabled]:hover { border-color: var(--ac); }

/* 5. Forms */
.field { display: flex; flex-direction: column; gap: 8px; }
.stack { display: grid; gap: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
label { font-size: .95rem; font-weight: 700; }
input, select, textarea { width: 100%; height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--white); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
select { appearance: none; padding-right: 42px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6577' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; cursor: pointer; }
textarea { height: auto; min-height: 110px; padding: 12px 16px; resize: vertical; line-height: 1.5; }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--ac); }
input::placeholder, textarea::placeholder { color: #98a2b3; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ac); box-shadow: 0 0 0 4px var(--ac-soft); }
input:disabled, select:disabled { background: var(--bg); color: var(--mut); cursor: not-allowed; }
.hint { color: var(--mut); font-size: .88rem; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }

/* 6. Alerts. JavaScript builds: <div class="alert alert-error|ok|warn"><span class="alert-ic"></span><span>text</span></div> */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; margin-bottom: 20px; border-radius: var(--r-sm); border: 1px solid transparent; border-left-width: 4px; font-size: .95rem; font-weight: 600; line-height: 1.5; }
.alert-ic { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: currentColor; font-size: .85rem; font-weight: 800; line-height: 1; }
.alert-ic::before { content: "!"; color: #fff; }
.alert-ok .alert-ic::before { content: "\2713"; }
.alert-error { background: var(--bad-soft); border-color: var(--bad-line); border-left-color: var(--bad-text); color: var(--bad-text); }
.alert-ok { background: var(--ok-soft); border-color: #bfe8cf; border-left-color: var(--ok-text); color: var(--ok-text); }
.alert-warn { background: var(--warn-soft); border-color: #fde3b0; border-left-color: var(--warn-text); color: var(--warn-text); }
.alert > span:last-child { color: var(--ink); font-weight: 600; }
.notice { padding: 14px 18px; border-radius: var(--r-sm); background: var(--ac-soft); border: 1px solid var(--ac-line); color: var(--mut); font-size: .95rem; }

/* 7. Badges + account status (JavaScript adds badge-success | badge-warning | badge-danger | badge-blue) */
.badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 8px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.badge-success { background: var(--ok-soft); color: var(--ok-text); }
.badge-warning { background: var(--warn-soft); color: var(--warn-text); }
.badge-danger { background: var(--bad-soft); color: var(--bad-text); }
.badge-blue { background: var(--ac-soft); color: var(--ac); }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 8px; font-size: .85rem; font-weight: 700; text-transform: capitalize; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-active { background: var(--ok-soft); color: var(--ok-text); }
.status-suspended { background: var(--bad-soft); color: var(--bad-text); }
.status-unknown { background: var(--bg); color: var(--mut); border: 1px solid var(--line); }

/* 8. Page layout + cards */
/* Title band: white strip with top/bottom lines, like the homepage .white sections */
.band { background: var(--white); border-block: 1px solid var(--line); padding: 48px 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); margin-bottom: 12px; }
.page-head p { color: var(--mut); font-size: 1.05rem; max-width: 40em; }
.page-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.page { padding-top: 48px; padding-bottom: var(--s); }
.sh h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); margin-bottom: 12px; }
/* Section heading (.sh from index.css) with a button/count on the right */
.sh-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 48px; }
.sh-row .sh { margin-bottom: 0; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 28px 32px; }
.card + .card { margin-top: 20px; }
.card h3 { font-size: 1.2rem; margin-bottom: 6px; }
.card h2 { font-size: 1.2rem; }
.card-sub { color: var(--mut); font-size: .95rem; margin-bottom: 24px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.card-head .card-sub { margin-bottom: 0; }
.cols-2 > *, .ins > *, .panels > *, .card { min-width: 0; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.cols-2 > .card + .card { margin-top: 0; }
.num { display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 14px; border-radius: 50%; background: var(--ac); color: #fff; font-weight: 800; }
.card .card-sub:last-child { margin-bottom: 0; }
.form-grid + .btn { margin-top: 24px; }

/* 9. Stat cards: same icon box + text sizes as the homepage (.sum / .why) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat { display: flex; align-items: center; gap: 20px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 24px 28px; }
.stat .ic { flex: none; width: 48px; height: 48px; border-radius: 10px; background: var(--ac-soft); color: var(--ac); display: grid; place-items: center; }
.stat svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat span { display: block; color: var(--mut); font-size: .88rem; line-height: 1.3; margin-bottom: 3px; }
.stat strong { display: block; font-size: 1.08rem; font-weight: 700; line-height: 1.35; }

/* 10. Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--white); }
table { width: 100%; min-width: 640px; border-collapse: collapse; }
th { padding: 12px 14px; background: var(--bg); border-bottom: 1px solid var(--line-strong); border-right: 1px solid var(--line); text-align: left; font-size: .85rem; font-weight: 700; color: var(--mut); white-space: nowrap; }
td { padding: 14px 14px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); font-size: .95rem; color: var(--mut); vertical-align: middle; white-space: nowrap; }
td:first-child, td strong, td .person-copy strong { color: var(--ink); }
td.long, td small { white-space: normal; }
td.long { min-width: 240px; }
td strong + .muted { margin-left: 4px; }
th:last-child, td:last-child { border-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfe; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
td small { display: block; color: var(--mut); font-size: .88rem; line-height: 1.4; }
td textarea { min-height: 76px; min-width: 240px; }
.empty { padding: 44px 20px; text-align: center; color: var(--mut); }
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 1.05rem; }

/* 11. Small helpers used by JavaScript-built rows */
.help { color: var(--mut); font-size: .88rem; }
.muted { color: var(--mut); font-size: .88rem; }
.positive { color: var(--ok-text); font-weight: 700; }
.negative { color: var(--bad-text); font-weight: 700; }
.person { display: flex; align-items: center; gap: 12px; }
.person-copy strong { display: block; margin-bottom: 3px; line-height: 1.3; }
.person-copy small { display: block; margin-top: 2px; color: var(--mut); font-size: .88rem; line-height: 1.4; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-action { color: var(--ac); font-size: .85rem; font-weight: 700; white-space: nowrap; }
.link-action:hover { text-decoration: underline; }

/* Row under a table: record count + pagination */
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 16px; color: var(--mut); font-size: .9rem; }

@media (max-width: 1320px) {
  .user-chip .name { display: none; }
}
/* Admin menu has 7 links, so it collapses earlier than the homepage menu */
@media (max-width: 1180px) {
  .main-nav { display: none; position: absolute; left: 0; right: 0; top: 72px; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px var(--px) 24px; }
  .main-nav.open { display: block; }
  .main-nav ul { flex-direction: column; gap: 0; }
  .main-nav a { padding: 14px 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  .main-nav a[aria-current] { background: none; }
  .main-nav a[aria-current]::after { display: none; }
  .main-nav a:hover { background: none; }
  .menu { display: block; }
  .nav { gap: 12px; }
}
@media (max-width: 1000px) {
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .band { padding: 36px 0; }
  .page { padding-top: 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 22px 20px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 12px; padding: 18px; }
}
@media (max-width: 600px) {
  .user-chip .avatar { display: none; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}
.logo { white-space: nowrap; }

/* Terminal box that shows an installation command (new installation page + saved-command dialog) */
.term { overflow: hidden; border-radius: var(--r-sm); background: var(--ink); }
.tbar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; border-bottom: 1px solid #1f2a44; color: #aab4c8; font-size: .88rem; }
.tbar i { width: 10px; height: 10px; border-radius: 50%; background: #2b3957; }
.tbar span { flex: 1; margin-left: 6px; }
.term code { display: block; padding: 18px; min-height: 110px; color: #cfe0ff; font: 500 .85rem/1.7 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; overflow-wrap: anywhere; white-space: pre-wrap; }
.term .btn-sm { height: 30px; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.term .btn-sm:hover { background: rgba(255, 255, 255, .2); border-color: #fff; }

/* Dialog (pop-up) */
dialog { margin: auto; width: min(720px, calc(100% - 32px)); padding: 32px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--white); color: var(--ink); box-shadow: 0 24px 60px rgba(16, 24, 40, .25); }
dialog::backdrop { background: rgba(16, 24, 40, .55); }
dialog h3 { margin-bottom: 6px; font-size: 1.2rem; font-weight: 800; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 20px; }

/* "← Back to ..." link above a page title */
.back-link { display: inline-block; margin-bottom: 12px; color: var(--ac); font-weight: 700; font-size: .95rem; }
.back-link:hover { text-decoration: underline; }

/* Notification bell (client + admin header) and toast */
.bell-wrap { position: relative; }
.bell { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--white); color: var(--ink); cursor: pointer; }
.bell:hover { border-color: var(--ac); color: var(--ac); }
.bell svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bell-count { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--bad-text); color: #fff; font-size: .72rem; font-weight: 800; line-height: 20px; text-align: center; }
.bell-pop { position: absolute; right: 0; top: calc(100% + 10px); z-index: 60; width: min(380px, calc(100vw - 32px)); border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--white); box-shadow: 0 24px 60px rgba(16, 24, 40, .2); overflow: hidden; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.bell-head .link-action { background: none; border: 0; cursor: pointer; font-family: inherit; }
.bell-list { max-height: 380px; overflow-y: auto; list-style: none; margin: 0; padding: 0; }
.bell-list li { border-bottom: 1px solid var(--line); }
.bell-list li:last-child { border-bottom: 0; }
.bell-list a { display: block; padding: 14px 18px; color: var(--ink); }
.bell-list a:hover { background: var(--ac-soft); }
.bell-list .n-title { display: block; font-weight: 700; font-size: .95rem; line-height: 1.4; }
.bell-list .n-body { display: block; margin-top: 3px; color: var(--mut); font-size: .88rem; line-height: 1.5; }
.bell-list .n-time { display: block; margin-top: 6px; color: var(--mut); font-size: .8rem; }
.bell-list li.unread a { box-shadow: inset 3px 0 0 var(--ac); background: var(--ac-soft); }
.bell-list li.unread .n-title::after { content: ''; display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: var(--ac); }
.bell-empty { padding: 28px 18px; color: var(--mut); text-align: center; font-size: .95rem; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.toast { display: block; padding: 14px 18px; border: 1px solid var(--ac-line); border-radius: var(--r-sm); background: var(--white); box-shadow: 0 16px 40px rgba(16, 24, 40, .2); color: var(--ink); }
.toast strong { display: block; font-size: .95rem; }
.toast span { display: block; margin-top: 3px; color: var(--mut); font-size: .88rem; line-height: 1.5; }
@media (max-width: 600px) {
  .nav, .nav-r, .user-chip { gap: 6px; }
  .credit-chip { padding: 6px 8px; font-size: .85rem; }
  .bell { width: 38px; height: 38px; }
  .bell-pop { position: fixed; left: 16px; right: 16px; top: 76px; width: auto; }
}
