/* ==========================================================================
   Toral Panel - panel-admin design system
   --------------------------------------------------------------------------
   Single source of truth for the panel-admin look.

   Rules for anyone extending this file:
   - Every colour, radius and spacing value comes from a token below. Never
     hard-code a hex value in a component rule.
   - Light and dark are driven by [data-tp-theme] on <html>. Define the value
     once per theme in the token blocks, never inside a component.
   - Direction is driven by dir="rtl"/"ltr" on <html>. Use CSS logical
     properties (inline-start/inline-end) so RTL needs no mirrored rules.
   - No inline style attributes in PHP. Add a class here instead.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Brand ramp */
  --tp-brand-900: #2a0437;
  --tp-brand-800: #350645;
  --tp-brand-700: #4a0d5e;
  --tp-brand-600: #792c93;
  --tp-brand-500: #9340ad;
  --tp-brand-400: #b96fd0;
  --tp-brand-200: #e6cdef;

  /* Accents, shared by both themes */
  --tp-indigo: #6366f1;
  --tp-blue:   #3b82f6;

  /* Action blue — the owner-chosen colour for the "do something" buttons
     (Add New, Import from Provider, bulk Apply). See .tp-btn-action. */
  --tp-action-blue:     #3d68b0;
  --tp-action-blue-700: #345a97;
  --tp-action-blue-800: #2b4a7d;

  --tp-amber:  #f59e0b;
  --tp-red:    #ef4444;

  /* Sign-in background (Admin\UI\LoginBackground + section 10 of
     toral-admin-components.css). A fixed palette, not a themed one: the
     sign-in page is the one screen shown before any admin preference is
     known, and the panel has a single identity there. Blue leads, amber is
     the small accent, the base is near-black. */
  --tp-loginbg-base: #070c16;
  --tp-loginbg-1:    #1d4ed8;
  --tp-loginbg-2:    #3b82f6;
  --tp-loginbg-3:    #f2b307;
  --tp-green:  #10b981;
  --tp-teal:   #14b8a6;

  /* Customer levels (Levels\LevelSettings slugs). Same hues as the userside
     --tp-us-level-* tokens so a level looks the same on both sides. */
  --tp-level-new:     #8b94a6;
  --tp-level-bronze:  #a8652f;
  --tp-level-silver:  #7f8a99;
  --tp-level-gold:    #b7860b;
  --tp-level-diamond: #1b93c4;
  --tp-level-on:      #ffffff;

  /* Geometry */
  --tp-radius-xl: 25px;
  --tp-radius-lg: 16px;
  --tp-radius-md: 10px;
  --tp-radius-sm: 8px;
  --tp-radius-pill: 999px;

  --tp-gap: 10px;
  --tp-sidebar-w: 250px;
  --tp-sidebar-w-collapsed: 78px;
  --tp-chrome-h: 68px;

  --tp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Vazirmatn, Roboto,
             "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --tp-transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

/* Light theme (default) */
:root,
[data-tp-theme="light"] {
  --tp-app-bg:        #e1e1e1;
  --tp-surface:       #ffffff;
  --tp-surface-2:     #f6f7f9;
  --tp-surface-3:     #eceef2;
  --tp-border:        #e2e5ea;
  --tp-border-strong: #cdd2da;

  --tp-text:      #1c2434;
  --tp-text-soft: #5a6478;
  --tp-text-dim:  #8b94a6;

  --tp-sidebar-bg:      var(--tp-brand-800);
  --tp-sidebar-text:    #ffffff;
  --tp-sidebar-hover:   rgba(255, 255, 255, .12);
  --tp-sidebar-active:  var(--tp-brand-600);
  --tp-sidebar-stripe:  rgba(255, 255, 255, .035);
  --tp-sidebar-group:   rgba(255, 255, 255, .55);

  --tp-header-bg:     var(--tp-brand-600);
  --tp-header-text:   #ffffff;
  --tp-header-hover:  rgba(255, 255, 255, .16);
  --tp-header-stripe: rgba(255, 255, 255, .05);

  --tp-shadow-sm: 0 1px 2px rgba(23, 25, 35, .06);
  --tp-shadow:    0 4px 16px rgba(23, 25, 35, .08);
  --tp-shadow-lg: 0 12px 34px rgba(23, 25, 35, .16);

  --tp-table-stripe: #fafbfc;
  --tp-table-head:   #f4f5f8;

  /* Service pickers: the provider-services list and the API-service-id
     suggestions in Add New. The list box used to be painted by a hard-coded
     dark inline <style> block inside ServicesPage.php; this is the
     owner-chosen lavender in its place. */
  --tp-picker-bg:     #f2e2fc;
  --tp-picker-border: #ddc4ee;
  --tp-picker-hover:  #e7d0f8;
}

