:root {
  --bg: #f5f7fb;
  --bg-soft: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f9fbfd;
  --text: #16202b;
  --text-soft: #5e6b7a;
  --text-faint: #8e99a8;
  --line: #e5ebf2;
  --line-strong: #d9e2ec;
  --primary: #2d6cdf;
  --primary-soft: #eaf1ff;
  --success: #1f9d61;
  --success-soft: #e9f8f0;
  --warning: #d68a00;
  --warning-soft: #fff6df;
  --danger: #d94141;
  --danger-soft: #fff0f0;
  --shadow-sm: 0 4px 14px rgba(18, 38, 63, 0.04);
  --shadow-md: 0 10px 28px rgba(18, 38, 63, 0.06);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar-width: 272px;
  --header-height: 72px;
  --container: 1440px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  display: block;
}

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

a:hover {
  opacity: 0.92;
}

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

button {
  cursor: pointer;
}

input,
select,
textarea {
  outline: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-soft);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.bg-danger-soft {
  background: var(--danger-soft);
}

.bg-success-soft {
  background: var(--success-soft);
}

.bg-warning-soft {
  background: var(--warning-soft);
}

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

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(45, 108, 223, 0.08);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--text-faint);
  font-size: 0.84rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-label {
  margin: 14px 10px 4px;
  font-size: 0.73rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  color: var(--text-soft);
  font-weight: 600;
  transition: 0.18s ease;
}

.nav-link:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.sidebar-footer-title {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 500;
}

.sidebar-footer-text {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background: rgba(245, 247, 251, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(229, 235, 242, 0.85);
}

.header-inner {
  max-width: var(--container);
  height: 100%;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  color: var(--text);
}

.search-box {
  width: min(420px, 42vw);
  height: 46px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  box-shadow: var(--shadow-sm);
}

.search-box input {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--text-faint);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 500;
}

.user-copy {
  line-height: 1.2;
}

.user-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 500;
}

.user-role {
  display: block;
  font-size: 0.78rem;
  color: var(--text-faint);
}

.page-wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 28px;
}

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

.page-title {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.page-text {
  margin: 8px 0 0;
  color: var(--text-soft);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 18px;
}

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

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-flat {
  box-shadow: none;
}

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.card-subtitle {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

.stat-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stat-label {
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 600;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-meta {
  font-size: 0.85rem;
  color: var(--text-faint);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-neutral {
  background: var(--bg-soft);
  color: var(--text-soft);
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 500;
  transition: 0.18s ease;
  white-space: nowrap;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(45, 108, 223, 0.18);
}

.btn-primary:hover {
  filter: brightness(0.98);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

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

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-sm {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.table-wrap {
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.table th {
  color: var(--text-faint);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table td strong {
  font-size: 0.95rem;
}

.table td .sub {
  display: block;
  color: var(--text-faint);
  font-size: 0.82rem;
  margin-top: 2px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.form-help {
  font-size: 0.82rem;
  color: var(--text-faint);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 0 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.textarea {
  min-height: 120px;
  padding: 14px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(45, 108, 223, 0.45);
  box-shadow: 0 0 0 4px rgba(45, 108, 223, 0.09);
}

.input[readonly],
.select[disabled],
.textarea[readonly] {
  background: var(--surface-2);
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .input {
  border-radius: 14px 0 0 14px;
}

.input-addon {
  min-width: 56px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-left: 0;
  background: var(--surface-2);
  color: var(--text-soft);
  border-radius: 0 14px 14px 0;
  font-weight: 500;
}

.switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex: 0 0 52px;
}

.switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d6dfe9;
  transition: 0.18s ease;
}

.switch-slider::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(18, 38, 63, 0.14);
  transition: 0.18s ease;
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider::after {
  transform: translateX(22px);
}

.inline-option {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tab {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-weight: 500;
}

.tab.active {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.split {
  display: flex;
  gap: 18px;
}

.split-main {
  flex: 1 1 auto;
  min-width: 0;
}

.split-side {
  width: 340px;
  flex: 0 0 340px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 0.93rem;
}

.alert-success {
  background: var(--success-soft);
  color: #156c44;
  border-color: #d7f0e3;
}

.alert-warning {
  background: var(--warning-soft);
  color: #8a5b00;
  border-color: #f8e8b8;
}

.alert-danger {
  background: var(--danger-soft);
  color: #a62e2e;
  border-color: #f5d5d5;
}

.alert-neutral {
  background: var(--bg-soft);
  color: var(--text-soft);
  border-color: var(--line);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at top right, rgba(45, 108, 223, 0.08), transparent 28%),
    radial-gradient(circle at bottom left, rgba(45, 108, 223, 0.06), transparent 20%),
    var(--bg);
}

.login-card {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow-md);
  padding: 28px;
}

.login-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
  text-align: center;
}

.login-title {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}

.login-text {
  margin: 0;
  color: var(--text-soft);
}

.price-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.price-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.price-name {
  font-weight: 500;
}

.price-note {
  font-size: 0.82rem;
  color: var(--text-faint);
  margin-top: 2px;
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px 16px;
}

.kv-key {
  color: var(--text-faint);
  font-weight: 500;
}

.kv-value {
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 38px 20px;
  color: var(--text-soft);
}

.offcanvas-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 42, 0.26);
  opacity: 0;
  visibility: hidden;
  transition: 0.18s ease;
  z-index: 45;
}

.offcanvas-backdrop.show {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 1180px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split {
    flex-direction: column;
  }

  .split-side {
    width: auto;
    flex-basis: auto;
  }
}

@media (max-width: 980px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

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

  .app-main {
    margin-left: 0;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .search-box {
    width: 100%;
  }

  .header-inner {
    padding: 0 18px;
  }

  .page-wrap {
    padding: 18px;
  }

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .col-8,
  .col-6,
  .col-4,
  .col-3 {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .header-right .header-user {
    display: none;
  }

  .price-row {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .login-card {
    padding: 22px;
    border-radius: 22px;
  }

  .stat-value {
    font-size: 1.55rem;
  }
}