:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --border: #e3e6ef;
  --text: #171a2b;
  --muted: #6b7088;
  --primary: #4f46e5;
  --primary-soft: #eceafd;
  --primary-text: #ffffff;
  --ok: #12a150;
  --ok-soft: #dcf5e7;
  --warn: #c77700;
  --warn-soft: #fff1d6;
  --bad: #d92d3f;
  --bad-soft: #fde4e7;
  --off: #9aa0b8;
  --shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 8px 24px rgba(20, 24, 50, .06);
  --radius: 16px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1020;
    --surface: #171a2e;
    --surface-2: #1f2340;
    --border: #2a2f52;
    --text: #eceefb;
    --muted: #9aa0c3;
    --primary: #7c78ff;
    --primary-soft: #26275a;
    --primary-text: #0e1020;
    --ok: #3ddc84;
    --ok-soft: #14352a;
    --warn: #ffb547;
    --warn-soft: #3a2c10;
    --bad: #ff6b7a;
    --bad-soft: #3d1a22;
    --off: #6b7196;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", "Leelawadee UI", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600;
  transition: transform .06s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--primary); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.small { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.btn.icon { width: 42px; padding: 0; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; min-height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 10% -10%, var(--primary-soft), transparent 60%),
    radial-gradient(700px 400px at 100% 110%, var(--primary-soft), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; padding: 32px 28px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.logo {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; margin-bottom: 18px;
}
.logo svg { width: 28px; height: 28px; }
.login-card h1 { font-size: 24px; letter-spacing: -.01em; }
.login-card .sub { color: var(--muted); margin: 4px 0 24px; }
.form-error { color: var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }

/* ---------- shell ---------- */
.shell { min-height: 100%; display: grid; grid-template-columns: 240px 1fr; }
.nav {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; font-weight: 700; font-size: 17px; }
.brand .logo { width: 38px; height: 38px; border-radius: 12px; margin: 0; }
.brand .logo svg { width: 20px; height: 20px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
  border: 0; background: none; color: var(--muted); font-weight: 600; text-align: left; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--warn); color: #fff; font-size: 12px; display: grid; place-items: center;
}
.nav-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px 8px; color: var(--muted); font-size: 14px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }

.main { padding: 28px clamp(16px, 3vw, 40px) 40px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 26px; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); font-size: 14px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); text-align: left; display: grid; gap: 2px;
}
button.stat:hover { border-color: var(--primary); }
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.stat .n { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 13px; top: 12px; color: var(--muted); }
.search .input { padding-left: 42px; }