/* Dark theme */
[data-tp-theme="dark"] {
  --tp-app-bg:        #121017;
  --tp-surface:       #1c1922;
  --tp-surface-2:     #24202c;
  --tp-surface-3:     #2c2735;
  --tp-border:        #332d3e;
  --tp-border-strong: #453d53;

  --tp-text:      #ebe7f0;
  --tp-text-soft: #a9a2b8;
  --tp-text-dim:  #7d7590;

  --tp-sidebar-bg:      var(--tp-brand-900);
  --tp-sidebar-text:    #ffffff;
  --tp-sidebar-hover:   rgba(255, 255, 255, .1);
  --tp-sidebar-active:  var(--tp-brand-700);
  --tp-sidebar-stripe:  rgba(255, 255, 255, .028);
  --tp-sidebar-group:   rgba(255, 255, 255, .5);

  --tp-header-bg:     var(--tp-brand-700);
  --tp-header-text:   #ffffff;
  --tp-header-hover:  rgba(255, 255, 255, .12);
  --tp-header-stripe: rgba(255, 255, 255, .04);

  --tp-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --tp-shadow:    0 4px 16px rgba(0, 0, 0, .45);
  --tp-shadow-lg: 0 12px 34px rgba(0, 0, 0, .6);

  --tp-table-stripe: #211d29;
  --tp-table-head:   #272230;

  /* The same picker in the dark theme: the light theme's lavender taken down
     into the surface range so the labels keep their contrast. */
  --tp-picker-bg:     #2b2135;
  --tp-picker-border: #453d53;
  --tp-picker-hover:  #372a45;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

/* The page itself never scrolls: the sidebar nav and the content surface each
   scroll on their own, so the brand block, the sidebar and the header stay put. */
body.tp-body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  padding: var(--tp-gap);
  background: var(--tp-app-bg);
  color: var(--tp-text);
  font: 14px/1.65 var(--tp-font);
  -webkit-font-smoothing: antialiased;
}

/* Scoped to the content surface on purpose. A blanket `.tp-body a` rule outranks
   the chrome's own component rules (higher specificity), which silently repainted
   the sidebar links and the header icons in the brand colour. */
/* A link that is styled as a button is excluded: this rule (0,1,1) outranks
   `.tp-btn-primary` (0,1,0), which is why "Add New Provider" rendered as brand
   text on a brand background — the label was invisible. */
.tp-content a:not(.tp-btn) { color: var(--tp-brand-600); text-decoration: none; }
.tp-content a:not(.tp-btn):hover { text-decoration: underline; }
[data-tp-theme="dark"] .tp-content a:not(.tp-btn) { color: var(--tp-brand-400); }

.tp-icon { flex: none; display: block; }

:where(.tp-body) :focus-visible {
  outline: 2px solid var(--tp-brand-500);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. App layout
   -------------------------------------------------------------------------- */

.tp-app {
  display: grid;
  grid-template-columns: var(--tp-sidebar-w) minmax(0, 1fr);
  gap: var(--tp-gap);
  height: 100%;
  transition: grid-template-columns var(--tp-transition);
}

html.tp-sidebar-collapsed .tp-app {
  grid-template-columns: var(--tp-sidebar-w-collapsed) minmax(0, 1fr);
}

.tp-sidebar-col,
.tp-main-col {
  display: flex;
  flex-direction: column;
  gap: var(--tp-gap);
  min-width: 0;
  min-height: 0; /* lets the scrolling child shrink inside the flex column */
}

/* --------------------------------------------------------------------------
   4. Brand block
   -------------------------------------------------------------------------- */

.tp-brand {
  position: relative;
  flex: none;
  height: var(--tp-chrome-h);
  border-radius: var(--tp-radius-xl);
  background: var(--tp-sidebar-bg);
  box-shadow: var(--tp-shadow);
  overflow: hidden;
}

/* Same diagonal texture as the sidebar, so the two panels read as one surface. */
.tp-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--tp-sidebar-stripe) 0,
    var(--tp-sidebar-stripe) 1px,
    transparent 1px,
    transparent 13px
  );
}

