/* =========================================================================
   FILE MANAGEMENT — the client's document library (files staff uploaded in
   the CRM, at the account level and per property). Matches the dashboard
   theme (Montserrat, Modern-Clean/Light tokens, brand blue gradient).
   Scoped under #files-redesign so nothing leaks; the viewer overlay is moved
   to <body> by fileManagementController and is scoped under #fm-viewer.
   Icons: Font Awesome 5 Pro (fal / fas / fad). Responsive: library rail +
   content on desktop, a horizontal chip scroller on tablet/phone.
   ========================================================================= */
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap");

#files-redesign,
#fm-viewer {
  --brand-blue: #00b4ff;
  --brand-blue-2: #2b9cd3;
  --brand-green: #36bea6;
  --surface: #fff;
  --surface-2: #f7f9fc;
  --surface-3: #eef3f9;
  --line: #e7ecf3;
  --line-strong: #d8e0ea;
  --ink: #1f2a37;
  --ink-2: #5b6b7f;
  --ink-3: #8a99ad;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, 0.18);
  --grad-blue: linear-gradient(135deg, #2b9cd3, #00b4ff);
  --ring: 0 0 0 3px rgba(0, 180, 255, 0.22);
  /* file-type accents */
  --t-pdf: #e5484d;
  --t-img: #8e4ec6;
  --t-doc: #2b6cd3;
  --t-xls: #2f9e6e;
  --t-ppt: #e5732b;
  --t-zip: #a07a2c;
  --t-vid: #d6409f;
  --t-txt: #5b6b7f;
  font-family: "Montserrat", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
#files-redesign *,
#files-redesign *::before,
#files-redesign *::after,
#fm-viewer *,
#fm-viewer *::before,
#fm-viewer *::after {
  box-sizing: border-box;
}
#files-redesign button,
#fm-viewer button {
  font-family: inherit;
}

/* ===== sidebar menu item: light-green "new feature" highlight =====
   menu.html  <li class="a__file_management menu-new-feature">. Specific enough to beat the
   dark-sidebar theme rules in header-colors.css (html.color-sidebar .sidebar-wrapper .metismenu a). */
html .sidebar-wrapper .metismenu li.menu-new-feature > a {
  margin: 4px 8px;
  padding-left: 7px;
  border-radius: 10px;
  background: #e3f8f1;
  border: 1px solid #bfeedd;
  color: #0f3d33;
  white-space: normal;
}
html .sidebar-wrapper .metismenu li.menu-new-feature > a .parent-icon {
  color: #1f9e86;
}
html .sidebar-wrapper .metismenu li.menu-new-feature > a .menu-title {
  font-weight: 600;
  line-height: 1.2;
}
html .sidebar-wrapper .metismenu li.menu-new-feature > a .mnf-sub {
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #2f8f7d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html .sidebar-wrapper .metismenu li.menu-new-feature > a .mnf-sub i {
  font-size: 8.5px;
  margin-right: 2px;
  vertical-align: 1px;
}
html .sidebar-wrapper .metismenu li.menu-new-feature > a:hover,
html .sidebar-wrapper .metismenu li.menu-new-feature > a:focus,
html .sidebar-wrapper .metismenu li.menu-new-feature.mm-active > a {
  background: #ccf2e5;
  border-color: #9fe3cb;
  color: #0b3029;
}
/* collapsed (icon-only) rail: center the icon in a small green tile */
@media screen and (min-width: 1025px) {
  .wrapper.toggled:not(.sidebar-hovered) .sidebar-wrapper .metismenu li.menu-new-feature > a {
    margin: 4px 8px;
    padding: 8px 0;
  }
}

