/* controlpanelos — Control Panel and Server Admin.
   Plain CSS, no build step. The CSP forbids inline styles, so every visual
   state is a class. Theme: html[data-theme="light"|"dark"], or the system
   preference when the attribute is empty. */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --surface-3: #e9edf3;
  --border: #e4e8ef;
  --border-strong: #d2d9e3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent-cpanel: #5b5bf0;
  --accent-whm: #0d9488;
  --on-accent: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 5%);
  --shadow: 0 1px 2px rgb(15 23 42 / 4%), 0 4px 16px -4px rgb(15 23 42 / 8%);
  --shadow-lg: 0 24px 48px -12px rgb(15 23 42 / 18%);
  --topbar-bg: rgb(255 255 255 / 78%);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --accent: var(--accent-cpanel);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0d14;
    --surface: #111622;
    --surface-2: #161c2a;
    --surface-3: #1d2536;
    --border: #222b3c;
    --border-strong: #2e394d;
    --text: #e7ecf3;
    --text-2: #c3cddb;
    --muted: #8a97ab;
    --accent-cpanel: #8b8cfb;
    --accent-whm: #2dd4bf;
    --on-accent: #0a0d14;
    --ok: #4ade80;
    --warn: #fbbf24;
    --danger: #f87171;
    --info: #60a5fa;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgb(255 255 255 / 3%) inset, 0 8px 24px -12px rgb(0 0 0 / 60%);
    --shadow-lg: 0 24px 60px -12px rgb(0 0 0 / 70%);
    --topbar-bg: rgb(13 17 26 / 78%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0d14;
  --surface: #111622;
  --surface-2: #161c2a;
  --surface-3: #1d2536;
  --border: #222b3c;
  --border-strong: #2e394d;
  --text: #e7ecf3;
  --text-2: #c3cddb;
  --muted: #8a97ab;
  --accent-cpanel: #8b8cfb;
  --accent-whm: #2dd4bf;
  --on-accent: #0a0d14;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgb(255 255 255 / 3%) inset, 0 8px 24px -12px rgb(0 0 0 / 60%);
  --shadow-lg: 0 24px 60px -12px rgb(0 0 0 / 70%);
  --topbar-bg: rgb(13 17 26 / 78%);
  color-scheme: dark;
}

.theme-cpanel { --accent: var(--accent-cpanel); }
.theme-whm { --accent: var(--accent-whm); }

body {
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-softer: color-mix(in srgb, var(--accent) 6%, transparent);
  --accent-hover: color-mix(in srgb, var(--accent) 86%, var(--text));
  --ok-soft: color-mix(in srgb, var(--ok) 13%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 14%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 12%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 12%, transparent);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1rem; font-weight: 650; margin-bottom: .9rem; }
p { margin: 0; }
code { font: .86em ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); padding: .1rem .38rem; border-radius: 6px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

/* --- Buttons and forms --------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.4rem; padding: .45rem 1rem;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 1px 2px rgb(0 0 0 / 10%), 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-warn { background: var(--warn); border-color: transparent; color: #fff; }
.btn-warn:hover { background: color-mix(in srgb, var(--warn) 88%, #000); }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); border-color: transparent; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-small { min-height: 2rem; padding: .25rem .7rem; font-size: .84rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-topbar { min-height: 2.1rem; padding: .3rem .85rem; font-size: .86rem; }

label { display: block; font-weight: 600; font-size: .86rem; color: var(--text-2); margin: 1rem 0 .4rem; }
input, select, textarea {
  width: 100%; min-height: 2.5rem; padding: .5rem .75rem;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=file] { padding: .4rem; }
.hint { color: var(--muted); font-size: .83rem; margin-top: .4rem; }
.form h2 { margin-top: 1.5rem; }
.form h2:first-of-type { margin-top: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.4rem; }
.input-group { display: flex; gap: .4rem; align-items: stretch; }
.input-group input { flex: 1; min-width: 0; }
.input-group .btn-ghost { padding: .45rem .65rem; font-size: .84rem; border-color: var(--border-strong); }
.input-prefix { display: flex; align-items: center; padding: 0 .7rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: .88rem; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 0 1.1rem; }
.field.wide { grid-column: 1 / -1; }
label.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; color: var(--text); margin: .55rem 0; cursor: pointer; }
label.check input, .tr input[type=checkbox] { width: 1.05rem; height: 1.05rem; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); flex: none; box-shadow: none; }
.static-label { display: block; font-weight: 600; font-size: .86rem; margin: 1rem 0 .4rem; }
.static-value { padding: .5rem 0; }
textarea { min-height: 8rem; font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace; font-size: .85rem; resize: vertical; }

/* --- Alerts, badges, pills ------------------------------------------------ */