/* ---------- groups & cards ---------- */
.group { margin-bottom: 26px; }
.group-title { display: flex; align-items: center; gap: 10px; margin: 0 2px 10px; font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.group-title .count { background: var(--surface-2); border-radius: 10px; padding: 0 9px; font-size: 12px; line-height: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: grid; gap: 12px; text-align: left; width: 100%;
  transition: transform .12s, border-color .15s;
}
button.card:hover { border-color: var(--primary); transform: translateY(-1px); }
.card-top { display: flex; align-items: center; gap: 12px; }
.pc {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); position: relative; flex: none;
}
.pc .dot { position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--surface); background: var(--off); }
.pc .dot.on { background: var(--ok); }
.pc .dot.wait { background: var(--warn); }
.card-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-info { min-width: 0; flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.card.pending { border-color: var(--warn); background: linear-gradient(var(--warn-soft), var(--surface) 70%); }
.card .actions { display: flex; gap: 8px; }
.card .actions .btn { flex: 1; }

.empty { text-align: center; color: var(--muted); padding: 56px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty svg { width: 40px; height: 40px; margin-bottom: 10px; opacity: .6; }

/* ---------- list rows (branches / audit) ---------- */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row .desc { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.row .when { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- modal / sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 10, 24, .5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s; }
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border-radius: 22px; border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: pop .18s ease-out;
}
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sheet-head h2 { font-size: 19px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { padding: 12px 20px 20px; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 20px 20px; }
.sheet-foot .btn { flex: 0 1 auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes rise { from { transform: translateY(100%); } }

.section-title { margin: 18px 0 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 4px 0 2px; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar > i.hot { background: var(--bad); }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.bar-block { margin-bottom: 10px; }
.sw-list { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; margin-top: 8px; }
.sw-list .row { padding: 8px 12px; font-size: 13px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(92vw, 380px); pointer-events: none; }
@media (min-width: 861px) { #toasts { bottom: 24px; } }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); animation: pop .18s; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; top: auto; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom); flex-direction: row; justify-content: space-around; gap: 2px;
    border-right: 0; border-top: 1px solid var(--border);
  }
  .brand, .nav-spacer, .user-chip { display: none; }
  .nav-item { flex: 1; flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 11px; justify-content: center; align-items: center; }
  .nav-badge { position: absolute; top: 2px; left: 50%; margin: 0 0 0 8px; min-width: 18px; height: 18px; font-size: 11px; }
  .main { padding: 18px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat .n { font-size: 26px; }
  .grid { grid-template-columns: 1fr; }
  .overlay { align-items: end; padding: 0; }
  .sheet { max-width: none; max-height: 92vh; border-radius: 22px 22px 0 0; border-bottom: 0; animation: rise .22s ease-out; padding-bottom: env(safe-area-inset-bottom); }
  .sheet-foot { flex-direction: column-reverse; }
  .sheet-foot .btn { flex: 1; width: 100%; }
  .kv { grid-template-columns: 96px 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- file inputs & wrapped rows ---------- */
input[type="file"].input { padding: 6px; min-height: 48px; line-height: 34px; color: var(--muted); }
input[type="file"].input::file-selector-button {
  height: 34px; margin-right: 12px; padding: 0 14px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
}
input[type="file"].input::file-selector-button:hover { border-color: var(--primary); }
.row-actions { display: flex; gap: 8px; align-items: center; }
@media (max-width: 860px) {
  .row.wrap { flex-wrap: wrap; }
  .row.wrap .row-actions { width: 100%; justify-content: flex-end; }
}

/* ---------- scripts page ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); min-height: 36px; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.tpls-wrap { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; flex-wrap: wrap; }
.tpls { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-chip { border: 1px solid var(--border); cursor: pointer; padding: 5px 12px; }
.btn-chip:hover { border-color: var(--primary); color: var(--primary); }
textarea.input.code, .out { font: 13px/1.5 ui-monospace, "Cascadia Mono", Consolas, "Leelawadee UI", monospace; }
textarea.input.code { padding: 12px 14px; min-height: 160px; resize: vertical; tab-size: 2; white-space: pre; overflow: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.checks { display: grid; gap: 6px; max-height: 260px; overflow: auto; margin-bottom: 8px; }
.check { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); }
.check:hover { border-color: var(--primary); }
.check input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.check .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dot-s { width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; }
.dot-s.on { background: var(--ok); }
.jobrow { width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; }
.jobrow:hover { background: var(--surface-2); }
pre.out { margin: 0; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; overflow: auto; max-height: 320px; white-space: pre-wrap; word-break: break-word; }
details.res { border-bottom: 1px solid var(--border); }
details.res:last-child { border-bottom: 0; }
details.res > summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
details.res > summary::-webkit-details-marker { display: none; }
details.res > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.res[open] > summary::before { transform: rotate(90deg); }
details.res > pre { margin: 0 14px 14px; }
details.script-view summary { cursor: pointer; color: var(--primary); font-weight: 600; margin: 8px 0; }
.sheet-foot { flex-wrap: wrap; }
@media (max-width: 860px) {
  .two { grid-template-columns: 1fr; }
  .seg button { padding: 7px 10px; }
  .sheet-foot { flex-direction: column-reverse; }
}

/* ---------- remote viewer ---------- */
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--primary); transform: translateY(-1px); }
.card.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.remote { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: #0b0d18; color: #eceefb; }
.rbar { display: flex; align-items: center; gap: 10px; padding: 8px 10px calc(8px) 10px; background: #151834; border-bottom: 1px solid #2a2f52; min-height: 56px; }
.rtitle { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; white-space: nowrap; }
.rtitle .chip { background: #232852; color: #b8bdea; }
.rtitle .chip.ok { background: #14352a; color: #3ddc84; }
.rtitle .chip.bad { background: #3d1a22; color: #ff6b7a; }
.rtools { display: flex; align-items: center; gap: 6px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.rtools::-webkit-scrollbar { display: none; }
.rbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; min-width: 38px; padding: 0 10px; justify-content: center; border: 1px solid #2f3566; border-radius: 10px; background: #1d2145; color: #eceefb; font-weight: 600; white-space: nowrap; }
.rbtn:hover { border-color: #7c78ff; }
.rsel { min-height: 38px; border-radius: 10px; border: 1px solid #2f3566; background: #1d2145; color: #eceefb; padding: 0 8px; }
.rzoom { min-width: 54px; text-align: center; font-size: 13px; color: #9aa0c3; }
.rwrap { position: relative; }
.rmenu { position: absolute; right: 0; top: 44px; z-index: 5; min-width: 250px; padding: 6px; border-radius: 12px; background: #1d2145; border: 1px solid #2f3566; box-shadow: 0 12px 32px rgba(0,0,0,.5); display: grid; }
.rmenu[hidden] { display: none; }
.rmenu-item { text-align: left; border: 0; background: none; color: #eceefb; padding: 10px 12px; border-radius: 8px; }
.rmenu-item:hover { background: #2a2f5c; }
.rstage { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; background: #05060d; }
.rcanvas { display: block; background: #000; outline: none; touch-action: pan-x pan-y; image-rendering: auto; cursor: default; }
.rbanner { padding: 8px 14px; background: #3a2c10; color: #ffb547; font-size: 14px; }
.rbanner[hidden] { display: none; }
.rkbd { position: fixed; left: -100px; top: 0; width: 1px; height: 1px; opacity: 0; }
.remote .seg { background: #1d2145; border-color: #2f3566; }
.remote .seg button { color: #9aa0c3; min-height: 32px; }
.remote .seg button.on { background: #2f3566; color: #fff; box-shadow: none; }
@media (max-width: 860px) {
  .rbar { flex-wrap: wrap; gap: 6px; }
  .rtools { width: 100%; margin-left: 0; padding-bottom: 2px; }
  .rlbl { display: none; }
  .rtitle { flex: 1; overflow: hidden; }
}

[hidden] { display: none !important; }
.rmenu { position: fixed; top: 0; right: auto; z-index: 70; }
@media (max-width: 860px) { .rstage { place-items: start center; } }

.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.head-actions .btn { text-decoration: none; }
a.btn { text-decoration: none; }
@media (max-width: 860px) { .page-head { flex-wrap: wrap; } .head-actions { width: 100%; } }

.card .notice { padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
/* ---------- file manager ---------- */
.fm { position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
.fm-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 56px; }
.fm-title { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; white-space: nowrap; }
.fm-bar .rtools, .fm-nav { display: flex; align-items: center; gap: 6px; }
.fm-bar .rtools { margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.fm .rbtn { border-color: var(--border); background: var(--surface); color: var(--text); }
.fm .rbtn:hover { border-color: var(--primary); }
.fm .rbtn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.fm .rbtn.danger { color: var(--bad); }
.fm .rbtn.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.fm-nav { padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.fm-crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.fm-crumb { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 6px 8px; border-radius: 8px; color: var(--text); font-weight: 600; }
.fm-crumb:hover { background: var(--surface-2); }
.fm-sep { color: var(--muted); }
.fm-filter { max-width: 220px; min-height: 38px; }
.fm-places { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.fm-chip { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; }
.fm-chip:hover { border-color: var(--primary); color: var(--primary); }
.fm-list { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 16px; outline: none; }
.fm-list.drop { box-shadow: inset 0 0 0 3px var(--primary); background: var(--primary-soft); }
.fm-row { display: grid; grid-template-columns: 28px 28px minmax(0, 1fr) 90px 150px 40px; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; background: var(--surface); }
.fm-row:hover { background: var(--surface-2); }
.fm-row.sel { background: var(--primary-soft); }
.fm-row.fm-hidden { opacity: .6; }
.fm-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.fm-head { cursor: default; position: sticky; top: 0; z-index: 1; font-size: 13px; color: var(--muted); }
.fm-head:hover { background: var(--surface); }
.fm-th { border: 0; background: none; padding: 0; text-align: left; font-weight: 700; color: var(--muted); }
.fm-th.fm-size { text-align: right; }
.fm-ic { color: var(--muted); display: inline-flex; }
.fm-name { min-width: 0; display: grid; }
.fm-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fm-sub { display: none; }
.fm-size { text-align: right; color: var(--muted); font-size: 13px; }
.fm-mod { color: var(--muted); font-size: 13px; }
.fm-more { min-height: 34px; min-width: 34px; padding: 0; }
.fm-drive { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; margin-bottom: 8px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.fm-drive:hover { border-color: var(--primary); }
.fm-drive-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.fm-uploads { max-height: 32vh; overflow: auto; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--border); }
.fm-up-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.fm-up { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.fm-up-main { min-width: 0; }
.fm-up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fm-up-error .card-sub { color: var(--bad); }
.fm-up-done .bar > i { background: var(--ok); }
.fm-up-actions { display: flex; gap: 8px; }
.fm-acts { display: grid; gap: 6px; }
.fm-act { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 600; text-align: left; }
.fm-act:hover { border-color: var(--primary); }
.fm-act.danger { color: var(--bad); }
.fm-err { color: var(--bad); min-height: 1.3em; }
.fm-dellist { margin: 8px 0 0; padding-left: 20px; max-height: 180px; overflow: auto; }
.fm-preview { max-height: 55vh; }
@media (max-width: 860px) {
  .fm-row { grid-template-columns: 26px 26px minmax(0, 1fr) 40px; }
  .fm-size, .fm-mod, .fm-head .fm-th:not(.fm-name) { display: none; }
  .fm-sub { display: block; font-size: 12px; }
  .fm-head { grid-template-columns: 26px 26px minmax(0, 1fr) 40px; }
  .fm-filter { max-width: none; width: 110px; }
  .fm-nav { padding: 6px 8px; }
  .rlbl { display: none; }
}

.fm-title { flex: 1 1 auto; min-width: 0; }
.fm-title span { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) {
  .fm-bar { flex-wrap: wrap; }
  .fm-bar .rtools { width: 100%; margin-left: 0; }
}