/* ===== hero ===== */
#files-redesign .fm-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--grad-blue);
  color: #fff;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 10px 30px rgba(0, 180, 255, 0.22);
  margin-bottom: 16px;
}
#files-redesign .fm-hero::before,
#files-redesign .fm-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
#files-redesign .fm-hero::before {
  width: 260px;
  height: 260px;
  right: -70px;
  top: -120px;
}
#files-redesign .fm-hero::after {
  width: 160px;
  height: 160px;
  right: 140px;
  bottom: -110px;
  background: rgba(255, 255, 255, 0.07);
}
#files-redesign .fm-hero-ic {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#files-redesign .fm-hero-text {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
#files-redesign .fm-hero-text h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}
#files-redesign .fm-hero-text p {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.45;
}
#files-redesign .fm-stats {
  position: relative;
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}
/* icon pinned top-left, number + label right-aligned */
#files-redesign .fm-stat {
  position: relative;
  min-width: 122px;
  padding: 10px 14px 10px 54px;
  text-align: right;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.08);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#files-redesign .fm-stat .s-ic {
  position: absolute;
  top: 11px;
  left: 14px;
  font-size: 24px;
  line-height: 1;
  color: #4b5563;
}
#files-redesign .fm-stat .v {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.05;
  color: #4b5563;
}
#files-redesign .fm-stat .l {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4b5563;
  margin-top: 3px;
}

/* ===== layout ===== */
#files-redesign .fm-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* ===== library rail ===== */
#files-redesign .fm-rail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px;
  position: sticky;
  top: 128px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}
#files-redesign .fm-rail-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 10px 6px;
}
#files-redesign .fm-scope {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
#files-redesign .fm-scope + .fm-scope {
  margin-top: 2px;
}
#files-redesign .fm-scope:hover {
  background: var(--surface-2);
}
#files-redesign .fm-scope:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
#files-redesign .fm-scope .s-ic {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: var(--surface-3);
  color: var(--brand-blue-2);
  transition: all 0.15s ease;
}
#files-redesign .fm-scope .s-txt {
  flex: 1 1 auto;
  min-width: 0;
}
#files-redesign .fm-scope .s-t1 {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#files-redesign .fm-scope .s-t2 {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#files-redesign .fm-scope .s-count {
  flex: 0 0 auto;
  min-width: 26px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  background: var(--surface-3);
  color: var(--ink-2);
}
#files-redesign .fm-scope.is-empty .s-count {
  opacity: 0.55;
}
#files-redesign .fm-scope.active {
  background: rgba(0, 180, 255, 0.09);
}
#files-redesign .fm-scope.active .s-ic {
  background: var(--grad-blue);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.3);
}
#files-redesign .fm-scope.active .s-t1 {
  color: var(--brand-blue-2);
}
#files-redesign .fm-scope.active .s-count {
  background: var(--brand-blue-2);
  color: #fff;
}
#files-redesign .fm-rail-divider {
  height: 1px;
  background: var(--line);
  margin: 8px 6px;
}

/* ===== main column ===== */
#files-redesign .fm-main {
  min-width: 0;
}
#files-redesign .fm-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px;
  margin-bottom: 14px;
}
#files-redesign .fm-search {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
}
#files-redesign .fm-search i.fa-search {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 13px;
  pointer-events: none;
}
#files-redesign .fm-search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 34px 0 36px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
#files-redesign .fm-search input::placeholder {
  color: var(--ink-3);
}
#files-redesign .fm-search input:focus {
  border-color: var(--brand-blue);
  background: var(--surface);
  box-shadow: var(--ring);
}
#files-redesign .fm-search .clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
#files-redesign .fm-search .clear:hover {
  background: var(--surface-3);
  color: var(--ink);
}
/* ===== sort menu (custom listbox) ===== */
#files-redesign .fm-dd {
  position: relative;
  flex: 0 0 auto;
}
#files-redesign .fm-dd-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  min-width: 178px;
  padding: 0 12px 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
#files-redesign .fm-dd-btn:hover {
  border-color: var(--brand-blue);
}
#files-redesign .fm-dd-btn:focus-visible,
#files-redesign .fm-dd.open .fm-dd-btn {
  border-color: var(--brand-blue);
  box-shadow: var(--ring);
}
#files-redesign .fm-dd-btn .dd-ic {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--brand-blue-2);
  background: rgba(0, 180, 255, 0.1);
  transition: all 0.15s ease;
}
#files-redesign .fm-dd.open .fm-dd-btn .dd-ic {
  color: #fff;
  background: var(--grad-blue);
}
#files-redesign .fm-dd-btn .dd-txt {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
#files-redesign .fm-dd-btn .dd-k {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
#files-redesign .fm-dd-btn .dd-v {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#files-redesign .fm-dd-btn .dd-chev {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--ink-3);
  transition: transform 0.2s ease, color 0.15s ease;
}
#files-redesign .fm-dd.open .fm-dd-btn .dd-chev {
  transform: rotate(180deg);
  color: var(--brand-blue-2);
}
#files-redesign .fm-dd-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: 272px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  box-shadow: 0 20px 44px rgba(16, 24, 40, 0.16), 0 3px 8px rgba(16, 24, 40, 0.06);
  transform-origin: top left;
  animation: fm-dd-in 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