.alert { display: block; border: 1px solid transparent; border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1.1rem; font-size: .92rem; }
.alert ul { margin: 0; padding-left: 1.1rem; }
.alert p { margin-top: .35rem; }
.alert-success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, transparent); }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .76rem; font-weight: 650; white-space: nowrap; color: var(--text-2); }
.badge-ok, .badge-danger, .badge-warn { border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-ok::before, .badge-danger::before, .badge-warn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-plain { background: var(--surface-2); }

.pills { display: inline-flex; gap: .2rem; padding: .2rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.pill { padding: .3rem .8rem; border-radius: 8px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.pill:hover { text-decoration: none; color: var(--text); }
.pill.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.banner { padding: .55rem 1rem; background: var(--warn-soft); color: var(--text); border-bottom: 1px solid var(--border); font-size: .88rem; text-align: center; }
.banner-danger { background: var(--danger-soft); }

/* --- Layout --------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  height: 60px; padding: 0 1.25rem;
  background: var(--topbar-bg); color: var(--text);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.topbar-brand { display: flex; align-items: center; gap: .65rem; min-width: 0; color: var(--text); font-size: .98rem; }
.topbar-brand:hover { text-decoration: none; }
.topbar-tag { padding: .12rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .74rem; font-weight: 650; }
.topbar-search { max-width: 380px; min-height: 2.25rem; margin-left: 1.25rem; background: var(--surface-2); border-color: var(--border); border-radius: 999px; padding-left: 1rem; }
.topbar-right { display: flex; align-items: center; gap: .6rem; margin-left: auto; min-width: 0; }
.topbar-right form { margin: 0; }
.topbar-meta { color: var(--muted); font-size: .84rem; padding-right: .25rem; }
.topbar-user { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .9rem; }
.topbar-user::before { content: ""; width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #ec4899)); }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #06b6d4));
  color: #fff; font-weight: 800; font-size: .78rem; letter-spacing: .02em;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 80%, transparent);
}
.nav-toggle { display: none; min-height: 2.1rem; padding: .3rem .75rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }

.theme-toggle {
  display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text-2); cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle::before { content: ""; width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.theme-toggle[data-mode="system"] { --icon: var(--icon-monitor); }
.theme-toggle[data-mode="light"] { --icon: var(--icon-sun); }
.theme-toggle[data-mode="dark"] { --icon: var(--icon-moon); }

.shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sidebar { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); overflow-y: auto; padding: 1rem .8rem 2rem; background: var(--surface); border-right: 1px solid var(--border); scrollbar-width: thin; }
.nav-search { min-height: 2.25rem; margin-bottom: .5rem; font-size: .88rem; background: var(--surface-2); border-color: var(--border); }
.nav-group { margin-top: 1.1rem; }
.nav-title { display: block; padding: 0 .65rem .35rem; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.nav-link { position: relative; display: flex; align-items: center; gap: .65rem; padding: .48rem .65rem; border-radius: 9px; color: var(--text-2); font-size: .9rem; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-link.active::after { content: ""; position: absolute; left: -.8rem; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }

.content { padding: 1.75rem 2rem 3rem; min-width: 0; max-width: 1480px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-head p { margin-top: .3rem; }

.ssl-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  border-radius: var(--radius-lg);
  background: radial-gradient(ellipse at right top, #214866, transparent 70%), #111c32;
  color: #f7faff;
}
.ssl-hero .crumb, .ssl-hero p { color: #c4d6ee; }
.ssl-hero h1 { margin: .45rem 0 .3rem; font-size: clamp(1.75rem, 3vw, 2.65rem); letter-spacing: -.045em; }
.ssl-hero p { margin: 0; }
.ssl-hero-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 5rem;
  height: 5rem;
  border: 1px solid #7094ae66;
  border-radius: 1.4rem;
  background: #92c6ed1a;
  color: #b1e1ff;
}
.ssl-hero-mark.icon::before { width: 2.5rem; height: 2.5rem; }
.ssl-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}
.ssl-stat, .ssl-inventory {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.ssl-stat {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: .8rem;
  padding: 1rem 1.2rem;
}
.ssl-stat-icon, .ssl-domain-icon {
  display: grid;
  place-items: center;
  width: 2.45rem;
  height: 2.45rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.ssl-stat-icon { grid-row: span 2; }
.ssl-stat-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.ssl-stat-value { color: var(--text); font-size: 1.55rem; line-height: 1.2; }
.ssl-inventory-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  padding: 1.2rem 1.4rem;
}
.ssl-inventory-head h2 { margin: 0 0 .25rem; }
.ssl-inventory-head p { margin: 0; color: var(--muted); }
.ssl-columns, .ssl-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.4fr) minmax(6rem, .75fr) minmax(10.5rem, auto);
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.4rem;
}
.ssl-columns {
  background: var(--surface-2);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ssl-list { margin: 0; padding: 0; list-style: none; }
.ssl-row { min-height: 4.9rem; border-top: 1px solid var(--border); }
.ssl-domain { display: flex; align-items: center; gap: .65rem; overflow-wrap: anywhere; }
.ssl-domain-icon { flex: none; background: var(--surface-2); color: var(--muted); }
.ssl-domain strong, .ssl-domain div span { display: block; }
.ssl-domain div span, .ssl-expiry { color: var(--muted); font-size: .82rem; }
.ssl-status { white-space: normal; }
.ssl-status::before { flex: none; }
.ssl-status.badge-ok { color: color-mix(in srgb, var(--ok) 65%, var(--text)); }
.ssl-status.badge-warn { color: color-mix(in srgb, var(--warn) 65%, var(--text)); }
.ssl-status.badge-danger { color: color-mix(in srgb, var(--danger) 70%, var(--text)); }
.ssl-expiry-label { display: none; }
.ssl-empty { margin: 0; padding: 1.5rem 1.4rem; border-top: 1px solid var(--border); color: var(--muted); }
.ssl-note {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin-top: 1rem;
  padding: .85rem 1rem;
  background: var(--accent-softer);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
}
.ssl-note p { margin: 0; font-size: .875rem; }

.terminal-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; margin-bottom: .9rem; }
#terminal-screen { position: relative; min-width: 0; overflow: hidden; padding: 10px; border-radius: var(--radius); background: #101827; }
#terminal-screen .xterm { height: 100%; }
.terminal-measure { position: absolute; visibility: hidden; font: 14px monospace; }

@media (max-width: 900px) {
  .ssl-columns { display: none; }
  .ssl-row { grid-template-columns: minmax(0, 1fr) auto; gap: .65rem 1rem; }
  .ssl-domain { grid-column: 1 / -1; }
  .ssl-expiry-label { display: inline; margin-right: .3rem; }
}
@media (max-width: 520px) {
  .ssl-hero-mark { display: none; }
  .ssl-stats { gap: .5rem; }
  .ssl-stat { grid-template-columns: minmax(0, 1fr); row-gap: .25rem; padding: .65rem; }
  .ssl-stat-icon { grid-row: auto; width: 1.8rem; height: 1.8rem; }
  .ssl-stat-label { min-height: 2.4em; line-height: 1.2; }
  .ssl-row { grid-template-columns: minmax(0, 1fr); }
  .ssl-inventory-head, .ssl-row { padding-inline: 1rem; }
}
.crumb { display: inline-flex; align-items: center; gap: .3rem; font-size: .82rem; font-weight: 600; margin-bottom: .35rem; }
.crumb::before { content: "←"; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.3rem 1.4rem; margin-bottom: 1.25rem; min-width: 0; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-narrow { max-width: 680px; }
.panel-danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: linear-gradient(var(--danger-soft), transparent 40%), var(--surface); }
.panel-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
.panel p.muted { margin-bottom: .75rem; }
.grid-1 { display: block; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; align-items: start; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.1rem; }
.toolbar > .muted { flex: 1; min-width: 240px; }
.search { display: flex; gap: .4rem; flex: 1; min-width: 260px; max-width: 480px; }
.empty { padding: 2.25rem 1.25rem; color: var(--muted); text-align: center; }
.lead { color: var(--muted); margin: -.6rem 0 1.4rem; max-width: 80ch; }
.block-head { margin-bottom: 1rem; }
.block-head h2 { margin-bottom: .2rem; }
.block-head p.muted { margin-bottom: 0; }
.panel-flush .block-head { padding: 1.2rem 1.4rem .2rem; margin-bottom: .5rem; }

/* --- Dashboard pieces ---------------------------------------------------- */

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: .15rem;
  padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); color: var(--text);
  transition: border-color .15s, transform .15s;
}
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(var(--accent-soft), transparent 70%); }
.stat:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); text-decoration: none; transform: translateY(-1px); }
.stat-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 500; }
.stat-warn .stat-value { color: var(--danger); }
.stat-warn::after { background: radial-gradient(var(--danger-soft), transparent 70%); }

