:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --line: #d6dde8;
  --line-soft: #e8edf3;
  --soft: #e9f4f1;
  --primary: #0b766d;
  --primary-dark: #075f58;
  --accent: #263445;
  --amber: #a16207;
  --amber-soft: #fff7df;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --danger: #b42318;
  --profit: #b42318;
  --loss: #067647;
  --warning: #8a5a00;
  --shadow: 0 10px 28px rgba(17, 24, 39, 0.07);
  --shadow-soft: 0 6px 18px rgba(17, 24, 39, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f7f9fb 0%, var(--bg) 260px);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 18px 14px;
  background: #101c2b;
  color: #eaf0f7;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #0b766d;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(11, 118, 109, 0.28);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
  letter-spacing: 0;
}

.brand span,
.sidebar-note p,
.panel-title p,
.eyebrow {
  font-size: 13px;
  line-height: 1.45;
}

.brand span,
.sidebar-note p {
  color: #91a1b5;
}

.panel-title p,
.eyebrow {
  color: var(--muted);
}

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

.nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #a8b4c4;
  cursor: pointer;
  text-align: left;
  font-weight: 800;
}

.nav-item.active {
  background: rgba(11, 118, 109, 0.18);
  color: #ffffff;
  box-shadow: inset 3px 0 0 #2dd4bf;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-note span {
  color: #7dd3c7;
  font-weight: 900;
}

.workspace {
  min-width: 0;
  padding: 18px 20px 28px;
}

.topbar,
.records-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 16px 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(11, 118, 109, 0.16);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  box-shadow: none;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.notice {
  margin-bottom: 16px;
  border: 1px solid rgba(11, 118, 109, 0.24);
  border-radius: 8px;
  padding: 12px 14px;
  background: #f1fbf8;
  color: var(--primary-dark);
  font-weight: 800;
}

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

.stat-card,
.panel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 13px 14px;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.stat-card:nth-child(2)::before {
  background: var(--amber);
}

.stat-card:nth-child(3)::before {
  background: var(--blue);
}

.stat-card:nth-child(4)::before {
  background: var(--danger);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.panel {
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.panel-title {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.panel-title h2 {
  letter-spacing: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.two-col {
  grid-template-columns: 1fr 1fr;
}

.trade-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.55fr);
  margin-bottom: 16px;
}

.customer-layout {
  grid-template-columns: minmax(300px, 0.65fr) minmax(0, 1.35fr);
}

.summary-list {
  display: grid;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}

.summary-list div,
.compact-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.summary-list div:last-child,
.compact-item:last-child {
  border-bottom: 0;
}

.summary-list span,
.compact-item span {
  color: var(--muted);
}

.compact-list {
  display: grid;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}

.staff-summary {
  display: grid;
  gap: 8px;
}

.staff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fbfcfd;
}

.staff-row strong,
.staff-row span {
  display: block;
}

.staff-row strong {
  font-size: 14px;
}

.staff-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.staff-row em {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 15px;
}

.empty-inline {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.form-panel {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
  font-size: 14px;
}

.field-hint {
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

input,
select,
.search {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 118, 109, 0.12);
}

.search {
  max-width: 280px;
}

.table-panel {
  min-width: 0;
}

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

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

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
}

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

th {
  color: #526173;
  background: #f6f8fb;
  font-weight: 900;
}

tbody tr:hover {
  background: #fbfcfd;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 900;
}

.badge.open {
  background: #fff7e6;
  color: var(--warning);
}

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

.profit {
  color: var(--profit);
  font-weight: 900;
}

.loss {
  color: var(--loss);
  font-weight: 900;
}

.empty {
  height: 84px;
  color: var(--muted);
  text-align: center;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav,
  .stats-grid,
  .two-col,
  .trade-layout,
  .customer-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .records-header {
    display: grid;
  }

  .search {
    max-width: none;
  }
}