@keyframes fm-dd-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
#files-redesign .fm-dd-menu .dd-head {
  padding: 8px 10px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
#files-redesign .dd-opt {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px 8px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}
#files-redesign .dd-opt + .dd-opt {
  margin-top: 2px;
}
#files-redesign .dd-opt.focus {
  background: var(--surface-2);
}
#files-redesign .dd-opt .o-ic {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--surface-3);
  transition: all 0.12s ease;
}
#files-redesign .dd-opt.focus .o-ic {
  color: var(--brand-blue-2);
  background: rgba(0, 180, 255, 0.12);
}
#files-redesign .dd-opt .o-txt {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#files-redesign .dd-opt .o-l {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
#files-redesign .dd-opt .o-d {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 1px;
}
#files-redesign .dd-opt .o-check {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--brand-blue-2);
}
#files-redesign .dd-opt.sel {
  background: rgba(0, 180, 255, 0.08);
}
#files-redesign .dd-opt.sel .o-ic {
  color: #fff;
  background: var(--grad-blue);
  box-shadow: 0 4px 10px rgba(0, 180, 255, 0.28);
}
#files-redesign .dd-opt.sel .o-l {
  color: var(--brand-blue-2);
}
#files-redesign .fm-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-3);
}
#files-redesign .fm-seg button {
  width: 34px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
#files-redesign .fm-seg button.on {
  background: var(--surface);
  color: var(--brand-blue-2);
  box-shadow: var(--shadow-sm);
}
#files-redesign .fm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}
#files-redesign .fm-toggle i {
  font-size: 14px;
}
#files-redesign .fm-toggle:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue-2);
}
#files-redesign .fm-toggle.on {
  border-color: rgba(0, 180, 255, 0.45);
  background: rgba(0, 180, 255, 0.08);
  color: var(--brand-blue-2);
}
#files-redesign .fm-icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
#files-redesign .fm-icon-btn:hover {
  color: var(--brand-blue-2);
  border-color: var(--brand-blue);
}
#files-redesign .fm-icon-btn.spinning i {
  animation: fm-spin 0.8s linear infinite;
}
@keyframes fm-spin {
  to {
    transform: rotate(360deg);
  }
}

/* type filter chips */
#files-redesign .fm-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -2px 0 14px;
}
#files-redesign .fm-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
#files-redesign .fm-chip:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue-2);
}
#files-redesign .fm-chip .n {
  font-weight: 600;
  color: var(--ink-3);
}
#files-redesign .fm-chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
#files-redesign .fm-chip.on .n {
  color: rgba(255, 255, 255, 0.7);
}

/* section head (current scope) */
#files-redesign .fm-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 2px 12px;
}
#files-redesign .fm-section-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}
#files-redesign .fm-section-head .sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 3px;
}
#files-redesign .fm-section-head .count {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ===== type tile (shared by grid / list / viewer) ===== */
.fm-type {
  --c: var(--t-txt);
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  color: var(--c);
  background: rgba(91, 107, 127, 0.1);
  background: color-mix(in srgb, var(--c) 12%, #fff);
  position: relative;
}
.fm-type .ext {
  position: absolute;
  bottom: -5px;
  right: -6px;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--c);
  text-transform: uppercase;
  box-shadow: 0 0 0 2px #fff;
}
.fm-type.t-pdf { --c: var(--t-pdf); }
.fm-type.t-img { --c: var(--t-img); }
.fm-type.t-doc { --c: var(--t-doc); }
.fm-type.t-xls { --c: var(--t-xls); }
.fm-type.t-ppt { --c: var(--t-ppt); }
.fm-type.t-zip { --c: var(--t-zip); }
.fm-type.t-vid { --c: var(--t-vid); }
.fm-type.t-txt { --c: var(--t-txt); }