.tp-brand-link {
  position: relative; /* above the texture layer */
  display: flex;
  align-items: center;
  gap: 11px;
  height: 100%;
  padding-inline: 20px;
  color: #fff;
  text-decoration: none;
}
.tp-brand-link:hover { text-decoration: none; }

.tp-brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--tp-radius-md);
  background: linear-gradient(135deg, var(--tp-brand-500), var(--tp-brand-600));
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .5px;
}

/* Logo picture (the Toral badge, or the site's own picture with the white-label right). */
.tp-brand-img { flex: none; display: block; width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.tp-brand-img:only-child { width: auto; max-width: 100%; height: auto; max-height: 46px; border-radius: var(--tp-radius-md); object-fit: contain; }

.tp-brand-text {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: .3px;
  white-space: nowrap;
  transition: opacity var(--tp-transition);
}
.tp-brand-text b { font-weight: 800; }

html.tp-sidebar-collapsed .tp-brand-link { padding-inline: 0; justify-content: center; }
html.tp-sidebar-collapsed .tp-brand-text { display: none; }

/* Toral lockup (mark + stacked text) on the dark brand block; collapsed sidebar shows the mark only. */
.tp-brand-img.tp-brand-lockup { width: auto; max-width: 100%; height: 46px; border-radius: 0; object-fit: contain; }
html.tp-sidebar-collapsed .tp-brand-img.tp-brand-lockup { width: 50px; height: 44px; object-fit: cover; object-position: left center; }

/* --------------------------------------------------------------------------
   5. Sidebar
   -------------------------------------------------------------------------- */

.tp-sidebar {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 12px 56px;
  border-radius: var(--tp-radius-xl);
  background: var(--tp-sidebar-bg);
  box-shadow: var(--tp-shadow);
  overflow: hidden;
}

/* Faint diagonal texture, drawn in CSS so no image asset is needed. */
.tp-sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--tp-sidebar-stripe) 0,
    var(--tp-sidebar-stripe) 1px,
    transparent 1px,
    transparent 13px
  );
}

.tp-sidebar > * { position: relative; }

/* Search */
.tp-sidebar-search {
  flex: none;
  position: relative;
  margin-bottom: 14px;
}

.tp-sidebar-search-icon {
  position: absolute;
  inset-inline-start: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tp-sidebar-text);
  opacity: .7;
  pointer-events: none;
}

.tp-sidebar-search-input {
  width: 100%;
  height: 38px;
  padding-inline: 36px 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--tp-radius-md);
  background: rgba(255, 255, 255, .07);
  color: #fff;
  font: inherit;
  font-size: 13px;
  transition: border-color var(--tp-transition), background var(--tp-transition);
}
.tp-sidebar-search-input::placeholder { color: var(--tp-sidebar-text); opacity: .6; }
.tp-sidebar-search-input:focus {
  outline: none;
  border-color: var(--tp-brand-400);
  background: rgba(255, 255, 255, .12);
}
.tp-sidebar-search-input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }

html.tp-sidebar-collapsed .tp-sidebar-search-input { padding-inline: 12px; color: transparent; }
html.tp-sidebar-collapsed .tp-sidebar-search-input::placeholder { color: transparent; }
html.tp-sidebar-collapsed .tp-sidebar-search-icon {
  inset-inline-start: 50%;
  transform: translate(-50%, -50%);
}
html.tp-sidebar-collapsed[dir="rtl"] .tp-sidebar-search-icon { transform: translate(50%, -50%); }

/* Nav */
.tp-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .2) transparent;
}
.tp-nav::-webkit-scrollbar { width: 6px; }
.tp-nav::-webkit-scrollbar-thumb {
  border-radius: var(--tp-radius-pill);
  background: rgba(255, 255, 255, .18);
}

.tp-nav-group {
  margin: 16px 0 6px;
  padding-inline: 12px;
  color: var(--tp-sidebar-group);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  white-space: nowrap;
}
.tp-nav-group:first-child { margin-top: 0; }

html.tp-sidebar-collapsed .tp-nav-group {
  padding-inline: 0;
  text-align: center;
  font-size: 0;
}
html.tp-sidebar-collapsed .tp-nav-group::after {
  content: "";
  display: block;
  height: 1px;
  margin: 10px 16px;
  background: rgba(255, 255, 255, .13);
}

