/* MT Manager — a trade-manager styled as a precision terminal.
   Identity: amber-on-ink (the trading-terminal lineage), because green and red
   are reserved for profit and loss and must never be spent on chrome. Numbers
   are the subject, so every readout is set in a monospaced, tabular face. */

:root {
  --bg: #0a0e15;
  --panel: #111826;
  --raised: #172032;
  --border: #232d40;
  --border-bright: #33415c;
  --text: #e7edf7;
  --muted: #8492a8;
  --faint: #5b6880;

  --accent: #f7a828;          /* amber — brand, links, active, focus, master   */
  --accent-ink: #140d00;      /* text that sits on top of amber                */
  --up: #33d38a;              /* profit                                        */
  --down: #ff5c6e;            /* loss                                          */
  --follow: #5cb4ff;          /* slave / follower role                         */

  --r-card: 14px;
  --r-ctl: 9px;
  --r-pill: 999px;
  --hair: 1px solid var(--border);
  --shadow: 0 10px 30px -18px rgba(0, 0, 0, .8);

  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", "JetBrains Mono", "Fira Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 520px at 50% -220px, rgba(247, 168, 40, .06), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 1120px; margin: 0 auto; padding: 20px 18px 64px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; margin-bottom: 4px; }
h2 {
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); margin: 26px 0 12px; display: flex; align-items: center; gap: 12px;
}
h2::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Numbers are the product — a shared readout treatment. */
.val, .stat .val, td, .key-box, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- layout */

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
/* min(320px, 100%) keeps a single card from overflowing phones narrower than 320px. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; }

/* --------------------------------------------------------------- wordmark */

.brand { font-weight: 700; letter-spacing: -.01em; display: inline-flex; align-items: center; gap: 9px; }
.brand::before {
  content: ""; width: 10px; height: 18px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 14px rgba(247, 168, 40, .55);
}
.brand span { color: var(--accent); }

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px 16px;
  flex-wrap: wrap; padding: 4px 0 20px; margin-bottom: 8px; border-bottom: var(--hair);
}
.topbar .brand { font-size: 1.1rem; }
.topbar .user { color: var(--muted); font-size: .85rem; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Language switch (EN / ES). */
.lang { display: inline-flex; gap: 6px; font-size: .78rem; letter-spacing: .04em; }
.lang a { color: var(--faint); font-weight: 600; }
.lang a:hover { color: var(--text); text-decoration: none; }
.lang a.active { color: var(--accent); }
.auth-lang { text-align: center; margin-top: 16px; }

/* ------------------------------------------------------------------ cards */

.card {
  background: linear-gradient(180deg, #131b2b, var(--panel));
  border: var(--hair); border-radius: var(--r-card); padding: 18px;
  box-shadow: var(--shadow);
}
.empty { color: var(--muted); text-align: center; padding: 30px 20px; }

/* -------------------------------------------------------------------- auth */

.auth-wrap { max-width: 400px; margin: 12vh auto 0; }
.auth-wrap .brand { justify-content: center; font-size: 1.7rem; margin-bottom: 22px; }
.auth-wrap .brand::before { height: 26px; width: 13px; }
.auth-wrap .card { position: relative; overflow: hidden; }
.auth-wrap .card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

/* --------------------------------------------------------- account cards */

.acct { position: relative; cursor: pointer; transition: transform .16s ease, border-color .16s ease; }
.acct::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; border-radius: var(--r-card) var(--r-card) 0 0;
  background: var(--accent); opacity: 0; transition: opacity .16s ease;
}
.acct:hover { transform: translateY(-2px); border-color: var(--border-bright); }
.acct:hover::before { opacity: .9; }
.acct .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.acct .name { font-weight: 650; font-size: 1.05rem; letter-spacing: -.01em; }
.acct .sub { color: var(--muted); font-size: .8rem; }
.acct .sub b { color: var(--text); font-weight: 600; }

.acct .nums { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 4px; }
.nums > div { display: flex; flex-direction: column; gap: 3px; }
.lbl { color: var(--faint); font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.acct .nums .val { font-size: 1.02rem; font-weight: 550; }

/* ------------------------------------------------------------------ badges */

.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-pill);
  padding: 3px 10px; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; border: 1px solid transparent;
}
.badge.online  { color: var(--up);     background: rgba(51, 211, 138, .1);  border-color: rgba(51, 211, 138, .22); }
.badge.offline { color: var(--down);   background: rgba(255, 92, 110, .1);  border-color: rgba(255, 92, 110, .22); }
.badge.master  { color: var(--accent); background: rgba(247, 168, 40, .1);  border-color: rgba(247, 168, 40, .24); }
.badge.slave   { color: var(--follow); background: rgba(92, 180, 255, .1);  border-color: rgba(92, 180, 255, .22); }