/* ===== grid view ===== */
#files-redesign .fm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
#files-redesign .fm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: fm-rise 0.32s ease both;
}
#files-redesign .fm-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}
#files-redesign .fm-card:focus-visible {
  outline: none;
  box-shadow: var(--ring), var(--shadow-md);
}
#files-redesign .fm-card-top {
  position: relative;
  height: 120px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(0, 180, 255, 0.1), transparent 60%),
    var(--surface-2);
  border-bottom: 1px solid var(--line);
}
#files-redesign .fm-card-top .fm-type {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  font-size: 26px;
  box-shadow: var(--shadow-sm);
}
#files-redesign .fm-card-top .thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#files-redesign .fm-card-top .new {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--brand-green);
  box-shadow: 0 4px 10px rgba(54, 190, 166, 0.35);
}
#files-redesign .fm-card-body {
  padding: 12px 14px 10px;
  flex: 1 1 auto;
  min-width: 0;
}
#files-redesign .fm-name {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#files-redesign .fm-desc {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#files-redesign .fm-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 6px;
}
#files-redesign .fm-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}
#files-redesign .fm-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  margin-top: 8px;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-blue-2);
  background: rgba(0, 180, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#files-redesign .fm-tag.acct {
  color: #2f8f7d;
  background: rgba(54, 190, 166, 0.12);
}
#files-redesign .fm-tag span {
  overflow: hidden;
  text-overflow: ellipsis;
}
#files-redesign .fm-card-actions {
  display: flex;
  border-top: 1px solid var(--line);
}
#files-redesign .fm-card-actions button {
  flex: 1 1 0;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
#files-redesign .fm-card-actions button + button {
  border-left: 1px solid var(--line);
}
#files-redesign .fm-card-actions button:hover {
  background: var(--surface-2);
  color: var(--brand-blue-2);
}
#files-redesign .fm-card-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: transparent;
  color: var(--ink-2);
}

/* ===== list view ===== */
#files-redesign .fm-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
#files-redesign .fm-list-head,
#files-redesign .fm-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px 110px 80px 128px;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
}
#files-redesign .fm-list.no-prop .fm-list-head,
#files-redesign .fm-list.no-prop .fm-item {
  grid-template-columns: minmax(0, 1fr) 110px 80px 128px;
}
#files-redesign .fm-list-head {
  height: 40px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
#files-redesign .fm-list-head .r {
  text-align: right;
}
#files-redesign .fm-item {
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
  animation: fm-rise 0.28s ease both;
}
#files-redesign .fm-item:last-child {
  border-bottom: 0;
}
#files-redesign .fm-item:hover {
  background: #fafcff;
}
#files-redesign .fm-item:focus-visible {
  outline: none;
  box-shadow: inset var(--ring);
}
#files-redesign .fm-item .c-file {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
#files-redesign .fm-item .c-file .fm-type {
  width: 40px;
  height: 40px;
  font-size: 17px;
}
#files-redesign .fm-item .c-file .txt {
  min-width: 0;
}
#files-redesign .fm-item .fm-name {
  -webkit-line-clamp: 1;
}
#files-redesign .fm-item .fm-desc {
  -webkit-line-clamp: 1;
  margin-top: 1px;
}
#files-redesign .fm-item .fm-tag {
  margin-top: 0;
}
#files-redesign .fm-item .c-date,
#files-redesign .fm-item .c-size {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
#files-redesign .fm-item .c-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}
#files-redesign .fm-act {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
}
#files-redesign .fm-act:hover {
  background: rgba(0, 180, 255, 0.1);
  color: var(--brand-blue-2);
}
#files-redesign .fm-act:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: transparent;
  color: var(--ink-2);
}
#files-redesign .fm-new-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-green);
  margin-left: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(54, 190, 166, 0.2);
}

/* group headers (All Files grouped by property) */
#files-redesign .fm-group + .fm-group {
  margin-top: 22px;
}
#files-redesign .fm-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 2px 10px;
}
#files-redesign .fm-group-head .g-ic {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--brand-blue-2);
  background: rgba(0, 180, 255, 0.1);
}
#files-redesign .fm-group-head .g-ic.acct {
  color: #2f8f7d;
  background: rgba(54, 190, 166, 0.14);
}
#files-redesign .fm-group-head .g-t {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#files-redesign .fm-group-head .g-s {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
}
#files-redesign .fm-group-head .g-line {
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
  min-width: 20px;
}