.tp-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 3px;
  padding: 10px 12px;
  border-radius: var(--tp-radius-md);
  color: var(--tp-sidebar-text);
  font-size: 13.5px;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--tp-transition), color var(--tp-transition);
}
.tp-nav-link:hover {
  background: var(--tp-sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.tp-nav-link.is-active {
  background: var(--tp-sidebar-active);
  color: #fff;
  font-weight: 600;
}

/* Active marker: a vertical bar on the inline-start edge. */
.tp-nav-link.is-active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: var(--tp-radius-pill);
  background: var(--tp-brand-200);
}

.tp-nav-link.is-danger:hover { background: rgba(239, 68, 68, .22); color: #fff; }

/* A paid module outside this site's license (Admin\UI\ModuleLock). */
.tp-nav-link.is-locked { opacity: .5; }
.tp-nav-link.is-locked:hover { opacity: .8; }
.tp-nav-lock { flex: none; display: grid; place-items: center; margin-inline-start: auto; }
html.tp-sidebar-collapsed .tp-nav-lock { display: none; }

.tp-nav-icon { flex: none; display: grid; place-items: center; width: 22px; }
.tp-nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.tp-nav-badge {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 19px;
  padding-inline: 6px;
  border-radius: var(--tp-radius-pill);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.tp-badge-red   { background: var(--tp-red); }
.tp-badge-amber { background: var(--tp-amber); color: #3d2600; }

html.tp-sidebar-collapsed .tp-nav-link { justify-content: center; padding-inline: 0; }
html.tp-sidebar-collapsed .tp-nav-text { display: none; }
html.tp-sidebar-collapsed .tp-nav-badge {
  position: absolute;
  top: 4px;
  inset-inline-end: 10px;
  min-width: 16px;
  height: 16px;
  padding-inline: 4px;
  font-size: 9.5px;
}
html.tp-sidebar-collapsed .tp-nav-link.is-active::before { display: none; }

/* Tooltip for the collapsed rail */
html.tp-sidebar-collapsed .tp-nav-link::after {
  content: attr(data-tp-label);
  position: absolute;
  inset-inline-start: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  padding: 5px 10px;
  border-radius: var(--tp-radius-sm);
  background: var(--tp-brand-900);
  color: #fff;
  font-size: 12px;
  text-transform: capitalize;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--tp-transition);
}
html.tp-sidebar-collapsed .tp-nav-link:hover::after { opacity: 1; visibility: visible; }

.tp-nav-empty {
  margin: 6px 12px;
  color: var(--tp-sidebar-text);
  font-size: 12.5px;
  opacity: .75;
}

/* Search results dropdown (panel-wide search) */
.tp-search-results {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  z-index: 60;
  max-height: 340px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-lg);
  background: var(--tp-surface);
  box-shadow: var(--tp-shadow-lg);
}

.tp-search-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--tp-radius-sm);
  color: var(--tp-text) !important;
  font-size: 13px;
  text-decoration: none !important;
  transition: background var(--tp-transition);
}
.tp-search-item:hover,
.tp-search-item.is-active { background: var(--tp-surface-3); }

.tp-search-label { flex: 1; min-width: 0; }
.tp-search-label mark {
  padding: 0;
  background: color-mix(in srgb, var(--tp-amber) 40%, transparent);
  color: inherit;
  border-radius: 2px;
}

.tp-search-section {
  flex: none;
  color: var(--tp-text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.tp-search-empty {
  margin: 0;
  padding: 12px 10px;
  color: var(--tp-text-dim);
  font-size: 12.5px;
  text-align: center;
}

/* In the collapsed rail there is no room for a dropdown. */
html.tp-sidebar-collapsed .tp-search-results { display: none; }

/* Collapse control pinned to the sidebar footer */
.tp-sidebar-toggle {
  position: absolute;
  inset-block-end: 12px;
  inset-inline-end: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--tp-radius-sm);
  background: rgba(255, 255, 255, .09);
  color: var(--tp-sidebar-text);
  cursor: pointer;
  transition: background var(--tp-transition), color var(--tp-transition);
}
.tp-sidebar-toggle:hover { background: rgba(255, 255, 255, .18); color: #fff; }
html.tp-sidebar-collapsed .tp-sidebar-toggle { inset-inline: 0; margin-inline: auto; }
html.tp-sidebar-collapsed .tp-sidebar-toggle .tp-icon { transform: scaleX(-1); }

/* --------------------------------------------------------------------------
   6. Header
   -------------------------------------------------------------------------- */

.tp-header {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--tp-chrome-h);
  padding-inline: 16px;
  border-radius: var(--tp-radius-xl);
  background: var(--tp-header-bg);
  color: var(--tp-header-text);
  box-shadow: var(--tp-shadow);
}

/* Same diagonal texture as the sidebar, tuned to the header's own colour.
   Kept as ::before (not overflow:hidden) so the dropdown panels can still
   escape the header box. */
.tp-header::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--tp-header-stripe) 0,
    var(--tp-header-stripe) 1px,
    transparent 1px,
    transparent 13px
  );
}

