:root {
  color-scheme: light;
  --bg: #fafaf7;
  --bg-alt: #f8fbff;
  --panel: rgba(255, 255, 255, 0.74);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --panel-soft: rgba(255, 255, 255, 0.54);
  --sidebar: rgba(250, 250, 247, 0.9);
  --text: #0f172a;
  --text-soft: #334155;
  --muted: rgba(71, 85, 105, 0.84);
  --line: rgba(15, 23, 42, 0.075);
  --line-strong: rgba(15, 23, 42, 0.13);
  --primary: #0f172a;
  --primary-2: #1e293b;
  --green: #0f8f62;
  --amber: #a16207;
  --red: #b42318;
  --blue: #1e3a8a;
  --cyan: #075985;
  --focus: rgba(15, 23, 42, 0.14);
  --shadow: 0 24px 70px -54px rgba(15, 23, 42, 0.36);
  --shadow-hover: 0 28px 80px -58px rgba(15, 23, 42, 0.42);
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Sora", var(--font-body);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 54%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 46%, var(--bg) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at top, rgba(255, 255, 255, 0.72), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(250, 250, 247, 0.44) 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 100vh;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(250, 250, 247, 0.9) 0%, rgba(248, 251, 255, 0.82) 100%);
  border-right: 1px solid rgba(15, 23, 42, 0.065);
  backdrop-filter: blur(24px);
}

.brand {
  padding: 8px 8px 16px;
  border-bottom: 1px solid var(--line);
}

.brand h1,
.topbar h2,
.panel h3,
.login-box h1 {
  font-family: var(--font-display);
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
}

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

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

.nav button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #64748b;
  background: transparent;
  border-radius: 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.nav button.active {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 18px 42px -30px rgba(15, 23, 42, 0.72);
}

.nav button:hover:not(.active) {
  color: var(--text);
  background: rgba(15, 23, 42, 0.045);
}

.sidebar > .btn {
  margin-top: auto;
}

.content {
  position: relative;
  z-index: 1;
  min-width: 0;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  padding: 28px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
}

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

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

.totp-verify {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px auto;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #fde68a;
  border-radius: 12px;
  background: #fffbeb;
}

.totp-verify p {
  margin: 4px 0 0;
}

.totp-verify input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.pricebar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 22px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.05);
}

.price-chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
}

.price-chip.tier-price {
  min-height: 36px;
  background: #eef2ff;
}

.price-chip-stock {
  padding-left: 10px;
  border-left: 1px solid rgba(30, 64, 175, 0.16);
  color: var(--cyan);
}

.price-chip.balance {
  background: #dcfce7;
  color: #166534;
}

.price-chip.internal {
  background: #ede9fe;
  color: #5b21b6;
}

.price-chip.muted {
  background: #f1f5f9;
  color: #64748b;
}

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

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

.compact-cards {
  margin-bottom: 14px;
}

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.05);
}

.card {
  min-height: 124px;
  padding: 22px 24px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.card:hover,
.panel:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-hover);
}

.card .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.card .value {
  margin-top: 14px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.panel {
  padding: 22px 24px;
  margin-top: 18px;
}

.panel h3 {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 700;
}

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

.inline-form {
  margin-top: 12px;
  grid-template-columns: minmax(180px, 260px) minmax(240px, 1fr) auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 12px;
  background: rgba(248, 250, 252, 0.78);
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
#quick-text:focus,
#enable-2fa-code:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.07);
  background: rgba(255, 255, 255, 0.94);
}

.field textarea {
  min-height: 132px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12px;
}

.btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  font-weight: 700;
  box-shadow: 0 14px 32px -24px rgba(15, 23, 42, 0.62);
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
  background: var(--primary-2);
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.btn.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.secondary:hover {
  background: rgba(248, 250, 252, 0.96);
}

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

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-strong);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: transparent;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(248, 250, 252, 0.9);
  color: #475569;
  font-weight: 700;
}

tr:hover td {
  background: rgba(248, 250, 252, 0.56);
}

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

.empty {
  height: 76px;
  text-align: center;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.34);
}

.mono,
td.mono {
  font-family: var(--font-mono);
}

.money-positive {
  color: var(--green);
  font-weight: 700;
}

.money-negative {
  color: var(--red);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.badge.green {
  background: #dcfce7;
  color: #166534;
}

.badge.amber {
  background: #fef3c7;
  color: #92400e;
}

.badge.red {
  background: #fee2e2;
  color: #991b1b;
}

.badge.blue {
  background: #dbeafe;
  color: #1e40af;
}

.login {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at top, rgba(255, 255, 255, 0.84), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(248, 251, 255, 0.54) 100%);
}

.login-box {
  position: relative;
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 34px 90px -58px rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(22px) saturate(1.08);
  padding: 30px;
}

.login-box h1 {
  margin: 0 0 6px;
  font-size: 30px;
  line-height: 1.12;
  font-weight: 700;
}

.notice {
  min-height: 40px;
  padding: 11px 13px;
  border-radius: 10px;
  margin: 12px 0;
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
  font-size: 13px;
}

.notice.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.summary-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.summary-inline span {
  color: var(--muted);
}

.summary-inline strong {
  color: var(--text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(12px);
}

.modal {
  width: min(880px, 100%);
  max-height: calc(100vh - 48px);
  display: grid;
  gap: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 80px -36px rgba(15, 23, 42, 0.42);
  padding: 18px;
}

.compact-modal {
  width: min(720px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
}

.modal-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.summary-grid div {
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.72);
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 20px;
}

.summary-edit input {
  width: 100%;
  min-height: 36px;
  margin-top: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  outline: none;
}

.quick-mode {
  display: inline-flex;
  width: fit-content;
  gap: 4px;
  padding: 4px;
  background: rgba(241, 245, 249, 0.86);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.quick-mode button {
  min-width: 92px;
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border-radius: 8px;
  font-weight: 700;
}

.quick-mode button.active {
  color: #ffffff;
  background: var(--primary);
}

#quick-text {
  width: 100%;
  min-height: 420px;
  max-height: 60vh;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 14px;
  background: rgba(248, 250, 252, 0.84);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
  outline: none;
}

#enable-2fa-code {
  min-height: 38px;
  margin-top: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}

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

.progress {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--green);
}

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

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

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

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

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

  .sidebar > .btn {
    margin-top: 4px;
  }

  .content {
    padding: 18px;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .nav,
  .cards,
  .form-grid,
  .modal-form,
  .summary-grid,
  .inline-form,
  .totp-verify,
  .split {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .card,
  .panel {
    border-radius: 12px;
  }

  .panel,
  .card,
  .login-box {
    padding: 18px;
  }
}
