:root {
  --bg: #f5f7fb;
  --panel: rgba(255, 255, 255, 0.68);
  --panel-strong: rgba(255, 255, 255, 0.86);
  --line: rgba(20, 28, 42, 0.12);
  --text: #151923;
  --muted: #667085;
  --soft: #eef2f7;
  --primary: #0f6fff;
  --primary-dark: #0a54c2;
  --green: #0f8b6d;
  --amber: #b7791f;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(23, 35, 61, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 9% 8%, rgba(15, 111, 255, 0.16), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(15, 139, 109, 0.12), transparent 26%),
    linear-gradient(135deg, #f9fbff 0%, #eef3fa 48%, #f6f7fb 100%);
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.55) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.55) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.login-logo {
  width: 160px;
  height: auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.18;
}

h2 {
  font-size: 28px;
  line-height: 1.2;
}

h3 {
  font-size: 18px;
}

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

.small {
  font-size: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.76);
  outline: none;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 111, 255, 0.58);
  box-shadow: 0 0 0 3px rgba(15, 111, 255, 0.12);
}

.primary,
.secondary,
.ghost,
.danger,
a.secondary {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform 0.16s ease, background 0.16s ease, border 0.16s ease;
}

.primary {
  color: white;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  box-shadow: 0 8px 20px rgba(15, 111, 255, 0.22);
}

.secondary {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.ghost {
  color: var(--muted);
  background: transparent;
}

.danger {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.08);
}

.primary:hover,
.secondary:hover,
.danger:hover {
  transform: translateY(-1px);
}

.full {
  width: 100%;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
}

.brand img {
  width: 54px;
  height: 32px;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 15px;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: #344054;
  background: transparent;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav button.active,
.nav button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 0 0 1px var(--line);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.quick-actions,
.toolbar,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.filters {
  display: grid;
  gap: 10px;
}

.filter-grid {
  display: grid;
  grid-template-columns:
    minmax(116px, 1.25fr)
    minmax(92px, 0.88fr)
    minmax(62px, 0.52fr)
    minmax(82px, 0.72fr)
    minmax(64px, 0.56fr)
    minmax(64px, 0.56fr)
    minmax(72px, 0.62fr);
  gap: 6px;
  align-items: center;
}

.filter-grid input,
.filter-grid select {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

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

.filter-actions button,
.filter-actions a {
  min-height: 34px;
  padding-inline: 12px;
  font-size: 13px;
}

.view {
  display: grid;
  gap: 16px;
}

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

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

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

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

.panel,
.metric,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(24px);
  box-shadow: 0 10px 34px rgba(23, 35, 61, 0.08);
}

.panel,
.metric {
  padding: 16px;
}

.metric {
  min-height: 118px;
  display: grid;
  align-content: space-between;
}

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

.metric strong {
  font-size: 30px;
  line-height: 1.1;
}

.table-panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.customer-table table {
  min-width: 1140px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(20, 28, 42, 0.08);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #475467;
  background: rgba(247, 249, 252, 0.95);
  font-weight: 700;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.42);
}

tr.saving td {
  opacity: 0.68;
}

.inline-edit {
  min-height: 32px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.64);
}

td .inline-edit {
  width: 100%;
}

.customer-mark-select {
  min-width: 104px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(15, 111, 255, 0.09);
  color: #0a54c2;
  font-size: 12px;
  white-space: nowrap;
}

.badge.green {
  color: var(--green);
  background: rgba(15, 139, 109, 0.1);
}

.badge.amber {
  color: var(--amber);
  background: rgba(183, 121, 31, 0.12);
}

.cell-main {
  display: grid;
  gap: 4px;
}

.cell-main strong {
  font-size: 14px;
}

.truncate {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.permission-grid legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.check-row {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}

.check-row input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(13, 18, 28, 0.26);
  backdrop-filter: blur(12px);
}

.modal-panel {
  width: min(980px, 100%);
  max-height: min(86vh, 920px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

#modalBody {
  padding: 16px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(16, 24, 40, 0.06);
  font-size: 22px;
  line-height: 1;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-strong);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.empty {
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.file-input {
  position: relative;
  overflow: hidden;
}

.file-input input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .nav button {
    text-align: center;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 16px;
  }

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

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

  .quick-actions,
  .toolbar {
    width: 100%;
  }

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

  .filter-grid input:first-child {
    grid-column: 1 / -1;
  }

  .filter-actions {
    width: 100%;
  }

  .quick-actions button,
  .toolbar button,
  .toolbar input,
  .toolbar select {
    flex: 1 1 160px;
  }

  .filter-actions button,
  .filter-actions a {
    flex: 1 1 110px;
  }
}