/* ===== loading skeleton ===== */
#files-redesign .fm-skel {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}
#files-redesign .fm-skel .b {
  background: linear-gradient(90deg, var(--surface-3) 0%, #f8fbfe 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: fm-shimmer 1.2s ease-in-out infinite;
  border-radius: 6px;
}
#files-redesign .fm-skel .b.top {
  height: 120px;
  border-radius: 0;
}
#files-redesign .fm-skel .pad {
  padding: 14px;
}
#files-redesign .fm-skel .b.l1 {
  height: 12px;
  width: 80%;
}
#files-redesign .fm-skel .b.l2 {
  height: 10px;
  width: 50%;
  margin-top: 9px;
}
@keyframes fm-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes fm-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ===== empty / error states ===== */
#files-redesign .fm-empty {
  text-align: center;
  padding: 54px 24px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
#files-redesign .fm-empty .e-ic {
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 30px;
  color: var(--brand-blue-2);
  background: linear-gradient(135deg, rgba(43, 156, 211, 0.12), rgba(0, 180, 255, 0.16));
}
#files-redesign .fm-empty.err .e-ic {
  color: var(--t-pdf);
  background: rgba(229, 72, 77, 0.1);
}
#files-redesign .fm-empty h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}
#files-redesign .fm-empty p {
  max-width: 420px;
  margin: 6px auto 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink-2);
}
#files-redesign .fm-empty .fm-btn {
  margin-top: 16px;
}

/* ===== buttons ===== */
#files-redesign .fm-btn,
#fm-viewer .fm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
#files-redesign .fm-btn:hover,
#fm-viewer .fm-btn:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue-2);
}
#files-redesign .fm-btn.primary,
#fm-viewer .fm-btn.primary {
  border: 0;
  background: var(--grad-blue);
  color: #fff;
  box-shadow: 0 6px 16px rgba(0, 180, 255, 0.3);
}
#files-redesign .fm-btn.primary:hover,
#fm-viewer .fm-btn.primary:hover {
  filter: brightness(1.05);
  color: #fff;
}
#fm-viewer .fm-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* =========================================================================
   VIEWER OVERLAY (moved to <body> at runtime so no transformed ancestor
   can break position: fixed)
   ========================================================================= */
#fm-viewer {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 36, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#fm-viewer.open {
  display: flex;
  animation: fm-fade 0.18s ease both;
}
@keyframes fm-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
#fm-viewer .fv-panel {
  width: min(1100px, 100%);
  height: min(860px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fm-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes fm-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
#fm-viewer .fv-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 18px;
  border-bottom: 1px solid var(--line);
}
#fm-viewer .fv-title {
  flex: 1 1 auto;
  min-width: 0;
}
#fm-viewer .fv-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#fm-viewer .fv-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#fm-viewer .fv-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
#fm-viewer .fv-head > .fm-type {
  width: 40px;
  height: 40px;
  font-size: 17px;
}
#fm-viewer .fv-x {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}
#fm-viewer .fv-x:hover {
  background: var(--ink);
  color: #fff;
}
#fm-viewer .fv-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #eef2f7;
  display: grid;
  place-items: center;
}
#fm-viewer .fv-body iframe {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}
#fm-viewer .fv-body img {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 40px);
  max-height: calc(100% - 40px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  background: #fff;
}
#fm-viewer .fv-body video {
  position: relative;
  z-index: 1;
  background: #000;
  max-width: 100%;
  max-height: 100%;
}
#fm-viewer .fv-loading {
  position: absolute;
  inset: 0;
  z-index: 0;
  justify-content: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
#fm-viewer .fv-spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(0, 180, 255, 0.18);
  border-top-color: var(--brand-blue);
  animation: fm-spin 0.8s linear infinite;
}
#fm-viewer .fv-nopreview {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 30px;
  max-width: 380px;
}
#fm-viewer .fv-nopreview .fm-type {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  font-size: 32px;
  margin: 0 auto 16px;
}
#fm-viewer .fv-nopreview h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
#fm-viewer .fv-nopreview p {
  margin: 6px 0 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink-2);
}
#fm-viewer .fv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font-size: 16px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 2;
}
#fm-viewer .fv-nav:hover {
  background: var(--brand-blue-2);
  color: #fff;
}
#fm-viewer .fv-nav.prev {
  left: 14px;
}
#fm-viewer .fv-nav.next {
  right: 14px;
}
#fm-viewer .fv-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
}
#fm-viewer .fv-foot kbd {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
}
body.fm-viewer-open {
  overflow: hidden;
}

