/* AK console skin: preserves Sub2API navigation, forms, charts and theme switch. */
body:has(aside.sidebar) {
  --ak-paper: #e8dfca;
  --ak-surface: #f6efdf;
  --ak-inset: #e1d6bf;
  --ak-ink: #292720;
  --ak-muted: #706553;
  --ak-line: #39372f;
  --ak-red: #ae402e;
  --ak-accent-ink: #ae402e;
  --ak-red-ink: #fff6e4;
  --ak-blue: #355c70;
  --ak-gold: #e7bb52;
  --ak-green: #356b4b;
  --ak-danger: #b33229;
  --ak-shadow: #292720;
  --ak-dot: #39372f16;
  background: var(--ak-paper) !important;
  color: var(--ak-ink) !important;
  font-family: "Helvetica Now Var", "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif !important;
}
html.dark body:has(aside.sidebar) {
  --ak-paper: #232c31;
  --ak-surface: #303b40;
  --ak-inset: #263136;
  --ak-ink: #f2e8d0;
  --ak-muted: #c1b79f;
  --ak-line: #10191d;
  --ak-red: #bd503b;
  --ak-accent-ink: #f29b80;
  --ak-red-ink: #fff6e4;
  --ak-blue: #91bfd2;
  --ak-green: #9dce9a;
  --ak-danger: #ff9c88;
  --ak-shadow: #10191d;
  --ak-dot: #eedfc80a;
  color-scheme: dark;
}
body:has(aside.sidebar) #app > .min-h-screen {
  background: var(--ak-paper) !important;
  color: var(--ak-ink);
  background-image: radial-gradient(var(--ak-dot) 0.8px, transparent 0.8px) !important;
  background-size: 6px 6px !important;
}
body:has(aside.sidebar) .bg-mesh-gradient { display: none !important; }

