:root {
  color: #17202a;
  background: #eef1f5;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --border: #d5dbe4;
  --muted: #627084;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --accent: #166853;
  --accent-hover: #0d5846;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  padding: 9px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #2a8069;
  box-shadow: 0 0 0 3px rgba(22, 104, 83, 0.13);
}

label {
  display: grid;
  gap: 7px;
  color: #344256;
  font-size: 13px;
  font-weight: 650;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

.hidden {
  display: none !important;
}

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

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

.login-panel,
.toolbar,
.records-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 24px;
  padding: 30px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 16px;
}

.app-view {
  min-height: 100vh;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1280px;
  margin: 0 auto 22px;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  padding: 0 16px;
}

.primary-button:hover {
  background: var(--accent-hover);
}

.secondary-button,
.icon-button {
  border: 1px solid var(--border);
  background: #ffffff;
  color: #263445;
}

.secondary-button {
  padding: 0 14px;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: #aab5c4;
  background: #f7f9fc;
}

.icon-button {
  width: 40px;
  font-size: 18px;
}

.toolbar,
.records-section,
.status {
  max-width: 1280px;
  margin: 0 auto 18px;
}

.toolbar {
  padding: 18px;
}

.record-form {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr 0.85fr 0.85fr 0.85fr auto;
  gap: 14px;
  align-items: end;
}

.add-button {
  min-width: 94px;
}

.status {
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
}

.status.success {
  background: #e8f5ef;
  color: #105b48;
}

.status.error {
  background: #fff0ed;
  color: var(--danger);
}

.records-section {
  overflow: hidden;
}

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

.section-heading span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #e7ebf1;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--panel-soft);
  color: #506176;
  font-size: 12px;
  font-weight: 800;
}

td {
  color: #223044;
  font-size: 14px;
}

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

td input,
td select {
  min-width: 120px;
}

.code-text {
  color: #304158;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.operation-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #edf3f8;
  color: #35475d;
  font-weight: 750;
}

.operation-tag.buy {
  background: #e8f5ef;
  color: #105b48;
}

.operation-tag.sell {
  background: #fff0ed;
  color: #a13b2f;
}

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

.action-button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: #263445;
  padding: 0 10px;
  font-weight: 700;
}

.action-button.danger {
  color: var(--danger);
}

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

@media (max-width: 980px) {
  .app-view {
    padding: 20px;
  }

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

  .top-actions {
    justify-content: flex-start;
  }

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

  .add-button {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .login-panel {
    padding: 22px;
  }

  .app-view {
    padding: 16px;
  }

  .top-actions,
  .secondary-button {
    width: 100%;
  }

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