/* ===== responsive ===== */
@media (max-width: 1199px) {
  #files-redesign .fm-list-head,
  #files-redesign .fm-item {
    grid-template-columns: minmax(0, 1fr) 150px 100px 128px;
  }
  #files-redesign .fm-list.no-prop .fm-list-head,
  #files-redesign .fm-list.no-prop .fm-item {
    grid-template-columns: minmax(0, 1fr) 100px 128px;
  }
  #files-redesign .fm-list-head .h-size,
  #files-redesign .fm-item .c-size {
    display: none;
  }
}

@media (max-width: 991px) {
  #files-redesign .fm-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  /* the rail becomes a horizontal chip scroller */
  #files-redesign .fm-rail {
    position: static;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    gap: 8px;
    padding: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #files-redesign .fm-rail::-webkit-scrollbar {
    display: none;
  }
  #files-redesign .fm-rail-label,
  #files-redesign .fm-rail-divider {
    display: none;
  }
  #files-redesign .fm-scope {
    flex: 0 0 auto;
    width: auto;
    max-width: 240px;
    border: 1px solid var(--line);
    padding: 6px 10px 6px 6px;
  }
  #files-redesign .fm-scope + .fm-scope {
    margin-top: 0;
  }
  #files-redesign .fm-scope.active {
    border-color: rgba(0, 180, 255, 0.4);
  }
  #files-redesign .fm-scope .s-ic {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  #files-redesign .fm-scope .s-t2 {
    display: none;
  }
  #files-redesign .fm-stats {
    display: none;
  }
}

@media (max-width: 700px) {
  #files-redesign .fm-hero {
    padding: 18px;
    gap: 14px;
  }
  #files-redesign .fm-hero-ic {
    width: 44px;
    height: 44px;
    font-size: 19px;
  }
  #files-redesign .fm-hero-text h2 {
    font-size: 18px;
  }
  #files-redesign .fm-hero-text p {
    font-size: 12px;
  }
  #files-redesign .fm-toolbar {
    gap: 8px;
  }
  #files-redesign .fm-search {
    flex: 1 1 100%;
  }
  #files-redesign .fm-dd {
    flex: 1 1 auto;
  }
  #files-redesign .fm-dd-btn {
    width: 100%;
    min-width: 0;
  }
  #files-redesign .fm-dd-menu {
    width: max(100%, 250px);
  }
  /* an icon-only checkbox reads as noise on a phone; grouping keeps its current setting */
  #files-redesign .fm-toggle {
    display: none;
  }
  #files-redesign .fm-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }
  #files-redesign .fm-card-top {
    height: 92px;
  }
  #files-redesign .fm-card-top .fm-type {
    width: 48px;
    height: 48px;
    font-size: 21px;
  }
  #files-redesign .fm-card-actions button .lbl {
    display: none;
  }
  /* list rows collapse to file + actions */
  #files-redesign .fm-list-head {
    display: none;
  }
  #files-redesign .fm-item,
  #files-redesign .fm-list.no-prop .fm-item {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px 12px;
  }
  #files-redesign .fm-item .c-prop,
  #files-redesign .fm-item .c-date {
    display: none;
  }
  #files-redesign .fm-item .c-actions {
    gap: 0;
  }
  #files-redesign .fm-act {
    width: 34px;
    height: 34px;
  }

  #fm-viewer {
    padding: 0;
  }
  #fm-viewer .fv-panel {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  #fm-viewer .fv-head {
    flex-wrap: wrap;
    padding: 12px;
  }
  #fm-viewer .fv-actions {
    order: 3;
    width: 100%;
  }
  #fm-viewer .fv-actions .fm-btn {
    flex: 1 1 0;
    padding: 0 10px;
  }
  #fm-viewer .fv-foot {
    display: none;
  }
  #fm-viewer .fv-nav {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #files-redesign *,
  #fm-viewer * {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== print: never print the dashboard chrome if someone uses Ctrl+P here ===== */
@media print {
  #fm-viewer {
    display: none !important;
  }
}