.tp-header-start,
.tp-header-end {
  position: relative; /* above the texture layer */
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tp-header-title {
  margin: 0;
  padding-inline-start: 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-header-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 38px;
  height: 38px;
  padding-inline: 9px;
  border: 0;
  border-radius: var(--tp-radius-md);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--tp-transition);
}
.tp-header-btn:hover { background: var(--tp-header-hover); text-decoration: none; }
.tp-menu.is-open > .tp-header-btn { background: var(--tp-header-hover); }

.tp-avatar-btn {
  border: 2px solid rgba(255, 255, 255, .45);
  border-radius: var(--tp-radius-pill);
}

.tp-header-badge {
  position: absolute;
  top: 3px;
  inset-inline-end: 2px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding-inline: 4px;
  border: 2px solid var(--tp-header-bg);
  border-radius: var(--tp-radius-pill);
  background: var(--tp-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.tp-clock-readout {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tp-caret { transition: transform var(--tp-transition); }
.tp-menu.is-open .tp-caret { transform: rotate(180deg); }

.tp-hamburger { display: none; }

/* --------------------------------------------------------------------------
   7. Dropdown menus
   -------------------------------------------------------------------------- */

.tp-menu { position: relative; }

.tp-menu-panel {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 60;
  min-width: 192px;
  padding: 6px;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-lg);
  background: var(--tp-surface);
  color: var(--tp-text);
  box-shadow: var(--tp-shadow-lg);
}
.tp-menu-panel-wide { min-width: 214px; }

.tp-menu-title {
  padding: 7px 10px 5px;
  color: var(--tp-text-dim);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.tp-menu-note {
  padding: 2px 10px 8px;
  color: var(--tp-text-soft);
  font-size: 12.5px;
}

.tp-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--tp-radius-sm);
  background: transparent;
  color: var(--tp-text);
  font: inherit;
  font-size: 13px;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--tp-transition);
}
.tp-menu-item:hover { background: var(--tp-surface-3); text-decoration: none; }
.tp-menu-item.is-danger { color: var(--tp-red); }
.tp-menu-item.is-danger:hover { background: rgba(239, 68, 68, .1); }

.tp-menu-item-text { flex: 1; }

.tp-menu-check {
  flex: none;
  width: 15px;
  height: 15px;
  border-radius: var(--tp-radius-pill);
  border: 2px solid var(--tp-border-strong);
  transition: border-color var(--tp-transition), background var(--tp-transition);
}
.tp-menu-item.is-selected .tp-menu-check {
  border-color: var(--tp-brand-600);
  background: var(--tp-brand-600);
  box-shadow: inset 0 0 0 2.5px var(--tp-surface);
}

.tp-menu-sep {
  height: 1px;
  margin: 5px 6px;
  background: var(--tp-border);
}

/* --------------------------------------------------------------------------
   8. Content surface
   -------------------------------------------------------------------------- */

/* The only scroll container for page content; the header above it stays fixed. */
.tp-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px;
  border-radius: var(--tp-radius-xl);
  background: var(--tp-surface);
  box-shadow: var(--tp-shadow);
  scrollbar-width: thin;
  scrollbar-color: var(--tp-border-strong) transparent;
}
.tp-content::-webkit-scrollbar { width: 9px; }
.tp-content::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--tp-radius-pill);
  background: var(--tp-border-strong);
  background-clip: content-box;
}

.tp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(18, 16, 23, .5);
  backdrop-filter: blur(2px);
}

/* --------------------------------------------------------------------------
   9. Alerts
   -------------------------------------------------------------------------- */

