:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #152033;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #b42318;
  --success: #067647;
  --warning: #b7791f;
  --sidebar: #111827;
  --sidebar-ink: #e5edf8;
  --sidebar-muted: #98a2b3;
  --sidebar-hover: #1f2937;
  --sidebar-active: #172554;
  --sidebar-line: rgba(255, 255, 255, .08);
  --shadow: 0 10px 28px rgba(15, 23, 42, .10);
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Roboto, Arial, Helvetica, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  background: var(--bg);
}

.main-panel {
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: margin-left 200ms ease;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-line);
  box-shadow: 6px 0 20px rgba(15, 23, 42, .10);
}

.sidebar-inner {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 14px 22px;
  scrollbar-width: thin;
  scrollbar-color: #475467 transparent;
}

.sidebar-inner::-webkit-scrollbar {
  width: 8px;
}

.sidebar-inner::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-inner::-webkit-scrollbar-thumb {
  background: #475467;
  border-radius: 999px;
}

.sidebar-backdrop {
  display: none;
}

.brand {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 4px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(135deg, #0f766e, #2563eb);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.large {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
}

.brand-name,
.brand-subtitle {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 1px;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 600;
}

.sidebar-close {
  display: none;
  color: var(--sidebar-ink);
  background: rgba(255, 255, 255, .08);
  width: auto;
  padding: 0 11px;
}

.erp-nav {
  padding-top: 8px;
}

.nav-section {
  margin-top: 18px;
}

.nav-section-toggle {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 8px 9px;
  color: var(--sidebar-ink);
  background: transparent;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  transition: background 200ms ease, color 200ms ease;
}

.nav-section-toggle:hover,
.nav-section-toggle:focus-visible {
  color: #fff;
  background: var(--sidebar-hover);
  outline: none;
}

.section-kicker {
  margin: 0 8px 2px;
  color: var(--sidebar-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1;
  text-transform: uppercase;
}

.section-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.section-title i {
  width: 18px;
  color: #93c5fd;
  text-align: center;
}

.section-title span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-chevron {
  flex: 0 0 auto;
  color: var(--sidebar-muted);
  font-size: 12px;
  transition: transform 200ms ease;
}

.nav-section-toggle[aria-expanded="true"] .section-chevron {
  transform: rotate(90deg);
}

.nav-section-items {
  list-style: none;
  margin: 4px 0 0;
  padding: 0 0 2px;
  display: grid;
  gap: 2px;
}

.nav-section-items[hidden] {
  display: none;
}

.erp-nav-link {
  position: relative;
  min-height: 40px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 2px;
  padding: 9px 10px 9px 14px;
  border-radius: 8px;
  color: #d6deeb;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background 200ms ease, color 200ms ease, transform 200ms ease;
}

.erp-nav-link::before {
  content: "";
  position: absolute;
  inset: 7px auto 7px 0;
  width: 3px;
  border-radius: 999px;
  background: transparent;
}

.erp-nav-link i {
  color: #9fb0c7;
  text-align: center;
  transition: color 200ms ease;
}

.erp-nav-link:hover,
.erp-nav-link:focus-visible {
  color: #fff;
  background: var(--sidebar-hover);
  outline: none;
}

.erp-nav-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(147, 197, 253, .28);
}

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

.erp-nav-link.is-active::before {
  background: #60a5fa;
}

.erp-nav-link.is-active i {
  color: #bfdbfe;
}

.erp-nav-link.is-disabled {
  cursor: not-allowed;
  color: #8f9bad;
  background: transparent;
}

.erp-nav-link.is-disabled i {
  color: #667085;
}

.nav-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  min-width: max-content;
  border: 1px solid rgba(251, 191, 36, .35);
  border-radius: 999px;
  padding: 2px 7px;
  color: #fbbf24;
  background: rgba(251, 191, 36, .08);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 900;
  min-height: 72px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 16px;
}

.topnav-title {
  min-width: 0;
}

.topnav h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.topnav p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topnav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-area {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  padding: 24px;
  flex: 1;
}

