.admin-shell {
  min-height: 100vh;
}

.page-admin:not(.is-login) {
  position: relative;
  --page-pad-left: 1.5rem;
  --page-pad-right: 1.5rem;
  --nav-edge-clear: 3.7rem;
}

.page-admin:not(.is-login) .admin-shell {
  padding-left: 0;
}

.nav-edge {
  position: fixed;
  left: 0.7rem;
  top: 0.7rem;
  z-index: 32;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(20, 32, 48, 0.28);
  transition: left 0.2s ease;
}

.nav-edge svg {
  width: 1.2rem;
  height: 1.2rem;
}

.nav-edge-close,
body.nav-open .nav-edge-open {
  display: none;
}

body.nav-open .nav-edge-close {
  display: block;
}

body.nav-open .nav-edge {
  left: calc(248px + 0.7rem);
}

[dir="rtl"] .nav-edge {
  left: auto;
  right: 0.7rem;
}
[dir="rtl"] body.nav-open .nav-edge {
  left: auto;
  right: calc(248px + 0.7rem);
}
[dir="rtl"] .admin-nav {
  left: auto;
  right: 0;
  transform: translateX(100%);
}
[dir="rtl"] body.nav-open .admin-nav {
  transform: none;
  box-shadow: -8px 0 28px rgba(20, 32, 48, 0.22);
}

.admin-nav {
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 248px;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1rem 0.85rem 1.5rem;
  z-index: 30;
  transform: translateX(-100%);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: none;
}

body.nav-open .admin-nav {
  transform: none;
  box-shadow: 8px 0 28px rgba(20, 32, 48, 0.22);
}

@media (prefers-reduced-motion: reduce) {
  .admin-nav,
  .nav-edge {
    transition: none;
  }
}

.admin-nav a,
.admin-nav button,
.admin-nav summary {
  color: inherit;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: inherit;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.55rem 0.9rem;
  flex-shrink: 0;
}

.brand-logo {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
}

.brand-name {
  display: block;
  font-size: 0.95rem;
  line-height: 1.2;
}

.admin-nav nav {
  display: grid;
  align-content: start;
  gap: 0.15rem;
  margin: 0.35rem 0 1rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.admin-nav nav::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.nav-group {
  margin: 0;
}

.nav-group-label {
  margin: 0.35rem 0.35rem 0.15rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-radius: 8px;
  user-select: none;
}

.nav-group-label::-webkit-details-marker,
.nav-group-label::marker {
  display: none;
}

.nav-group-label::after {
  content: "";
  width: 0.35rem;
  height: 0.35rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.nav-group[open] > .nav-group-label::after {
  transform: rotate(225deg);
}

.nav-group-label:hover,
.nav-group-label:focus-visible {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
}

.nav-group-links {
  display: grid;
  gap: 0.15rem;
  padding: 0 0 0.35rem;
}

.admin-nav nav a {
  text-decoration: none;
  padding: 0.48rem 0.7rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.admin-nav nav a.is-active,
.admin-nav nav a:hover {
  background: var(--action);
}

.logout-form {
  margin-top: auto;
  padding: 0.55rem;
  flex-shrink: 0;
}

.logout-form button {
  width: 100%;
  min-height: 2.4rem;
  border: 0;
  border-radius: var(--button-radius);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.nav-user {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.72);
}

.admin-main {
  position: relative;
  z-index: 0;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  padding: 0;
}

.topbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 3.6rem;
  margin-top: auto;
  padding: 0.55rem var(--page-pad-right, 1.5rem) 0.55rem var(--page-pad-left, 1.5rem);
  background: var(--topbar);
  border-top: 1px solid var(--line);
}

.page-body {
  flex: 1 1 auto;
  padding: 1.15rem var(--page-pad-right, 1.5rem) 2rem var(--page-pad-left, 1.5rem);
}

.page-body > .crumb-bar,
.page-body > .page-head {
  padding-left: max(0rem, calc(var(--nav-edge-clear, 3.7rem) - var(--page-pad-left, 1.5rem)));
}

.topbar-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  position: relative;
}

.lang-menu { position: relative; }
.lang-panel {
  position: absolute;
  inset-inline-end: 0;
  bottom: calc(100% + 0.45rem);
  width: min(12.5rem, calc(100vw - 1.5rem));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 40;
  padding: 0.65rem 0.7rem 0.6rem;
}
.lang-panel-title {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.lang-list { list-style: none; margin: 0; padding: 0; }
.lang-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}
.lang-list a:hover { background: var(--canvas); }
.lang-list a.is-current {
  background: var(--canvas);
}
.lang-list a.is-current::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--action);
  flex: 0 0 auto;
}

.chip-link {
  min-height: 2.4rem;
  min-width: 2.4rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--button-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
  padding: 0 0.7rem;
  font-size: 0.85rem;
}

.chip-icon {
  padding: 0;
}

.chip-icon svg {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
}

.profile-chip {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
  padding: 0.35rem 0.8rem;
}

.profile-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chip small {
  color: var(--muted);
}

.crumb-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0 0 0.85rem;
}

.crumb-back {
  min-height: 2.2rem;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
}

.breadcrumbs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.breadcrumbs a {
  color: inherit;
  text-decoration: none;
}

.record-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.record-drawer[hidden] {
  display: none;
}

.record-drawer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(20, 32, 48, 0.4);
}

.record-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(28rem, 100vw);
  height: 100%;
  background: var(--surface);
  box-shadow: -12px 0 32px rgba(20, 32, 48, 0.18);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.record-drawer.is-open .record-drawer-panel {
  transform: none;
}

.record-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.record-drawer-head h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.record-drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.15rem;
}

.drawer-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.drawer-table th,
.drawer-table td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

.drawer-table th {
  width: 38%;
  font-weight: 650;
  background: var(--canvas);
  color: var(--ink);
  white-space: nowrap;
}

.drawer-table td {
  overflow-wrap: anywhere;
}

.drawer-section-title,
.used-parts-title {
  margin: 1.15rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 650;
}

.used-parts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.used-parts-table th,
.used-parts-table td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

.used-parts-table thead th {
  width: auto;
  font-weight: 650;
  background: var(--canvas);
  color: var(--ink);
  white-space: nowrap;
}

.record-drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1.15rem 1.15rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.record-drawer-actions:empty {
  display: none;
}

body.drawer-open {
  overflow: hidden;
}

@media (min-width: 960px) {
  .admin-nav {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    overflow: hidden;
  }
}

@media (min-width: 721px) {
  .nav-edge {
    position: absolute;
  }
}

.hero-grid,
.card-grid,
.split {
  display: grid;
  gap: 1rem;
}

.split {
  grid-template-columns: 1.2fr 0.8fr;
}

@media (max-width: 800px) {
  .split,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-admin:not(.is-login) {
    --page-pad-left: 1rem;
    --page-pad-right: 1rem;
  }
}