.kv-row { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.kv-row:last-child { border-bottom: 0; }
.kv-key { color: var(--muted); }
.kv-value { text-align: right; overflow-wrap: anywhere; font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; flex-direction: column; padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.list li:last-child { border-bottom: 0; }
.list .muted { font-size: .82rem; }

.meter-row { margin-bottom: .95rem; }
.meter-label { display: flex; justify-content: space-between; gap: 1rem; font-size: .86rem; margin-bottom: .35rem; }
.meter { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ok), color-mix(in srgb, var(--ok) 70%, #06b6d4)); }
.meter-warn .meter-fill { background: linear-gradient(90deg, var(--warn), color-mix(in srgb, var(--warn) 70%, #ef4444)); }
.meter-danger .meter-fill { background: var(--danger); }

.account-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.account-head h2 { font-size: 1.35rem; margin-bottom: .3rem; }
.account-head p.muted { margin-bottom: .15rem; }
.account-status { display: flex; align-items: center; gap: .75rem; }
.account-status form { margin: 0; }
.quick-links { display: flex; flex-wrap: wrap; gap: .5rem; margin: -.4rem 0 1.25rem; }

.tabs { display: flex; gap: .2rem; margin-bottom: 1.4rem; padding: .25rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); overflow-x: auto; width: fit-content; max-width: 100%; }
.tab { padding: .45rem .9rem; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: .88rem; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: .6rem; }
.link-card { display: flex; flex-direction: column; gap: .2rem; padding: .85rem .95rem; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.link-card:hover { border-color: var(--accent); text-decoration: none; }
.code-block { display: block; white-space: pre-wrap; overflow-x: auto; padding: 1rem 1.1rem; line-height: 1.6; font-size: .8rem; border-radius: var(--radius); background: var(--surface-2); }
code.secret { display: block; margin-top: .5rem; padding: .65rem .85rem; font-size: .92rem; overflow-wrap: anywhere; user-select: all; }
.text-line { margin-bottom: .55rem; color: var(--muted); }

/* --- Tables (div grids; the template language has no <table>) ------------ */

.table-scroll { overflow-x: auto; }
.table { --cols: repeat(4, minmax(0, 1fr)); min-width: 100%; }
.tr { display: grid; grid-template-columns: var(--cols); gap: .75rem; align-items: center; padding: .75rem 1.4rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.tr:last-child { border-bottom: 0; }
.tr > span { min-width: 0; overflow-wrap: anywhere; }
.th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding-top: .6rem; padding-bottom: .6rem; }
.tr:not(.th) { transition: background .12s; }
.tr:not(.th):hover { background: var(--accent-softer); }
.tr-warn { background: var(--warn-soft); }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.row-actions form { margin: 0; }
.table-foot { padding: .7rem 1.4rem; color: var(--muted); font-size: .84rem; border-top: 1px solid var(--border); }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; padding: 1rem 1.4rem; border-top: 1px solid var(--border); background: var(--surface-2); }
.bulk-bar .field { min-width: 200px; }
.bulk-bar label { margin-top: 0; }
.bulk-bar > .muted { align-self: center; }

.cols-accounts { --cols: 1.4fr .8fr 1.4fr .8fr 1fr 1.1fr .8fr 1.3fr; min-width: 1040px; }
.cols-packages { --cols: 1fr .8fr .9fr .6fr .7fr .5fr .8fr .6fr 1.1fr; min-width: 900px; }
.cols-activity { --cols: 1.2fr .8fr 1.5fr .8fr 1.3fr .9fr; min-width: 860px; }
.cols-admins { --cols: 1fr 1.2fr 1.2fr .8fr; }
.cols-n3 { --cols: minmax(0, 1.6fr) minmax(0, 1fr) auto; }
.cols-n4 { --cols: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)) auto; min-width: 560px; }
.cols-n5 { --cols: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)) auto; min-width: 680px; }
.cols-n6 { --cols: minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)) auto; min-width: 780px; }
.cols-files { --cols: 2rem minmax(0, 2.4fr) .7fr 1.2fr .5fr minmax(0, 2fr); min-width: 900px; }

/* --- Control Panel home --------------------------------------------------- */

.cp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 1.25rem; align-items: start; }
.cp-side { position: sticky; top: 80px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 165px), 1fr)); gap: .5rem; }
.tool { display: flex; align-items: center; gap: .75rem; padding: .65rem; border: 1px solid transparent; border-radius: var(--radius); color: var(--text); font-size: .9rem; font-weight: 500; transition: background .15s, border-color .15s; }
.tool:hover { background: var(--accent-softer); border-color: var(--accent-soft); text-decoration: none; }
.tool-icon { flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); position: relative; transition: transform .15s; }
.tool:hover .tool-icon { transform: scale(1.06); }
.tool-icon::after { content: ""; position: absolute; inset: 10px; background: var(--accent); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }

/* Solutions: full-colour product logos, on white so they read in both themes. */
.icon-sol-receiptspos { --logo: url("/public/solutions/receiptspos.png"); --logo-size: 86%; }
.icon-sol-paid2marketing { --logo: url("/public/solutions/paid2marketing.png"); --logo-size: 78%; }
.icon-sol-domaincubex { --logo: url("/public/solutions/domaincubex.png"); --logo-size: 100%; }
.icon-sol-bizmail { --logo: url("/public/solutions/bizmail.png"); --logo-size: 80%; }
.icon-sol-origincrm { --logo: url("/public/solutions/origincrm.png"); --logo-size: 100%; }
.tool-icon[class*="icon-sol-"] { background: #fff var(--logo) center / var(--logo-size) no-repeat; border: 1px solid var(--border); overflow: hidden; }
.tool-icon[class*="icon-sol-"]::after { display: none; }
.icon[class*="icon-sol-"]::before { -webkit-mask: none; mask: none; opacity: 1; border-radius: 4px; background: #fff var(--logo) center / var(--logo-size) no-repeat; }
.solution-head { display: flex; align-items: flex-start; gap: 1rem; min-width: 0; }
.tool-icon.solution-logo { width: 64px; height: 64px; border-radius: 16px; }
.solution-status { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.solution-status h2 { margin-bottom: 0; }
.client-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--border); min-width: 0; }
.client-row p { margin-top: .15rem; }
.client-row > div { min-width: 0; overflow-wrap: anywhere; }
.client-row > .btn, .client-row > form, .client-row > .badge { flex: none; }

.workspace-head {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1.25rem;
  padding: clamp(1.25rem, 3vw, 2.25rem); margin-bottom: 1.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--radius-lg);
  background: radial-gradient(ellipse at top right, var(--accent-soft), transparent 70%), var(--surface);
}
.workspace-head h1 { font-size: clamp(1.65rem, 3vw, 2.35rem); overflow-wrap: anywhere; }
.workspace-head p { margin-top: .4rem; color: var(--muted); overflow-wrap: anywhere; }
.workspace-search { position: relative; width: min(100%, 19rem); }
.workspace-search input { min-height: 2.85rem; padding-right: 2.8rem; }
.workspace-search .shortcut-key {
  position: absolute; inset-inline-end: .65rem; top: 50%; transform: translateY(-50%);
  padding: .05rem .4rem; border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface-2); color: var(--muted); pointer-events: none; font-family: monospace;
}
.admin-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.admin-stats .stat-value { line-height: 1.15; }
.admin-stats .stat-warn .tool-icon { background: var(--danger-soft); }
.admin-stats .stat-warn .tool-icon::after { background: var(--danger); }
.admin-section-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .4rem .75rem; margin-bottom: .85rem; }
.admin-section-head h2 { margin: 0; }
.admin-section-head a { font-size: .85rem; font-weight: 600; }
.admin-activity-search { margin-bottom: .4rem; }

