:root {
  --top-bg: #0f1722;
  --top-line: #1f2b3a;
  --sidebar-bg: #111923;
  --sidebar-bg-deep: #0b121b;
  --sidebar-text: #cad5e2;
  --sidebar-active: #4b8dff;
  --content-bg: #f4f7fb;
  --panel-bg: #ffffff;
  --panel-line: #e6ebf2;
  --text-main: #1f2937;
  --text-muted: #64748b;
  --btn-blue: #4b8dff;
  --btn-yellow: #f0a54a;
  --btn-red: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top, rgba(64, 158, 255, 0.12), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #f3f7fc 100%);
  overflow-x: hidden;
}

body:not(.login) {
  padding-top: 50px;
}

#container {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

a {
  text-decoration: none;
}

/* Top bar */
#header {
  height: 50px;
  background: var(--top-bg);
  color: var(--text-main);
  border-bottom: 1px solid var(--top-line);
  display: flex;
  align-items: center;
  padding: 0 14px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
}

#branding {
  display: none;
}

#user-tools {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

#user-tools .hhcm-top-icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#user-tools .hhcm-top-icons a {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #93a7be;
}

#user-tools .hhcm-top-icons a:hover {
  background: rgba(140, 185, 255, 0.12);
}

#user-tools .hhcm-user-name {
  color: #dbe5f1;
}

#user-tools .hhcm-link,
#logout-form button {
  color: #8cb9ff;
}

#logout-form {
  display: inline-flex;
}

#logout-form button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

/* Bread crumbs row */
nav[aria-label="Breadcrumbs"] {
  margin: 0;
  min-height: 34px;
  border-bottom: 1px solid var(--top-line);
  background: #111a25;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 50px;
  z-index: 1100;
}

.breadcrumbs {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 12px;
}

/* Main frame */
#main {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: calc(100vh - 84px);
  min-width: 0;
  overflow-x: hidden;
}

.main > #nav-sidebar {
  visibility: visible !important;
  margin-left: 0 !important;
}

.toggle-nav-sidebar {
  display: none !important;
}

#nav-sidebar {
  position: fixed;
  top: 50px;
  left: 0;
  width: 232px;
  height: calc(100vh - 50px);
  max-height: calc(100vh - 50px);
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: var(--sidebar-bg);
  padding: 0;
  z-index: 1090;
}

.hhcm-nav-filter {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.hhcm-sidebar-head {
  height: 50px;
  padding: 0 14px;
  background: var(--sidebar-bg-deep);
  display: flex;
  align-items: center;
  gap: 8px;
}

.hhcm-side-logo {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 0 0 28px;
}

.hhcm-side-logo i {
  position: absolute;
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.hhcm-side-logo i:nth-child(1) {
  background: #36d3c8;
  left: 0;
  top: 7px;
  transform: rotate(25deg);
}

.hhcm-side-logo i:nth-child(2) {
  background: #ffb84d;
  left: 10px;
  top: 2px;
  transform: rotate(25deg);
}

.hhcm-side-logo i:nth-child(3) {
  background: #ff6e67;
  left: 15px;
  top: 12px;
  transform: rotate(25deg);
}

.hhcm-sidebar-label {
  color: #fff;
  font-size: 18px;
  transform: scale(0.5);
  transform-origin: left center;
  margin-right: -58px;
  font-weight: 700;
  white-space: nowrap;
}

.hhcm-menu-root,
.hhcm-menu-sub {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hhcm-menu-root {
  padding: 8px 0;
}

.hhcm-menu-group {
  margin-top: 2px;
}

.hhcm-group-title {
  margin: 0;
  padding: 10px 20px;
  color: #d7e2f1;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hhcm-menu-sub .hhcm-menu-item {
  padding-left: 34px;
  margin: 2px 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.12);
  color: #f2f6fc;
  border-left: 0;
}

.hhcm-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  color: var(--sidebar-text);
  font-size: 14px;
  border-left: 3px solid transparent;
}

a.hhcm-menu-item:hover {
  color: #fff;
  background: #4b6481;
}

.hhcm-menu-sub a.hhcm-menu-item:hover {
  background: #577697;
}

.hhcm-menu-item.current {
  color: #fff;
  background: #4f6c8b;
  border-left-color: var(--sidebar-active);
}

.hhcm-menu-sub .hhcm-menu-item.current {
  border-left-color: transparent;
  background: #5b7da1;
}

.hhcm-menu-item.disabled {
  opacity: 0.45;
}

.hhcm-menu-icon {
  width: 14px;
  text-align: center;
  font-size: 12px;
  opacity: 0.9;
}

.main > #nav-sidebar + .content {
  max-width: 100% !important;
  width: 100%;
  min-width: 0;
  background: transparent;
  padding: 0;
  overflow-x: hidden;
}