/* A painted field case, with the native collapsible/mobile navigation intact. */
body:has(aside.sidebar) aside.sidebar {
  background: #222c31 !important;
  border-right: 3px solid #171d20 !important;
  box-shadow: 4px 0 0 #171d2020 !important;
  color: #f2e8d0 !important;
  backdrop-filter: none !important;
}
body:has(aside.sidebar) .sidebar-header {
  min-height: 88px;
  background: #1c262b !important;
  border-bottom: 2px solid #0e171a !important;
}
body:has(aside.sidebar) .sidebar-logo {
  border-radius: 2px !important;
  box-shadow: 3px 3px 0 #10191d !important;
  transform: rotate(-5deg);
  overflow: visible !important;
}
body:has(aside.sidebar) .sidebar-brand-title {
  color: #f4e9cf !important;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 34px !important;
  font-style: italic;
  letter-spacing: -1px;
  line-height: 1;
}
body:has(aside.sidebar) .sidebar-brand button {
  background: transparent !important;
  color: #b9ae93 !important;
  border-radius: 0 !important;
  padding-left: 0 !important;
  font-size: 10px !important;
  letter-spacing: 0.06em;
}
body:has(aside.sidebar) .sidebar-section-title {
  color: #bfb291 !important;
  letter-spacing: 0.12em;
  font-weight: 800;
}
body:has(aside.sidebar) .sidebar-link {
  color: #ded5bf !important;
  border: 1px solid transparent;
  border-radius: 2px !important;
  transition: background-color 0.15s, border-color 0.15s;
}
body:has(aside.sidebar) .sidebar-link:hover {
  background: #39474d !important;
  color: #fff7e5 !important;
  border-color: #69716c;
}
body:has(aside.sidebar) .sidebar-link-active,
body:has(aside.sidebar) .sidebar-link-active:hover {
  background: #b74a35 !important;
  color: #fff4dc !important;
  border: 1px solid #131e22 !important;
  box-shadow: 3px 3px 0 #10191d !important;
  font-weight: 800;
}
body:has(aside.sidebar) .sidebar-link svg { color: inherit !important; }
body:has(aside.sidebar) aside > .mt-auto {
  background: #1c262b !important;
  border-color: #0e171a !important;
}
body:has(aside.sidebar) aside > .mt-auto button {
  color: #e6d9b8 !important;
  border-radius: 2px !important;
}
body:has(aside.sidebar) aside > .mt-auto button:hover { background: #39474d !important; }

/* Shell, paper cards and a dashboard-only squad banner. */
body:has(aside.sidebar) header.glass {
  background: var(--ak-surface) !important;
  border-bottom: 2px solid var(--ak-line) !important;
  backdrop-filter: none !important;
  box-shadow: 0 3px 0 #171d2010;
}
body:has(aside.sidebar) header.glass h1 { font-weight: 900 !important; }
body:has(aside.sidebar) main { position: relative; }
body:has(.sidebar-link-active:is([href="/admin/dashboard"], [href="/dashboard"])) main::before {
  content: "AK / MISSION CONTROL\A 指挥你的 AI 战队。";
  display: flex;
  align-items: center;
  white-space: pre-line;
  min-height: 166px;
  margin-bottom: 26px;
  padding: 27px 30px;
  border: 2px solid var(--ak-line);
  border-left: 8px solid var(--ak-red);
  border-radius: 2px;
  box-shadow: 5px 5px 0 var(--ak-shadow);
  color: #f5e9cb;
  background:
    linear-gradient(90deg, #25343b 0%, #25343bf2 34%, #25343b24 76%),
    url("/ak-assets/tf2-squad.webp") right 40% / auto 265px no-repeat,
    #25343b;
  font-weight: 900;
  font-size: clamp(22px, 2.3vw, 36px);
  line-height: 1.55;
  letter-spacing: -0.035em;
}
body:has(aside.sidebar) :is(.card, .card-glass) {
  background: var(--ak-surface) !important;
  border: 1.5px solid var(--ak-line) !important;
  border-radius: 3px !important;
  box-shadow: 4px 4px 0 var(--ak-shadow) !important;
  backdrop-filter: none !important;
}
body:has(aside.sidebar) main > .space-y-6 > .grid > .card {
  border-top: 4px solid var(--ak-red) !important;
}
body:has(aside.sidebar) main > .space-y-6 > .grid > .card:nth-child(2n) {
  border-top-color: #527b8a !important;
}
body:has(aside.sidebar) main > .space-y-6 > .grid > .card:nth-child(3n) {
  border-top-color: #d3a746 !important;
}
body:has(aside.sidebar) main > .space-y-6 > .grid > .card .text-xl {
  font-size: 30px !important;
  font-weight: 900 !important;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}
body:has(aside.sidebar) main > .space-y-6 > .grid > .card .rounded-lg {
  background: var(--ak-inset) !important;
  border: 1px solid var(--ak-line);
  border-radius: 2px !important;
}

/* Override palette utilities only within the signed-in application. */
body:has(aside.sidebar) :is(.text-gray-900, .text-gray-800, .text-gray-700, .text-gray-600) {
  color: var(--ak-ink) !important;
}
body:has(aside.sidebar) :is(.text-gray-500, .text-gray-400) { color: var(--ak-muted) !important; }
html.dark body:has(aside.sidebar) :is([class~="dark:text-white"], [class~="dark:text-gray-200"], [class~="dark:text-gray-300"]) {
  color: var(--ak-ink) !important;
}
html.dark body:has(aside.sidebar) :is([class~="dark:text-dark-400"], [class~="dark:text-gray-400"], [class~="dark:text-gray-500"]) {
  color: var(--ak-muted) !important;
}
body:has(aside.sidebar) :is(.text-primary-500, .text-primary-600, .text-primary-700, [class~="dark:text-primary-300"], [class~="dark:text-primary-400"]) {
  color: var(--ak-accent-ink) !important;
}
body:has(aside.sidebar) :is(.text-green-600, .text-emerald-600, [class~="dark:text-green-400"], [class~="dark:text-emerald-400"]) {
  color: var(--ak-green) !important;
}
body:has(aside.sidebar) :is(.text-red-600, .text-rose-600, [class~="dark:text-red-400"], [class~="dark:text-rose-400"]) {
  color: var(--ak-danger) !important;
}
body:has(aside.sidebar) :is(.bg-white, .bg-gray-50, .bg-gray-100, [class~="dark:bg-dark-800"], [class~="dark:bg-dark-900"]) {
  background-color: var(--ak-surface) !important;
}
body:has(aside.sidebar) :is([class~="dark:bg-dark-800/50"], .bg-primary-50, .bg-primary-100) {
  background: var(--ak-inset) !important;
}
body:has(aside.sidebar) :is(.border-gray-100, .border-gray-200, .border-gray-300) {
  border-color: color-mix(in srgb, var(--ak-muted) 45%, transparent) !important;
}
body:has(aside.sidebar) :is(h1, h2, h3) { letter-spacing: -0.025em; }
body:has(aside.sidebar) main :is(h2, h3) { font-weight: 850 !important; }

/* Native controls retain focus, disabled, validation and status states. */
body:has(aside.sidebar) :is(.btn, .date-picker-trigger, .select-trigger, .input, .textarea, input[type="search"], select) {
  border-radius: 2px !important;
  border: 1.5px solid var(--ak-line) !important;
  background: var(--ak-surface) !important;
  color: var(--ak-ink) !important;
  box-shadow: 2px 2px 0 var(--ak-shadow) !important;
}
body:has(aside.sidebar) :is(.btn-primary, button.bg-primary-600, a.bg-primary-600) {
  background: var(--ak-red) !important;
  color: var(--ak-red-ink) !important;
  border: 1.5px solid var(--ak-line) !important;
  border-radius: 2px !important;
  box-shadow: 3px 3px 0 var(--ak-shadow) !important;
  font-weight: 750;
}
body:has(aside.sidebar) :is(.btn-primary, .btn-secondary):hover:not(:disabled) {
  filter: brightness(1.08);
}
body:has(aside.sidebar) :is(.input, .textarea, input[type="search"], select) {
  box-shadow: none !important;
  background: var(--ak-inset) !important;
}
body:has(aside.sidebar) :is(input, textarea)::placeholder { color: var(--ak-muted) !important; opacity: 0.85; }
body:has(aside.sidebar) :is(button, a, input, select, textarea):focus-visible {
  outline: 3px solid var(--ak-gold) !important;
  outline-offset: 3px !important;
}
body:has(aside.sidebar) :is(button, input, select, textarea):disabled { opacity: 0.5; }
body:has(aside.sidebar) input[type="checkbox"] { accent-color: var(--ak-red); }
body:has(aside.sidebar) main button.group {
  border: 1px solid var(--ak-line);
  border-radius: 2px !important;
}
body:has(aside.sidebar) main button.group:hover { background: var(--ak-inset) !important; }
body:has(aside.sidebar) header.glass [class*="bg-gradient-to-br"] {
  background: var(--ak-red) !important;
  color: #fff5df !important;
  border: 1px solid var(--ak-line);
  border-radius: 2px !important;
}

/* Tables, menus and dialogs keep their original overflow and positioning. */
body:has(aside.sidebar) :is(.table, table) { color: var(--ak-ink); }
body:has(aside.sidebar) :is(.table, table) thead {
  background: var(--ak-inset) !important;
  color: var(--ak-muted) !important;
  border-bottom: 2px solid var(--ak-line);
}
body:has(aside.sidebar) :is(.table, table) th {
  background: var(--ak-inset) !important;
  color: var(--ak-muted) !important;
  font-weight: 800;
}
body:has(aside.sidebar) :is(.table, table) td { border-color: color-mix(in srgb, var(--ak-muted) 25%, transparent) !important; }
body:has(aside.sidebar) :is(.table, table) td.sticky-col { background: var(--ak-surface) !important; }
body:has(aside.sidebar) :is(.table, table) tbody tr:hover { background: var(--ak-inset) !important; }
body:has(aside.sidebar) :is(.table, table) tbody tr:hover td.sticky-col { background: var(--ak-inset) !important; }
body:has(aside.sidebar) :is(.modal-content, .modal-container, .dropdown-menu, .select-dropdown, .date-picker-dropdown, [role="dialog"]:not(.modal-overlay)) {
  background-color: var(--ak-surface) !important;
  color: var(--ak-ink) !important;
  border: 2px solid var(--ak-line) !important;
  border-radius: 3px !important;
  box-shadow: 6px 6px 0 var(--ak-shadow) !important;
}
body:has(aside.sidebar) :is(.modal-title, .input-label) { color: var(--ak-ink) !important; }
body:has(aside.sidebar) :is(.border-primary-500, .border-primary-600) { border-color: var(--ak-red) !important; }
body:has(aside.sidebar) .navigation-progress-bar { background: #be4b36 !important; }

/* Restore fixed sidebar colors after shared utility overrides. */
body:has(aside.sidebar) aside.sidebar .sidebar-brand-title { color: #f4e9cf !important; }
body:has(aside.sidebar) aside.sidebar .sidebar-brand button { background: transparent !important; color: #b9ae93 !important; }
body:has(aside.sidebar) aside.sidebar .sidebar-link { color: #ded5bf !important; }
body:has(aside.sidebar) aside.sidebar .sidebar-link-active { color: #fff4dc !important; }

@media (max-width: 767px) {
  body:has(.sidebar-link-active:is([href="/admin/dashboard"], [href="/dashboard"])) main::before {
    min-height: 160px;
    padding: 20px 16px;
    font-size: 22px;
    line-height: 1.6;
    background:
      linear-gradient(90deg, #25343bf5 0%, #25343bd9 45%, #25343b44 100%),
      url("/ak-assets/tf2-squad.webp") 65% center / auto 210px no-repeat,
      #25343b;
  }
  body:has(aside.sidebar) main > .space-y-6 > .grid { gap: 12px; }
  body:has(aside.sidebar) main > .space-y-6 > .grid > .card { padding: 12px !important; }
  body:has(aside.sidebar) main > .space-y-6 > .grid > .card > .flex { gap: 8px; }
  body:has(aside.sidebar) main > .space-y-6 > .grid > .card .text-xl { font-size: 25px !important; }
  body:has(aside.sidebar) main > .space-y-6 > .grid > .card p { overflow-wrap: anywhere; }
  body:has(aside.sidebar) main > .space-y-6 > .grid > .card .p-2 { padding: 6px; }
  body:has(aside.sidebar) :is(.card, .card-glass) { box-shadow: 3px 3px 0 var(--ak-shadow) !important; }
}
@media (prefers-reduced-motion: reduce) {
  body:has(aside.sidebar) :is(.sidebar-link, .btn) { transition: none !important; }
}
