:root {
  --bg: #0f141a;
  --panel: #16202b;
  --panel-soft: #1d2a38;
  --line: #324457;
  --text: #e8edf3;
  --muted: #9baab8;
  --accent: #d08b2d;
  --accent-soft: #3a2a16;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(ellipse at top right, #2a1e12, #0f141a 35%);
  color: var(--text);
  overflow-x: hidden;
}

.shell {
  min-height: 100vh;
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #121a22, #111820);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.6px;
}

.subtitle {
  margin: -8px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}

.nav-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.session-box {
  margin-top: auto;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
  color: var(--muted);
  display: grid;
  gap: 10px;
}

.main {
  min-width: 0;
  max-width: 100%;
  padding: 20px;
  display: grid;
  gap: 16px;
  overflow-x: hidden;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(22, 32, 43, 0.82);
  backdrop-filter: blur(6px);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.hidden {
  display: none !important;
}

.panel-head {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel h2,
.block h3 {
  margin: 0;
}

.panel p {
  margin: 4px 0 0;
  color: var(--muted);
}

.actions {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 8px 12px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: linear-gradient(180deg, #c3822a, #9b641f);
  color: #fff;
}

button.danger {
  border-color: #7d2b2b;
  background: linear-gradient(180deg, #bf4242, #8e2c2c);
  color: #fff;
}

button.ghost {
  background: transparent;
}

.grid-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 12px;
}

.block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel-soft);
  margin-bottom: 12px;
}

.form-grid {
  min-width: 0;
  display: grid;
  gap: 10px;
}

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

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

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

label {
  min-width: 0;
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111a24;
  color: var(--text);
  padding: 8px 10px;
}

.metal-box #metalInfo {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.table-wrap table {
  min-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  white-space: nowrap;
}

th {
  background: #121d28;
  color: #f4d7ab;
}

td input,
td select {
  width: 100%;
  min-width: 80px;
  padding: 6px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

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

.totals {
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-weight: 600;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #17324f;
  border: 1px solid #2f6fa7;
  color: #d7ecff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);
}

code {
  background: #0f1b27;
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 6px;
}

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

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

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

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

@media (max-width: 860px) {
  .main {
    padding: 12px;
  }

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

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

  .panel {
    padding: 12px;
  }
}