.tp-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 15px;
  border: 1px solid var(--tp-border);
  border-inline-start: 3px solid var(--tp-text-dim);
  border-radius: var(--tp-radius-md);
  background: var(--tp-surface-2);
  font-size: 13.5px;
}
.tp-alert-icon { flex: none; margin-top: 2px; }
.tp-alert-text { flex: 1; }
/* Close button of a warning that may be hidden (Shell::dependency_banner). */
.tp-alert-close {
  flex: none;
  border: 0;
  background: none;
  color: var(--tp-text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.tp-alert-close:hover { color: var(--tp-text); }
/* Close button sent as a form (UI\RenterGuide::notice). */
.tp-alert > form { flex: none; margin: 0; }

/* The var() background is the fallback for browsers without color-mix(). */
.tp-alert-warning {
  border-inline-start-color: var(--tp-amber);
  background: var(--tp-surface-2);
  background: color-mix(in srgb, var(--tp-amber) 9%, var(--tp-surface));
}
.tp-alert-success {
  border-inline-start-color: var(--tp-green);
  background: var(--tp-surface-2);
  background: color-mix(in srgb, var(--tp-green) 9%, var(--tp-surface));
}
.tp-alert-error {
  border-inline-start-color: var(--tp-red);
  background: var(--tp-surface-2);
  background: color-mix(in srgb, var(--tp-red) 9%, var(--tp-surface));
}
.tp-alert-info {
  border-inline-start-color: var(--tp-blue);
  background: var(--tp-surface-2);
  background: color-mix(in srgb, var(--tp-blue) 9%, var(--tp-surface));
}

/* Pages emit alert bodies as <p>; keep them flush inside the box. */
.tp-alert p { margin: 0; }
.tp-alert p + p { margin-top: 6px; }

/* --------------------------------------------------------------------------
   10. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1200px) {
  :root { --tp-sidebar-w: 224px; }
}

/* Tablet and below: the sidebar becomes an off-canvas drawer. */
@media (max-width: 991px) {
  body.tp-body { padding: 8px; }

  .tp-app,
  html.tp-sidebar-collapsed .tp-app { grid-template-columns: minmax(0, 1fr); }

  .tp-sidebar-col {
    position: fixed;
    inset-block: 8px;
    inset-inline-start: 8px;
    z-index: 50;
    width: var(--tp-sidebar-w);
    max-width: calc(100vw - 60px);
    transform: translateX(calc((var(--tp-sidebar-w) + 20px) * -1));
    transition: transform var(--tp-transition);
  }
  html[dir="rtl"] .tp-sidebar-col {
    transform: translateX(calc(var(--tp-sidebar-w) + 20px));
  }

  html.tp-sidebar-open .tp-sidebar-col { transform: translateX(0); }

  /* The rail never collapses in drawer mode. */
  html.tp-sidebar-collapsed .tp-sidebar-col { width: var(--tp-sidebar-w); }
  html.tp-sidebar-collapsed .tp-brand-text,
  html.tp-sidebar-collapsed .tp-nav-text { display: initial; }
  html.tp-sidebar-collapsed .tp-nav-link { justify-content: flex-start; padding-inline: 12px; }
  html.tp-sidebar-collapsed .tp-brand-link { justify-content: flex-start; padding-inline: 20px; }
  html.tp-sidebar-collapsed .tp-nav-link::after { display: none; }
  html.tp-sidebar-collapsed .tp-nav-group { padding-inline: 12px; text-align: start; font-size: 10.5px; }
  html.tp-sidebar-collapsed .tp-nav-group::after { display: none; }
  html.tp-sidebar-collapsed .tp-sidebar-search-input { padding-inline: 36px 12px; color: #fff; }
  html.tp-sidebar-collapsed .tp-sidebar-search-icon { inset-inline-start: 11px; transform: translateY(-50%); }
  html.tp-sidebar-collapsed .tp-nav-badge { position: static; min-width: 20px; height: 19px; font-size: 11px; }

  .tp-sidebar-toggle { display: none; }
  .tp-hamburger { display: inline-flex; }
  .tp-header-title { font-size: 15.5px; }
}

@media (max-width: 640px) {
  .tp-content { padding: 15px; }
  .tp-header { padding-inline: 10px; }
  .tp-header-title { display: none; }
  .tp-clock-readout { display: none; }
  .tp-menu-panel { min-width: 178px; }
}

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