/* --- Tweak Settings ----------------------------------------------------- */
.settings-jump {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin: 0 0 1.25rem; padding-block: .75rem;
  border-block: 1px solid var(--border);
}
.settings-jump a {
  padding: .35rem .65rem; border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-2); background: var(--surface); font-size: .85rem; font-weight: 600;
}
.settings-jump a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.settings-section {
  display: grid; grid-template-columns: minmax(9rem, 1fr) minmax(0, 3fr);
  align-items: start; gap: 1rem 1.5rem; box-shadow: none;
}
.settings-section:has(:target) { border-color: var(--accent); }
.settings-section .block-head { padding: 0; }
.settings-section .block-head h2 { margin: 0; font-size: 1.06rem; scroll-margin-top: 88px; }
.settings-section .field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem;
}
.settings-section .field-grid:has(.field:only-child) { grid-template-columns: minmax(0, 1fr); }
.settings-section .field { min-width: 0; }
.settings-section .field > label { margin-top: 0; }
.settings-section input[type="number"] { max-width: 18rem; }
.settings-section .field:has(.check) {
  padding: .7rem .85rem; background: var(--surface-2); border-radius: 8px;
}
.settings-section .field:has(.check) .hint { margin: .25rem 0 0 1.65rem; }
.settings-section .form-actions { border-top: 1px solid var(--border); padding-top: .8rem; margin-top: 1rem; }
@media (max-width: 720px) {
  .settings-section { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .settings-section .field-grid { grid-template-columns: minmax(0, 1fr); }
}

/* --- WHM workspace ------------------------------------------------------- */
.admin-workspace {
  --rail-width: 248px;
  --header-height: 64px;
  --accent: light-dark(#4f46d8, #a5a4ff);
  --bg: light-dark(#f5f6fb, #0c101a);
  --surface: light-dark(#fff, #141a28);
  --surface-2: light-dark(#f5f6fa, #1b2233);
  --surface-3: light-dark(#e9ebf4, #252e42);
  --border: light-dark(#e3e6ef, #282f42);
  --border-strong: light-dark(#d5d9e6, #39435a);
}

.admin-workspace .topbar {
  height: var(--header-height);
  background: var(--surface);
  padding-inline: clamp(.75rem, 2.5vw, 2rem);
}
.admin-workspace .topbar-brand { font-weight: 700; }
.admin-workspace .topbar-brand strong { display: inline; }
.admin-workspace .sidebar {
  padding: 1rem .85rem 1.75rem;
  scrollbar-color: var(--border-strong) transparent;
}
.workspace-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 42px;
  margin: 0 .2rem 1.3rem;
  color: var(--text);
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.workspace-brand:hover { color: var(--accent); text-decoration: none; }
.workspace-brand .brand-mark {
  flex: none;
  background: var(--accent);
  color: var(--on-accent);
}
.admin-nav-search { position: relative; }
.admin-nav-search .admin-search-key {
  position: absolute;
  top: 50%;
  right: .55rem;
  translate: 0 -50%;
  padding: .03rem .32rem;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--muted);
  pointer-events: none;
}
.admin-nav-search:focus-within .admin-search-key,
.admin-nav-search:has(input:not(:placeholder-shown)) .admin-search-key { display: none; }
.admin-workspace .nav-search { margin: 0; padding-inline-end: 2rem; }
.admin-workspace .nav-link { padding: .5rem .68rem; }
.admin-workspace .nav-link.active::after { display: none; }
.admin-workspace .content { width: 100%; margin-inline: auto; }
.admin-workspace .content:focus { outline: none; }
.admin-skip { position: fixed; z-index: 30; top: .75rem; left: .75rem; translate: 0 -200%; }
.admin-skip:focus { translate: none; padding: .55rem .85rem; background: var(--surface); }

.admin-workspace .admin-theme { width: auto; min-height: 2.35rem; font-size: .84rem; cursor: pointer; }
.admin-workspace .admin-theme:hover { background-color: var(--surface-2); }
.admin-profile { position: relative; }
.admin-profile .topbar-user:not([hidden]) {
  display: flex;
  gap: .5rem;
  padding: .2rem .5rem .2rem .25rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.admin-profile .topbar-user[hidden],
.admin-profile .topbar-user::before { display: none; }
.admin-profile .topbar-user::after {
  content: "";
  width: .38rem;
  height: .38rem;
  border: solid var(--muted);
  border-width: 0 1px 1px 0;
  rotate: 45deg;
  margin: 0 .12rem .2rem .12rem;
}
.admin-profile .topbar-user:hover,
.admin-profile .topbar-user[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border); }
.admin-avatar {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: .82rem;
}
.admin-user-name { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-profile.interactive .admin-profile-menu:not([hidden]) {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + .5rem);
  width: 12rem;
  display: grid;
  gap: .25rem;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.admin-profile:not(.interactive) :is(.admin-profile-name, a) { display: none; }
.admin-profile-name { padding: .35rem .55rem; color: var(--muted); overflow-wrap: anywhere; }
.admin-profile-menu a,
.admin-profile-menu .btn { width: 100%; justify-content: start; padding: .45rem .55rem; }
.admin-profile-menu a { color: var(--text); border-radius: 8px; }
.admin-profile-menu a:hover { background: var(--surface-2); text-decoration: none; }

.admin-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(110deg, var(--surface) 28%, color-mix(in srgb, var(--accent) 9%, var(--surface)));
}
.admin-head h1,
.admin-workspace .page-head h1 { font-size: clamp(1.65rem, 3vw, 2.3rem); letter-spacing: -.045em; }
.admin-host { display: flex; align-items: center; gap: .45rem; margin-top: .5rem; color: var(--muted); overflow-wrap: anywhere; }
.admin-host .icon { display: inline-flex; --icon: var(--icon-monitor); }
.admin-workspace .panel { box-shadow: var(--shadow-sm); }
.admin-workspace .kv-row { border-bottom-style: solid; }
.admin-workspace .kv-row:last-child { border-bottom: 0; }

.admin-stats .stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .3rem .6rem;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.admin-stats .stat:hover { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.admin-stats .stat::after { content: none; }
.admin-stats .tool-icon { grid-column: 2; grid-row: 1 / 3; margin: 0; }
.admin-stats .stat-label { grid-column: 1; }
.admin-stats .stat-value { grid-column: 1; overflow-wrap: anywhere; }
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  grid-template-areas: "activity insights" "accounts insights";
  grid-template-rows: auto 1fr;
  gap: 1rem;
  align-items: start;
}
.admin-grid .panel { margin: 0; }
.admin-activity { grid-area: activity; }
.admin-insights { grid-area: insights; display: grid; gap: 1rem; min-width: 0; }
.admin-accounts { grid-area: accounts; }
.admin-activity .list li { position: relative; padding-inline-start: 1.15rem; overflow-wrap: anywhere; }
.admin-activity .list li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 1.05rem;
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.admin-accounts .list li { padding: 0; }
.admin-account-link { display: flex; align-items: center; gap: .7rem; padding: .65rem .4rem; color: var(--text); border-radius: 8px; overflow-wrap: anywhere; }
.admin-account-link:hover { background: var(--surface-2); text-decoration: none; }
.admin-account-link .tool-icon { width: 34px; height: 34px; }
.admin-account-link .muted { display: block; }
.admin-meter { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: .6rem; align-items: start; }
.admin-meter > strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.admin-meter .meter-label { flex-wrap: wrap; gap: .15rem .5rem; }

@media (min-width: 901px) {
  .admin-workspace .topbar { margin-left: var(--rail-width); }
  .admin-workspace .shell { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
  .admin-workspace .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--rail-width); height: 100dvh; z-index: 21; }
  .admin-workspace .content { grid-column: 2; }
}
@media (max-width: 900px) {
  .admin-workspace .sidebar {
    top: var(--header-height);
    height: calc(100dvh - var(--header-height));
    transition: transform .2s;
  }
  .admin-workspace .sidebar.open + .content::before {
    content: "";
    position: fixed;
    inset: var(--header-height) 0 0;
    z-index: 14;
    background: rgb(9 12 23 / 50%);
  }
}
@media (max-width: 710px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "activity" "insights" "accounts"; }
  .admin-user-name { display: none; }
}
@media (max-width: 420px) {
  .admin-workspace .topbar { gap: .4rem; }
  .admin-workspace .topbar-right { gap: .35rem; }
  .admin-stats { gap: .6rem; }
  .admin-stats .stat { padding: .75rem; }
  .admin-stats .tool-icon { width: 30px; height: 30px; }
}


/* --- Icons --------------------------------------------------------------- */

.icon::before { content: ""; flex: none; width: 18px; height: 18px; background: currentColor; opacity: .8; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.nav-link.active.icon::before { opacity: 1; }

/* Icons: SVG data URIs used as masks (img-src allows data:). Generated. */
:root {
  --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E");
  --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z'/%3E%3C/svg%3E");
  --icon-monitor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='3' width='20' height='14' rx='2'/%3E%3Cpath d='M8 21h8M12 17v4'/%3E%3C/svg%3E");
}
.icon-home { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5V21h-6v-6H9v6H3z'/%3E%3C/svg%3E"); }
.icon-list { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E"); }
.icon-users { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='4'/%3E%3Cpath d='M2 21v-1a6 6 0 0 1 12 0v1M16 3.5a4 4 0 0 1 0 8M22 21v-1a6 6 0 0 0-4-5.6'/%3E%3C/svg%3E"); }
.icon-plus { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.icon-box { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8'/%3E%3C/svg%3E"); }
.icon-shield { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E"); }
.icon-key { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7.5' cy='15.5' r='4.5'/%3E%3Cpath d='m10.7 12.3 9.8-9.8M16 7l3 3M19 4l2 2'/%3E%3C/svg%3E"); }
.icon-mail { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m22 7-10 6L2 7'/%3E%3C/svg%3E"); }
.icon-forward { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 17 5-5-5-5M4 18v-2a4 4 0 0 1 4-4h12'/%3E%3C/svg%3E"); }
.icon-folder { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6a2 2 0 0 1 2-2h4l2 3h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E"); }
.icon-database { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='12' cy='5' rx='9' ry='3'/%3E%3Cpath d='M3 5v14c0 1.7 4 3 9 3s9-1.3 9-3V5M3 12c0 1.7 4 3 9 3s9-1.3 9-3'/%3E%3C/svg%3E"); }
.icon-branch { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='6' cy='6' r='2.5'/%3E%3Ccircle cx='6' cy='18' r='2.5'/%3E%3Ccircle cx='18' cy='8' r='2.5'/%3E%3Cpath d='M6 8.5v7M18 10.5c0 4-6 3-12 5'/%3E%3C/svg%3E"); }
.icon-globe { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M2 12h20M12 2a15 15 0 0 1 0 20M12 2a15 15 0 0 0 0 20'/%3E%3C/svg%3E"); }
.icon-clock { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 6v6l4 2'/%3E%3C/svg%3E"); }
.icon-settings { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z'/%3E%3C/svg%3E"); }
.icon-sliders { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6'/%3E%3C/svg%3E"); }
.icon-chart { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3v18h18M7 16v-5M12 16V8M17 16v-8'/%3E%3C/svg%3E"); }
.icon-alert { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.icon-network { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='2' width='6' height='6' rx='1'/%3E%3Crect x='2' y='16' width='6' height='6' rx='1'/%3E%3Crect x='16' y='16' width='6' height='6' rx='1'/%3E%3Cpath d='M12 8v4M5 16v-2h14v2'/%3E%3C/svg%3E"); }
.icon-lock { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E"); }
.icon-cpu { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='5' width='14' height='14' rx='2'/%3E%3Crect x='9' y='9' width='6' height='6'/%3E%3Cpath d='M9 2v3M15 2v3M9 19v3M15 19v3M2 9h3M2 15h3M19 9h3M19 15h3'/%3E%3C/svg%3E"); }
.icon-archive { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='3' width='20' height='5' rx='1'/%3E%3Cpath d='M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8M10 12h4'/%3E%3C/svg%3E"); }
.icon-layers { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 2 10 5-10 5L2 7z'/%3E%3Cpath d='m2 12 10 5 10-5M2 17l10 5 10-5'/%3E%3C/svg%3E"); }
.icon-check { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Cpath d='m8 12 3 3 5-6'/%3E%3C/svg%3E"); }
.icon-file { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3C/svg%3E"); }
.icon-link { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7'/%3E%3C/svg%3E"); }
.icon-upload { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12'/%3E%3C/svg%3E"); }
.icon-download { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3'/%3E%3C/svg%3E"); }
.icon-edit { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E"); }
.icon-rename { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='7' width='20' height='10' rx='2'/%3E%3Cpath d='M13 4h4M15 4v16M13 20h4M6 12h4'/%3E%3C/svg%3E"); }
.icon-trash { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E"); }
.icon-refresh { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-2.6-6.4L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E"); }
.icon-up { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M5 12l7-7 7 7'/%3E%3C/svg%3E"); }
.icon-image { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-5-5L5 21'/%3E%3C/svg%3E"); }
.icon-code { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m16 18 6-6-6-6M8 6l-6 6 6 6'/%3E%3C/svg%3E"); }

.icon-search { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E"); }

/* Meter widths in 5% steps (no inline styles under the CSP). */
.w0 { width: 0%; } .w5 { width: 5%; } .w10 { width: 10%; } .w15 { width: 15%; } .w20 { width: 20%; } .w25 { width: 25%; } .w30 { width: 30%; } .w35 { width: 35%; } .w40 { width: 40%; } .w45 { width: 45%; } .w50 { width: 50%; } .w55 { width: 55%; } .w60 { width: 60%; } .w65 { width: 65%; } .w70 { width: 70%; } .w75 { width: 75%; } .w80 { width: 80%; } .w85 { width: 85%; } .w90 { width: 90%; } .w95 { width: 95%; } .w100 { width: 100%; }

.cols-g2 { --cols: minmax(0, 1.4fr) repeat(1, minmax(0, 1fr)); min-width: 480px; }
.cols-g2.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(0, minmax(0, 1fr)); }
.cols-g3 { --cols: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); min-width: 480px; }
.cols-g3.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(1, minmax(0, 1fr)); }
.cols-g4 { --cols: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); min-width: 480px; }
.cols-g4.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); }
.cols-g5 { --cols: minmax(0, 1.4fr) repeat(4, minmax(0, 1fr)); min-width: 575px; }
.cols-g5.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); }
.cols-g6 { --cols: minmax(0, 1.4fr) repeat(5, minmax(0, 1fr)); min-width: 690px; }
.cols-g6.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(4, minmax(0, 1fr)); }
.cols-g7 { --cols: minmax(0, 1.4fr) repeat(6, minmax(0, 1fr)); min-width: 805px; }
.cols-g7.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(5, minmax(0, 1fr)); }
.cols-g8 { --cols: minmax(0, 1.4fr) repeat(7, minmax(0, 1fr)); min-width: 920px; }
.cols-g8.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(6, minmax(0, 1fr)); }
.cols-g9 { --cols: minmax(0, 1.4fr) repeat(8, minmax(0, 1fr)); min-width: 1035px; }
.cols-g9.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(7, minmax(0, 1fr)); }
.cols-g10 { --cols: minmax(0, 1.4fr) repeat(9, minmax(0, 1fr)); min-width: 1150px; }
.cols-g10.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(8, minmax(0, 1fr)); }
.cols-g11 { --cols: minmax(0, 1.4fr) repeat(10, minmax(0, 1fr)); min-width: 1265px; }
.cols-g11.has-select { --cols: 2.25rem minmax(0, 1.4fr) repeat(9, minmax(0, 1fr)); }

/* --- File Manager app (its own full-window layout) ------------------------ */

.fm-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.fm-top { display: flex; align-items: center; gap: 1rem; height: 58px; padding: 0 1.1rem; flex: none; background: var(--topbar-bg); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.fm-brand { display: flex; align-items: center; gap: .65rem; color: var(--text); }
.fm-brand:hover { text-decoration: none; }
.fm-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.fm-brand-text span { color: var(--muted); font-size: .78rem; }
.fm-filter { max-width: 340px; min-height: 2.2rem; margin-left: 1rem; border-radius: 999px; background: var(--surface-2); border-color: var(--border); padding-left: 1rem; }
.fm-top-right { display: flex; align-items: center; gap: .5rem; margin-left: auto; }

.fm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; padding: .55rem 1.1rem; flex: none; background: var(--surface); border-bottom: 1px solid var(--border); }
.fm-action-group { display: flex; align-items: center; gap: .25rem; padding-right: 1rem; border-right: 1px solid var(--border); }
.fm-action-group:last-child { border-right: 0; padding-right: 0; margin-left: auto; }
.fm-action { display: inline-flex; align-items: center; gap: .45rem; min-height: 2.1rem; padding: .3rem .7rem; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text-2); font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; }
.fm-action:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.fm-action.active { background: var(--accent-soft); color: var(--accent); }
.fm-action:disabled { opacity: .45; cursor: not-allowed; background: transparent; }
.fm-action-danger { color: var(--danger); }
.fm-action-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.fm-archive-name { width: 9.5rem; min-height: 2.1rem; padding: .3rem .6rem; font-size: .84rem; border-radius: 9px; }

.fm-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); flex: 1; min-height: 0; }
.fm-tree { overflow-y: auto; padding: .9rem .6rem; background: var(--surface); border-right: 1px solid var(--border); scrollbar-width: thin; }
.fm-tree-title { display: block; padding: 0 .6rem .45rem; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.fm-node { display: flex; align-items: center; gap: .5rem; padding-top: .32rem; padding-bottom: .32rem; padding-right: .6rem; border-radius: 8px; color: var(--text-2); font-size: .87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-node::before { color: var(--accent); opacity: .75; width: 16px; height: 16px; }
.fm-node:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.fm-node.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.fm-node.d0 { padding-left: 0.6rem; }
.fm-node.d1 { padding-left: 1.5rem; }
.fm-node.d2 { padding-left: 2.4rem; }
.fm-node.d3 { padding-left: 3.3000000000000003rem; }
.fm-node.d4 { padding-left: 4.2rem; }
.fm-node.d5 { padding-left: 5.1rem; }
.fm-node.d6 { padding-left: 6rem; }
.fm-node.d7 { padding-left: 6.8999999999999995rem; }
.fm-node.d8 { padding-left: 7.8rem; }
.fm-node.d9 { padding-left: 8.7rem; }
.fm-node.d10 { padding-left: 9.6rem; }

.fm-main { overflow-y: auto; padding: 1rem 1.25rem 1.5rem; min-width: 0; }
.fm-pathbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; font-size: .85rem; }
.fm-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem; padding: .2rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.fm-crumbs a { padding: .2rem .55rem; border-radius: 7px; color: var(--text-2); font-weight: 600; }
.fm-crumbs a:hover { background: var(--surface); text-decoration: none; }
.fm-crumbs a + a::before { content: "›"; margin-right: .5rem; color: var(--muted); font-weight: 400; }
.fm-crumbs a:last-child { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }

.fm-drawer { margin-bottom: 1rem; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.fm-drawer label:first-of-type { margin-top: 0; }
.fm-drawer-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .5rem; }
.fm-drawer-row input[type=text] { flex: 1; min-width: 200px; }
.fm-drawer-row input[type=file] { flex: 1; min-width: 220px; }
.fm-drawer-row label.check { margin: 0; }
.fm-dropzone { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; border: 2px dashed var(--border-strong); background: var(--accent-softer); }
.fm-dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.fm-dropzone .fm-drawer-row { justify-content: center; width: 100%; }
.fm-drop-icon { width: 40px; height: 40px; background: var(--accent); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; opacity: .8; }
.fm-progress { width: 100%; height: 6px; margin-top: .6rem; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.fm-progress-bar { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s; }

.fm-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.fm-row { display: grid; grid-template-columns: 2.25rem minmax(0, 3fr) 90px 170px 80px 64px 132px; gap: .5rem; align-items: center; padding: .5rem 1rem; border-bottom: 1px solid var(--border); font-size: .88rem; }
.fm-row:last-child { border-bottom: 0; }
.fm-row:not(.fm-head):hover { background: var(--accent-softer); }
.fm-row.selected { background: var(--accent-soft); }
.fm-row input[type=checkbox] { width: 1.05rem; height: 1.05rem; min-height: 0; padding: 0; accent-color: var(--accent); box-shadow: none; }
.fm-head { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.fm-cell-name { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.fm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 550; }
a.fm-name:hover { color: var(--accent); }
.fm-file-icon { flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); position: relative; }
.fm-file-icon::after { content: ""; position: absolute; inset: 7px; background: var(--muted); -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.fm-file-icon.kind-folder { background: color-mix(in srgb, #f59e0b 16%, transparent); }
.fm-file-icon.kind-folder::after { background: #f59e0b; }
.fm-file-icon.kind-image { background: color-mix(in srgb, #ec4899 14%, transparent); }
.fm-file-icon.kind-image::after { background: #ec4899; }
.fm-file-icon.kind-archive { background: color-mix(in srgb, #8b5cf6 15%, transparent); }
.fm-file-icon.kind-archive::after { background: #8b5cf6; }
.fm-file-icon.kind-code { background: var(--accent-soft); }
.fm-file-icon.kind-code::after { background: var(--accent); }
.fm-perms { font: .8rem ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--text-2); padding: .1rem .35rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.fm-perms:hover { border-color: var(--accent); text-decoration: none; }
.fm-row-actions { display: flex; justify-content: flex-end; gap: .15rem; opacity: .55; transition: opacity .12s; }
.fm-row:hover .fm-row-actions, .fm-row:focus-within .fm-row-actions { opacity: 1; }
.fm-icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; }
.fm-icon-btn::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.fm-icon-btn:hover { background: var(--surface-3); color: var(--accent); text-decoration: none; }
.fm-empty { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 4rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius-lg); text-align: center; }

.fm-status { display: flex; gap: 1.5rem; justify-content: space-between; flex: none; padding: .45rem 1.1rem; background: var(--surface); border-top: 1px solid var(--border); color: var(--muted); font-size: .78rem; }
.fm-status span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fm-editor-app { display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0; }
.fm-editor-bar { display: flex; align-items: center; gap: .9rem; padding: .55rem 1.1rem; flex: none; background: var(--surface); border-bottom: 1px solid var(--border); }
.fm-editor-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; margin-right: auto; }
.fm-editor-title span { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-dirty { color: var(--warn); font-size: .8rem; font-weight: 600; }
.fm-editor-alert { margin: .75rem 1.1rem 0; }
textarea.fm-editor { flex: 1; min-height: 0; width: 100%; margin: 0; padding: 1rem 1.25rem; border: 0; border-radius: 0; resize: none; background: var(--bg); font-size: .86rem; line-height: 1.6; tab-size: 2; white-space: pre; overflow-wrap: normal; overflow: auto; box-shadow: none; }
textarea.fm-editor:focus { box-shadow: none; }

.fm-dialog-wrap { flex: 1; overflow-y: auto; display: grid; place-items: start center; padding: 3rem 1rem; }
.fm-dialog { width: 100%; max-width: 520px; padding: 1.6rem 1.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); }
.fm-dialog h1 { font-size: 1.3rem; margin-bottom: .25rem; }
.perm-grid { margin-top: 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.perm-row { display: grid; grid-template-columns: 1fr repeat(3, 80px); align-items: center; padding: .55rem 1rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.perm-row:last-child { border-bottom: 0; }
.perm-row > span:not(:first-child) { text-align: center; }
.perm-row input { width: 1.1rem; height: 1.1rem; min-height: 0; padding: 0; accent-color: var(--accent); box-shadow: none; }
.perm-head { background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

@media (max-width: 900px) {
  .fm-layout { grid-template-columns: minmax(0, 1fr); }
  .fm-tree { display: none; }
  .fm-filter { display: none; }
  .fm-action-group:last-child { margin-left: 0; }
}
@media (max-width: 700px) {
  .fm-row { grid-template-columns: 2rem minmax(0, 1fr) 70px 100px; }
  .fm-row > span:nth-child(4), .fm-row > span:nth-child(5), .fm-row > span:nth-child(6) { display: none; }
  .fm-row-actions { opacity: 1; }
  .fm-action-group { border-right: 0; padding-right: 0; }
  .fm-status span:nth-child(2) { display: none; }
}


/* --- Small screens ------------------------------------------------------- */

@media (max-width: 1180px) {
  .cp-layout { grid-template-columns: minmax(0, 1fr); }
  .cp-side { position: static; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 1.5rem; }
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: 60px; left: 0; z-index: 15; width: 288px; max-width: 86vw; visibility: hidden; transform: translateX(-100%); transition: transform .2s, visibility .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { visibility: visible; transform: none; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .topbar-search, .topbar-meta { display: none; }
}

@media (max-width: 600px) {
  .content { padding: 1rem; }
  .topbar { gap: .5rem; padding: 0 1rem; }
  .topbar-brand strong, .topbar-user, .topbar-tag { display: none; }
  .btn-topbar { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
  .page-head { flex-direction: column; }
  .search { min-width: 0; max-width: none; width: 100%; }
  .tr { padding: .7rem 1rem; }
  .fm-inline, .fm-inline input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* --- Code editor (Monaco, the VS Code editor) ------------------------------ */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ide { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; flex: 1; min-height: 0; background: var(--bg); }
.ide-bar { display: flex; align-items: stretch; gap: .5rem; min-height: 44px; padding: 0 .6rem 0 .4rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.ide-bar-btn { display: inline-flex; align-items: center; gap: .4rem; align-self: center; min-height: 1.9rem; padding: .2rem .6rem; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-2); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ide-bar-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.ide-bar-btn.active { background: var(--accent-soft); color: var(--accent); }
.ide-bar-btn.icon::before { width: 15px; height: 15px; }
.ide-bar-actions { display: flex; align-items: center; gap: .2rem; margin-left: auto; }
.ide-bar-actions .btn { margin-left: .35rem; }

.ide-tabs { display: flex; align-items: stretch; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.ide-tab { position: relative; display: flex; align-items: center; gap: .1rem; max-width: 220px; padding: 0 .3rem 0 .75rem; border-right: 1px solid var(--border); color: var(--muted); font-size: .84rem; }
.ide-tab:first-child { border-left: 1px solid var(--border); }
.ide-tab.active { background: var(--bg); color: var(--text); }
.ide-tab.active::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); }
.ide-tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: .55rem 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.ide-tab-close { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer; }
.ide-tab-close:hover { background: var(--surface-3); color: var(--text); }
.ide-tab.dirty .ide-tab-close { font-size: 0; }
.ide-tab.dirty .ide-tab-close::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); }
.ide-tab.dirty .ide-tab-close:hover { font-size: 1rem; }
.ide-tab.dirty .ide-tab-close:hover::before { display: none; }

.ide-body { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 0; }
.ide-explorer { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); }
.ide-explorer-head { display: flex; align-items: center; justify-content: space-between; padding: .55rem .55rem .35rem .8rem; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ide-mini { width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.ide-mini:hover { background: var(--surface-2); color: var(--text); }
.ide-tree { flex: 1; overflow: auto; padding: 0 .3rem .8rem; scrollbar-width: thin; }
.ide-tree-note { padding: .5rem .6rem; font-size: .82rem; }
.ide-node { display: flex; align-items: center; gap: .4rem; width: 100%; padding-top: .22rem; padding-bottom: .22rem; padding-right: .5rem; border: 0; border-radius: 6px; background: none; color: var(--text-2); font: inherit; font-size: .84rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ide-node:hover { background: var(--surface-2); color: var(--text); }
.ide-node.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ide-node::before { flex: none; width: .9rem; color: var(--muted); font-size: .85rem; text-align: center; }
.ide-node.is-dir::before { content: "›"; transition: transform .12s; }
.ide-node.is-dir.open::before { transform: rotate(90deg); }
.ide-node.is-file::before { content: "•"; color: var(--accent); opacity: .6; }
.ide-node.is-binary { color: var(--muted); opacity: .6; }

.ide-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ide-alert { margin: .6rem .8rem 0; }
.ide-host { flex: 1; min-height: 0; }
.ide-fallback { display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0; }
.ide-fallback textarea.fm-editor { flex: 1; }
.ide-fallback-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 1rem; border-top: 1px solid var(--border); background: var(--surface); font-size: .82rem; }

.ide-status { display: flex; align-items: center; gap: 0; min-height: 26px; padding: 0 .5rem; background: var(--accent); color: var(--on-accent); font-size: .76rem; }
.ide-status-item { padding: .2rem .6rem; white-space: nowrap; }
.ide-grow { flex: 1; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
.ide-status [data-kind=dirty] { font-weight: 700; }
.ide-status [data-kind=error] { background: var(--danger); color: #fff; border-radius: 4px; }
.ide-status [data-kind=warn] { background: var(--warn); color: #111; border-radius: 4px; }
.ide-lang { margin: 0; font-weight: 400; color: inherit; }
.ide-lang select { width: auto; min-height: 0; padding: 0 .2rem; border: 0; border-radius: 4px; background: transparent; color: inherit; font-size: .76rem; cursor: pointer; }
.ide-lang select:focus { box-shadow: none; outline: 1px solid currentColor; }
.ide-lang option { color: var(--text); background: var(--surface); }

@media (max-width: 800px) {
  .ide-body { grid-template-columns: minmax(0, 1fr); }
  .ide-explorer { display: none; }
  .ide-bar { flex-wrap: wrap; }
  .ide-bar-actions [data-ide-font], .ide-bar-actions [data-ide-toggle=minimap] { display: none; }
  .ide-status [data-ide-indent], .ide-status [data-ide-eol] { display: none; }
}