#content {
  margin: 14px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: var(--panel-bg);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  padding: 14px;
  min-width: 0;
  overflow-x: hidden;
}

#content-main,
#changelist,
#changelist-form {
  min-width: 0;
  max-width: 100%;
}

#changelist .results {
  overflow-x: auto;
  max-width: 100%;
}

#changelist .results table {
  width: max-content;
  min-width: 100%;
}

/* Login page */
body.login {
  background:
    radial-gradient(circle at top, rgba(65, 113, 171, 0.32), transparent 34%),
    linear-gradient(180deg, #0d141c 0%, #091018 100%);
  padding-top: 0;
}

body.login #header,
body.login nav[aria-label="Breadcrumbs"],
body.login #footer,
body.login #nav-sidebar {
  display: none !important;
}

body.login #main {
  display: block;
  min-height: 100vh;
}

body.login .content {
  max-width: none !important;
  width: 100%;
  padding: 0;
  background: transparent !important;
}

body.login #content {
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

#login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.login-panel {
  width: min(560px, 100%);
  border: 1px solid rgba(115, 140, 173, 0.24);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(21, 30, 42, 0.96) 0%, rgba(16, 24, 34, 0.96) 100%);
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.login-panel-head {
  min-height: 88px;
  padding: 22px 24px 20px;
  background: linear-gradient(135deg, #131d2a 0%, #0e1520 100%);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.login-head-copy h2 {
  margin: 0;
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.login-panel-body {
  padding: 20px 24px 24px;
}

.hhcm-login-form {
  padding: 0;
}

.hhcm-login-form .form-row {
  display: block;
  margin-bottom: 16px;
}

.hhcm-login-form .form-row > label {
  display: block;
  margin: 0 0 8px;
  text-align: left;
  color: #c8d4e4;
  font-size: 14px;
}

.hhcm-login-form .form-row > label span {
  color: #f56c6c;
}

.hhcm-login-form .form-row input[type="text"],
.hhcm-login-form .form-row input[type="password"],
.hhcm-login-form .form-row input[type="email"] {
  width: 100%;
  height: 44px;
  border: 1px solid #2b394a;
  border-radius: 12px;
  padding: 0 14px;
  color: #f0f4fa;
  background: rgba(10, 16, 24, 0.88);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.hhcm-login-form .form-row input::placeholder {
  color: #64778f;
}

.hhcm-login-form .errorlist {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: #ff8d8d;
  font-size: 12px;
}

.hhcm-login-form .submit-row {
  margin: 22px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  gap: 10px;
}

.hhcm-login-form .submit-row input[type="submit"],
.hhcm-login-form .submit-row .btn-reset {
  min-width: 150px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #2b394a;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.hhcm-login-form .submit-row input[type="submit"] {
  border-color: var(--btn-blue);
  background: linear-gradient(135deg, #4b8dff 0%, #2f6fe6 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(47, 111, 230, 0.24);
}

.hhcm-login-form .submit-row .btn-reset {
  background: rgba(17, 26, 37, 0.9);
  color: #c9d5e3;
}

.hhcm-login-form .submit-row input[type="submit"]:hover,
.hhcm-login-form .submit-row .btn-reset:hover {
  transform: translateY(-1px);
}

.errornote {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(92, 28, 28, 0.28);
  color: #ff9d9d;
  font-size: 13px;
}

/* Index page */
.hhcm-workbench {
  margin: -14px;
  background: var(--content-bg);
  min-height: calc(100vh - 119px);
}

.hhcm-tabbar {
  height: 34px;
  padding: 0 12px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  background: #161f2a;
  border-bottom: 1px solid var(--panel-line);
}

.hhcm-tabbar .tab {
  height: 26px;
  line-height: 26px;
  padding: 0 12px;
  border: 1px solid var(--panel-line);
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: #111923;
  color: #8ca0b8;
  font-size: 12px;
}

.hhcm-tabbar .tab.active {
  background: #1a2531;
  color: #8cb9ff;
}

.hhcm-table-panel {
  margin: 14px;
  border: 1px solid var(--panel-line);
  border-radius: 4px;
  background: #121a24;
  padding: 12px;
}

.hhcm-toolbar {
  margin-bottom: 10px;
}

.btn-add {
  display: inline-block;
  height: 30px;
  line-height: 30px;
  padding: 0 14px;
  border-radius: 3px;
  background: var(--btn-yellow);
  color: #fff;
  font-size: 13px;
}

.hhcm-table-wrap {
  overflow: auto;
}

.hhcm-demo-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}

.hhcm-demo-table th,
.hhcm-demo-table td {
  border: 1px solid #243140;
  padding: 10px;
  text-align: center;
  color: #dbe5f1;
  font-size: 13px;
}

.hhcm-demo-table th {
  background: #161f2a;
  color: #8ca0b8;
  font-weight: 600;
}

.hhcm-demo-table td:first-child,
.hhcm-demo-table th:first-child {
  text-align: left;
}

.hhcm-demo-table .group-row td {
  background: #182330;
}

.hhcm-demo-table .sub-cell {
  padding-left: 28px;
}

.op-btn {
  display: inline-block;
  min-width: 58px;
  height: 24px;
  line-height: 24px;
  border-radius: 3px;
  color: #fff;
  font-size: 12px;
  margin: 0 2px;
}

.op-btn.view {
  background: var(--btn-yellow);
}

.op-btn.edit {
  background: var(--btn-blue);
}

.op-btn.del {
  background: var(--btn-red);
}

.op-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Generic admin controls */
input,
textarea,
select,
.vTextField {
  border: 1px solid #d7dfeb;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #4b8dff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(75, 141, 255, 0.16);
}

body.login input,
body.login textarea,
body.login select,
body.login .vTextField {
  border: 1px solid #2b394a;
  background: #111923;
  color: #e8edf5;
}

.module,
.inline-group,
.selector,
.submit-row {
  border-radius: 4px;
  border-color: var(--panel-line);
}

.change-form .submit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  overflow: visible;
}

.change-form .submit-row input,
.change-form .submit-row a.deletelink,
.change-form .submit-row .deletelink-box {
  float: none !important;
  margin: 0 !important;
}

.change-form .submit-row .deletelink-box {
  margin-left: auto !important;
}

.change-form .submit-row a.deletelink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  line-height: 1;
}

.button,
input[type="submit"],
input[type="button"],
.submit-row input,
a.button {
  border-radius: 4px;
}

/* Responsive */
@media (max-width: 960px) {
  #main {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  #nav-sidebar {
    position: relative;
    top: 0;
    width: 100%;
    max-height: none;
  }

  .main > #nav-sidebar + .content {
    width: 100%;
  }

  #content {
    margin: 10px;
  }

  .hhcm-login-form .form-row {
    display: block;
  }

  .hhcm-login-form .form-row > label {
    text-align: left;
  }

  .hhcm-login-form .errorlist {
    margin-left: 0;
  }

  .hhcm-login-form .submit-row {
    padding-left: 0;
  }
}
