*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: #0a1224;
  color: #cbd5ea;
  min-height: 100vh;
  line-height: 1.55;
  font-size: 15px;
}
body.centered { display: grid; place-items: center; padding: 20px; }
a { color: #f5b820; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══ LOGIN CARD ═══ */
.login-card {
  background: #0f1a33;
  border: 1px solid #1a2342;
  border-radius: 18px;
  padding: 44px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
}
.login-card .logo {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}
.login-card .brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 10px;
}
.login-card .brand-logo {
  height: 56px;
  width: auto;
  background: transparent;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,.3));
  flex: none;
}
.login-card .brand-name {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-logo {
  height: 30px;
  width: auto;
  background: transparent;
  display: block;
  flex: none;
}
.topbar .brand-text-name {
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .02em;
}
@media (max-width: 480px) {
  .login-card .brand-row { gap: 10px; }
  .login-card .brand-logo { height: 44px; }
  .login-card .brand-name { font-size: 18px; }
  .topbar-logo { height: 26px; }
  .topbar .brand-text-name { font-size: 15px; }
}
.login-card .tag { color: #6b7ea3; font-size: 14px; margin: 0 0 32px; }
.login-card form label {
  display: block; font-size: 13px; color: #cbd5ea;
  font-weight: 600;
  margin-bottom: 8px; margin-top: 18px;
}
.login-card form input {
  width: 100%; padding: 14px 16px;
  background: #050b18;
  border: 1px solid #2a3d72;
  border-radius: 12px;
  color: #fff;
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
}
.login-card form input:focus { outline: none; border-color: #f5b820; box-shadow: 0 0 0 4px rgba(245,184,32,.15); }
.login-card form button {
  width: 100%;
  margin-top: 28px;
  padding: 14px 18px;
  background: #f5b820;
  color: #0a1224;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s;
}
.login-card form button:hover { background: #ffc739; }
.login-card .note {
  margin-top: 24px;
  font-size: 13px;
  color: #6b7ea3;
  text-align: center;
}

/* ═══ TOP BAR ═══ */
.topbar {
  background: #050810;
  border-bottom: 1px solid #1a2342;
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { color: #fff; font-weight: 800; font-size: 17px; letter-spacing: .02em; }
.topbar .user { font-size: 14px; color: #9fb0d1; display: flex; gap: 16px; align-items: center; }
.topbar .user b { color: #fff; }
.topbar .logout {
  padding: 8px 16px;
  background: rgba(255,255,255,.04);
  border-radius: 10px;
  font-size: 13px;
  color: #cbd5ea;
}
.topbar .logout:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }

/* ═══ TAB BAR ═══ */
.tabbar {
  background: #0a1224;
  border-bottom: 1px solid #1a2342;
  padding: 0 32px;
  display: flex;
  gap: 0;
}
.tab {
  display: inline-block;
  padding: 18px 24px;
  font-size: 15px;
  color: #6b7ea3;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  transition: all .15s;
}
.tab:hover { color: #cbd5ea; text-decoration: none; background: rgba(255,255,255,.02); }
.tab.active {
  color: #f5b820;
  border-bottom-color: #f5b820;
  background: rgba(245,184,32,.05);
}

/* ═══ PAGE ═══ */
.page {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 24px 80px;
}

/* ═══ CARD ═══ */
.card {
  background: #0f1a33;
  border: 1px solid #1a2342;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 20px;
}
.card h1 {
  color: #fff;
  font-size: 1.5rem;
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.card h2 {
  color: #fff;
  font-size: 1.1rem;
  margin: 0 0 8px;
  font-weight: 700;
}
.card .lede {
  color: #9fb0d1;
  margin: 0 0 24px;
  font-size: 14px;
}
.card .hint {
  color: #6b7ea3;
  font-size: 13px;
  margin: 8px 0 14px;
}
.card .hint b { color: #cbd5ea; }

/* ═══ FORMS ═══ */
form label {
  display: block;
  margin-bottom: 16px;
}
form label span {
  display: block;
  color: #cbd5ea;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
form input, form textarea {
  width: 100%;
  padding: 13px 16px;
  background: #050b18;
  border: 1px solid #2a3d72;
  border-radius: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
form input[type=number], form input[type=datetime-local] {
  font-family: "JetBrains Mono", monospace;
}
form input:focus, form textarea:focus {
  outline: none;
  border-color: #f5b820;
  box-shadow: 0 0 0 4px rgba(245,184,32,.1);
}
form textarea { resize: vertical; min-height: 64px; }
form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
form .row label { margin-bottom: 0; }

/* ═══ LOOKUP (special inline) ═══ */
.lookup {
  display: flex; gap: 12px;
  margin: 0;
}
.lookup input {
  flex: 1;
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
}
.lookup button {
  padding: 0 28px;
  background: #f5b820;
  color: #0a1224;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.lookup button:hover { background: #ffc739; }

/* ═══ BUTTONS ═══ */
.btn-primary {
  margin-top: 8px;
  padding: 13px 28px;
  background: #1fc77a;
  color: #0a1224;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #2dd987; }

.btn-danger {
  padding: 12px 22px;
  background: #ff3b3b;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover { background: #e62b2b; }

.danger-zone {
  border-color: rgba(255,92,92,.3);
  background: rgba(58,20,20,.3);
}
.danger-zone h2 { color: #ff9d9d; }

/* ═══ TRADE SUMMARY ═══ */
.trade-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid #1a2342;
  margin-bottom: 20px;
}
.trade-summary .ttype {
  font-size: 13px;
  color: #f5b820;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.trade-summary .ttotal {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
}
.trade-summary .ttotal .dim {
  color: #6b7ea3;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  margin-left: 4px;
}
.trade-summary .amount {
  font-size: 28px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
}
.trade-summary .amount.pos { color: #1fc77a; }
.trade-summary .amount.neg { color: #ff5c5c; }

/* ═══ KEY-VALUE TABLE ═══ */
.kv {
  width: 100%;
  border-collapse: collapse;
}
.kv th, .kv td {
  text-align: left;
  padding: 10px 0;
  border-bottom: 1px solid #131b30;
  font-size: 14px;
}
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }
.kv th {
  color: #6b7ea3;
  font-weight: 500;
  width: 35%;
}
.kv td { color: #fff; font-weight: 500; }
.kv td.mono { font-family: "JetBrains Mono", monospace; font-size: 13px; }

/* ═══ MESSAGES ═══ */
.err, .ok {
  padding: 14px 18px;
  border-radius: 12px;
  margin: 0 0 20px;
  font-size: 14px;
  font-weight: 500;
}
.err { background: #3a1414; border: 1px solid #ff5c5c; color: #ff9d9d; }
.ok  { background: #0d2e1f; border: 1px solid #1fc77a; color: #7fe7b8; }

/* ═══ Optional label ═══ */
.optional {
  color: #6b7ea3;
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}

/* ═══ MODAL ═══ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5,11,24,0.85);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn .2s ease;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: linear-gradient(180deg, #1a2950, #0f1a33);
  border: 1px solid #ff5c5c;
  border-radius: 18px;
  padding: 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
  animation: slideUp .25s ease;
}
.modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(255,92,92,0.15);
  color: #ff5c5c;
  font-size: 32px;
  display: grid;
  place-items: center;
}
.modal h3 {
  color: #fff;
  font-size: 1.3rem;
  margin: 0 0 12px;
  font-weight: 700;
}
.modal p {
  color: #cbd5ea;
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.modal-actions button {
  padding: 12px 28px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.btn-ghost {
  background: transparent;
  border: 1px solid #2a3d72 !important;
  color: #cbd5ea;
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ═══ MOBILE ═══ */
@media (max-width: 720px) {
  .topbar { padding: 14px 18px; flex-direction: column; gap: 8px; align-items: flex-start; }
  .tabbar { padding: 0 12px; overflow-x: auto; }
  .tab { padding: 14px 16px; font-size: 14px; white-space: nowrap; }
  .card { padding: 22px 18px; }
  .page { padding: 0 16px 60px; }
  form .row { grid-template-columns: 1fr; }
  .trade-summary { flex-direction: column; }
  .trade-summary .amount { font-size: 22px; }
  .lookup { flex-direction: column; }
  .lookup button { width: 100%; padding: 13px; }
}