.footer {
  padding: 14px 24px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.panel,
.login-card,
.error-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.panel h2,
.login-card h1,
.error-card h1 {
  margin-top: 0;
}

.status-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.status-list dt {
  color: var(--muted);
}

.status-list dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.auth-shell,
.error-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-panel {
  width: min(100%, 420px);
}

.login-header {
  text-align: center;
  margin-bottom: 20px;
}

.login-header p {
  color: var(--muted);
  margin: 0;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  font: inherit;
}

.checkbox-line {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  color: var(--muted);
  font-weight: 400 !important;
}

.button,
.icon-button {
  border: 0;
  border-radius: 7px;
  min-height: 40px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

.button:focus-visible,
.icon-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .24);
}

.button-primary {
  color: #fff;
  background: var(--primary);
}

.button-primary:hover {
  background: var(--primary-dark);
}

.button-secondary {
  color: var(--ink);
  background: #eef2f7;
}

.button-secondary:hover {
  background: #e2e8f0;
}

.button-danger {
  color: #fff;
  background: var(--danger);
}

.button-row,
.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.sidebar-close {
  display: none;
}

.nav-drawer-button {
  display: none;
  background: #eef2f7;
  width: auto;
  padding: 0 12px;
}

.icon-fallback {
  font-size: 13px;
  font-weight: 800;
}

.user-chip {
  max-width: 280px;
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert {
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.alert-success {
  color: var(--success);
  background: #ecfdf3;
  border: 1px solid #abefc6;
}

.alert-danger {
  color: var(--danger);
  background: #fef3f2;
  border: 1px solid #fecdca;
}

.error-card {
  width: min(100%, 460px);
  text-align: center;
}

.error-code {
  margin: 0;
  font-size: 56px;
  font-weight: 700;
  color: var(--primary);
}

.breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  margin-bottom: 16px;
  font-size: 14px;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb span::before {
  content: "/";
  margin-right: 8px;
  color: var(--muted);
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.page-header > * {
  min-width: 0;
  max-width: 100%;
}

.page-header h2 {
  margin: 0 0 4px;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px auto;
  gap: 10px;
  margin-bottom: 16px;
}

input[type="search"],
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  font: inherit;
  background: #fff;
}

textarea {
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.actions-column {
  width: 220px;
}

.inline-form {
  display: inline;
}

.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 24px !important;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status-active {
  color: var(--success);
  background: #ecfdf3;
}

.status-inactive {
  color: var(--danger);
  background: #fef3f2;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.form-grid label span {
  font-size: 13px;
  color: var(--muted);
}

.span-2 {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.detail-grid dd {
  margin: 0;
  font-weight: 700;
}

@media (max-width: 1180px) {
  :root {
    --sidebar-width: 240px;
  }

  .sidebar {
    width: var(--sidebar-width);
  }

  .content-area {
    padding: 20px;
  }

  .page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topnav {
    padding-inline: 20px;
  }
}

@media (max-width: 767px) {
  .main-panel {
    margin-left: 0;
    width: 100vw;
    max-width: 100vw;
  }

  .sidebar {
    width: min(88vw, 320px);
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: 18px 0 40px rgba(15, 23, 42, .22);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1030;
    background: rgba(15, 23, 42, .48);
  }

  .app-shell.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-close,
  .nav-drawer-button {
    display: inline-flex;
  }

  .topnav {
    align-items: center;
    width: 100vw;
    max-width: 100vw;
  }

  .content-area {
    width: 100vw;
    max-width: 100vw;
  }

  .topnav-actions {
    gap: 8px;
  }

  .user-chip {
    display: none;
  }

  .page-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .topnav {
    min-height: 64px;
    padding: 10px 14px;
  }

  .topnav h1 {
    font-size: 17px;
  }

  .topnav p {
    display: none;
  }

  .content-area {
    padding: 14px;
  }

  .footer {
    padding: 12px 14px;
    flex-direction: column;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header > * {
    width: 100%;
  }

  .page-header p {
    max-width: 100%;
  }

  .page-header .button-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .page-header .button-row .button {
    width: 100%;
  }

  .button {
    min-height: 38px;
    padding-inline: 11px;
  }
}
