:root {
  --primary: #1d5f9e;
  --primary-dark: #154a7c;
  --primary-soft: #eaf3fb;
  --accent: #0f766e;
  --danger: #c53b3b;
  --ink: #172433;
  --muted: #607080;
  --line: #dbe4ec;
  --surface: #ffffff;
  --surface-soft: #f4f7fa;
  --shadow: 0 8px 26px rgba(28, 55, 82, 0.08);
  --bg: #eef3f7;
  --border: var(--line);
  --text: var(--ink);
  --text-2: var(--muted);
  --text-3: #8796a5;
}

html {
  min-height: 100%;
  background: #eef3f7;
}

body.tool-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 24px 56px;
  color: var(--ink);
  background: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.55;
}

body.tool-shell .app-header {
  margin: 0 -24px 24px;
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

body.tool-shell .app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

body.tool-shell .app-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

body.tool-shell .app-brand-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #3987c8);
  color: #fff;
  font-weight: 800;
}

body.tool-shell .app-brand strong,
body.tool-shell .app-brand small {
  display: block;
}

body.tool-shell .app-brand strong {
  color: var(--ink);
  font-size: 18px;
}

body.tool-shell .app-brand small {
  color: var(--muted);
  font-size: 12px;
}

body.tool-shell .nav-menu {
  display: flex;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0 0 3px;
  overflow-x: auto;
  background: transparent;
  border-radius: 0;
  scrollbar-width: thin;
}

body.tool-shell .nav-menu button,
body.tool-shell .nav-menu .suite-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 38px;
  margin: 0;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: #40566c;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
}

body.tool-shell .nav-menu button:hover,
body.tool-shell .nav-menu .suite-home-link:hover {
  border-color: transparent;
  background: var(--primary-soft);
  box-shadow: none;
  color: var(--primary-dark);
  transform: none;
}

body.tool-shell .nav-menu .suite-home-link {
  border-color: #d6e5f1;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

body.tool-shell #loginStatus {
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 56%;
  padding: 5px 7px 5px 12px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  box-shadow: none;
  color: #40566c;
  font-size: 13px;
  white-space: normal;
  backdrop-filter: none;
}

body.tool-shell #loginStatus > span:first-child {
  max-width: 180px;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.tool-shell #loginStatus > span:first-child::before {
  content: none;
}

body.tool-shell #accountButton,
body.tool-shell #logoutButton,
body.tool-shell #adminPanelButton {
  min-height: 30px;
  margin: 0 0 0 3px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  box-shadow: none;
  font-size: 12px;
  line-height: 1.2;
}

body.tool-shell #accountButton {
  border-color: #ccd8e2;
  background: #607585;
  color: #fff;
}

body.tool-shell #logoutButton {
  border-color: #e6bcbc;
  background: #fff;
  color: var(--danger);
}

body.tool-shell #adminPanelButton {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

body.tool-shell button {
  min-height: 42px;
  margin: 4px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  box-shadow: none;
  transition: background-color 0.16s ease, border-color 0.16s ease,
    transform 0.16s ease, box-shadow 0.16s ease;
}

body.tool-shell button:hover {
  background: var(--primary-dark);
  box-shadow: 0 5px 14px rgba(29, 95, 158, 0.18);
  transform: translateY(-1px);
}

body.tool-shell button:active {
  transform: translateY(0);
}

body.tool-shell button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

body.tool-level .tool-card {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
}

body.tool-level .tool-card:hover {
  border-color: #9dbed9;
  background: #fff;
  color: var(--ink);
}

body.tool-shell button.ghost,
body.tool-shell .secondary-action,
body.tool-shell .secondary-button {
  border-color: #ccd8e2;
  background: #eef3f7;
  color: #34495e;
}

body.tool-shell button.ghost:hover,
body.tool-shell .secondary-action:hover,
body.tool-shell .secondary-button:hover {
  background: #e2eaf1;
  color: #263c50;
}

body.tool-shell input,
body.tool-shell select {
  min-height: 44px;
  border-color: #c7d4df;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}

body.tool-shell input:focus,
body.tool-shell select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 95, 158, 0.13);
}

body.tool-shell table {
  border-color: var(--line);
  border-radius: 10px;
  background: #fff;
}

body.tool-shell th,
body.tool-shell td {
  border-color: var(--line);
  font-variant-numeric: tabular-nums;
}

body.tool-shell th {
  background: #edf3f8;
  color: #314b63;
}

body.tool-flow #app {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.tool-flow #app > div {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

body.tool-flow #app h2 {
  color: var(--primary-dark);
}

body.tool-flow #admin-logout-btn,
body.tool-flow #user-logout-btn,
body.tool-section #logout-btn {
  display: none !important;
}

body.tool-section .container {
  width: 100%;
  max-width: none;
  margin: 0 auto 48px;
  padding: 0;
}

body.tool-section .container > h1 {
  display: none;
}

body.tool-section .card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

body.tool-section .top-bar {
  justify-content: flex-end;
  margin-bottom: 14px;
}

body.tool-section .top-bar > div:first-child {
  display: none;
}

body.tool-shell #saveStatus {
  left: 50%;
  right: auto;
  bottom: 18px;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  border-radius: 999px;
  background: #223548;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  text-align: center;
}

@media (max-width: 760px) {
  body.tool-shell {
    padding: 0 12px 42px;
  }

  body.tool-shell .app-header {
    margin: 0 -12px 16px;
    padding: 13px 12px 9px;
  }

  body.tool-shell .app-brand small {
    display: none;
  }

  body.tool-shell .app-brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  body.tool-shell #loginStatus {
    max-width: 64%;
    padding: 5px 7px 5px 9px;
    font-size: 12px;
  }

  body.tool-shell #loginStatus > span:first-child {
    max-width: 76px;
  }

  body.tool-shell #accountButton,
  body.tool-shell #logoutButton,
  body.tool-shell #adminPanelButton {
    padding: 5px 7px;
    font-size: 11px;
  }

  body.tool-shell .nav-menu {
    margin-top: 10px;
  }

  body.tool-shell .nav-menu button,
  body.tool-shell .nav-menu .suite-home-link {
    padding: 7px 10px;
    font-size: 13px;
  }

  body.tool-flow #app > div,
  body.tool-section .card {
    padding: 14px;
    border-radius: 12px;
  }

  body.tool-section .container {
    margin-bottom: 24px;
  }

  body.tool-shell #saveStatus {
    right: auto;
    bottom: 12px;
  }
}

@media (max-width: 520px) {
  body.tool-shell #loginStatus > span:first-child {
    display: none;
  }
}