/* Live status LED on the state badges only. */
.badge.online::before, .badge.offline::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 7px currentColor;
}
.badge.online::before { animation: led 2s ease-in-out infinite; }

a.badge:hover { text-decoration: none; filter: brightness(1.15); }

/* -------------------------------------------------------------- stat tiles */

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.stat { background: var(--panel); border: var(--hair); border-radius: 12px; padding: 12px 14px; }
.stat .lbl { display: block; margin-bottom: 6px; }
.stat .val { font-size: 1.08rem; font-weight: 600; white-space: nowrap; }
.stat .val .hint { font-family: var(--sans); font-weight: 500; }

.pos { color: var(--up); }
.neg { color: var(--down); }

/* -------------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 6px; margin: 22px 0 14px; flex-wrap: wrap; border-bottom: var(--hair); padding-bottom: 0; }
.tabs button {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; color: var(--muted); font-weight: 600; padding: 8px 12px 10px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { font-family: var(--mono); font-size: .72rem; color: var(--faint); }
.tabs button.active .tab-count { color: var(--accent); }

.toolbar { margin-bottom: 12px; gap: 8px; }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; border: var(--hair); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; white-space: nowrap; }
th, td { text-align: left; padding: 9px 13px; }
th {
  background: var(--raised); color: var(--faint); font-size: .66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; position: sticky; top: 0;
}
tr + tr { border-top: var(--hair); }
tr:hover td { background: rgba(255, 255, 255, .018); }

/* ------------------------------------------------------------------ forms */

.field { margin-bottom: 13px; }
.field label { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; letter-spacing: .02em; }

input, select {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-ctl);
  color: var(--text); padding: 10px 12px; font-size: .95rem; font-family: inherit;
  transition: border-color .14s ease, box-shadow .14s ease;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(247, 168, 40, .16);
}
input[type="number"] { font-family: var(--mono); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.check { display: flex; gap: 9px; align-items: center; font-size: .9rem; }

/* Toggle switch — a styled checkbox for boolean settings. */
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; font-size: .92rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  flex: none; width: 42px; height: 23px; border-radius: 999px;
  background: var(--raised); border: 1px solid var(--border); position: relative;
  transition: background .16s ease, border-color .16s ease;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: var(--muted); transition: transform .16s ease, background .16s ease;
}
.switch input:checked + .track { background: rgba(247, 168, 40, .22); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(19px); background: var(--accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.settings-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .settings-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- buttons */

button {
  background: var(--accent); border: 1px solid var(--accent); border-radius: var(--r-ctl);
  color: var(--accent-ink); cursor: pointer; font-family: inherit; font-size: .92rem;
  font-weight: 650; padding: 9px 16px; transition: filter .14s ease, border-color .14s ease, background .14s ease;
}
button:hover { filter: brightness(1.07); }
button.secondary { background: var(--raised); border-color: var(--border); color: var(--text); }
button.secondary:hover { border-color: var(--border-bright); filter: none; }
button.danger { background: transparent; border-color: rgba(255, 92, 110, .5); color: var(--down); }
button.danger:hover { background: rgba(255, 92, 110, .1); filter: none; }
button.small { padding: 5px 11px; font-size: .78rem; font-weight: 600; }
button:disabled { opacity: .45; cursor: default; filter: none; }

/* ------------------------------------------------------------------- misc */

.hint { color: var(--muted); font-size: .8rem; margin-top: 6px; line-height: 1.5; }
.hint b { color: var(--text); font-weight: 600; }
.error { color: var(--down); font-size: .85rem; margin: 8px 0; min-height: 1.2em; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--muted); font-size: .85rem; }
.back-link:hover { color: var(--accent); }

.key-box {
  background: var(--bg); border: var(--hair); border-left: 2px solid var(--accent); border-radius: var(--r-ctl);
  padding: 11px 13px; font-size: .88rem; color: var(--text); word-break: break-all; margin: 12px 0;
  user-select: all;
}

/* Enrollment QR needs a light backing to stay scannable on the dark theme. */
.qr { display: inline-block; background: #fff; padding: 12px; border-radius: 10px; margin: 4px 0 12px; }
.qr svg { display: block; width: 190px; height: 190px; }

/* One-time recovery codes: each intact, wrapping between codes. */
.codes {
  display: flex; flex-wrap: wrap; gap: 8px 18px; font-family: var(--mono); font-size: .9rem;
  background: var(--bg); border: var(--hair); border-radius: var(--r-ctl); padding: 12px 14px;
  margin: 8px 0; user-select: all;
}

/* ------------------------------------------------------------------ modal */

.modal-back {
  position: fixed; inset: 0; background: rgba(4, 7, 12, .72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10;
  animation: fade .16s ease;
}
.modal { width: 100%; max-width: 470px; max-height: 90vh; overflow-y: auto; }

/* ------------------------------------------------------------------ motion */

@keyframes led { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
