:root {
  color-scheme: dark;
  --bg: #07110d;
  --surface: rgba(13, 28, 21, .9);
  --surface-2: #10271c;
  --line: rgba(135, 255, 183, .14);
  --text: #ecfff3;
  --muted: #8eaa99;
  --green: #5df397;
  --green-deep: #23b662;
  --yellow: #f5c968;
  --red: #ff7d84;
  --shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(100, 255, 159, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 255, 159, .025) 1px, transparent 1px),
    radial-gradient(circle at 18% -10%, rgba(32, 218, 111, .13), transparent 35%),
    var(--bg);
  background-size: 40px 40px, 40px 40px, auto, auto;
  font: 14px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ambient { position: fixed; z-index: -1; width: 360px; height: 360px; border-radius: 50%; filter: blur(100px); opacity: .08; }
.ambient-one { top: 8%; right: -120px; background: var(--green); }
.ambient-two { bottom: -180px; left: -100px; background: #38bdf8; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.04em; line-height: 1.08; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: -.025em; }
strong { font-weight: 700; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 5px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
.no-underline { color: inherit; text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 74px; padding: 12px clamp(20px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 13, .82); backdrop-filter: blur(18px);
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row p { margin: 0; }
.brand-mark {
  display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px;
  color: #031209; background: linear-gradient(145deg, #7cffad, #32d575);
  font-size: 25px; font-weight: 900; box-shadow: 0 10px 35px rgba(69, 232, 132, .2);
}
.brand-mark-small { width: 42px; height: 42px; border-radius: 13px; font-size: 19px; }

.page-shell { width: min(1560px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 72px; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.hero-row .muted { margin-bottom: 0; }

.button, button, input { font: inherit; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 17px;
  border: 1px solid var(--line); border-radius: 11px; color: var(--text); background: var(--surface-2);
  cursor: pointer; text-decoration: none; font-weight: 700; transition: .18s ease;
}
.button:hover { border-color: rgba(93, 243, 151, .5); transform: translateY(-1px); }
.button-primary { color: #052011; border-color: transparent; background: linear-gradient(135deg, var(--green), #37d878); }
.button-secondary { color: var(--green); background: rgba(93, 243, 151, .06); }
.button-quiet { color: var(--muted); background: transparent; }
.button-wide { width: 100%; }

.filter-card, .panel, .form-card, .login-card, .metric-card {
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(14px);
}
.filter-card { position: relative; display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; padding: 18px; border-radius: 15px; }
.period-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
label > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"] {
  width: 100%; min-height: 43px; padding: 9px 12px; color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  outline: none; background: rgba(4, 13, 9, .72);
}
input:focus { border-color: var(--green-deep); box-shadow: 0 0 0 3px rgba(93, 243, 151, .08); }
.period-form input { width: 160px; }
.period-caption { color: var(--muted); white-space: nowrap; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric-card { min-height: 145px; padding: 22px; border-radius: 15px; }
.metric-card.accent { background: linear-gradient(145deg, rgba(46, 212, 111, .16), rgba(13, 28, 21, .92)); }
.metric-card > span { display: block; margin-bottom: 19px; color: var(--muted); font-weight: 650; }
.metric-card strong { display: block; margin-bottom: 4px; font-size: clamp(23px, 2.4vw, 31px); letter-spacing: -.04em; }
.metric-card small, td small { display: block; color: var(--muted); }

.panel { overflow: hidden; border-radius: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.health-pill { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.health-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1220px; }
th { padding: 13px 14px; color: #789181; background: rgba(2, 10, 6, .42); font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .09em; }
td { padding: 17px 14px; border-top: 1px solid rgba(135, 255, 183, .09); vertical-align: top; }
tbody tr:hover { background: rgba(93, 243, 151, .025); }
.row-disabled { opacity: .48; }
.row-warning { background: rgba(245, 201, 104, .025); }
.trader-cell { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--green); background: rgba(93, 243, 151, .09); font-weight: 800; }
.profit { color: var(--green); }
.inline-error { max-width: 250px; margin-top: 9px; color: var(--yellow); font-size: 11px; }
.sync-time { white-space: nowrap; }
.actions { display: flex; gap: 7px; }
.icon-button { padding: 5px 8px; color: var(--muted); border: 1px solid var(--line); border-radius: 7px; background: transparent; cursor: pointer; text-decoration: none; font-size: 11px; }
.empty-cell { color: var(--muted); text-align: center; }
.empty-state { padding: 60px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); font-size: 18px; }

.login-shell, .form-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 42px; border-radius: 20px; }
.login-card .brand-mark { margin-bottom: 26px; }
.login-card h1 { font-size: 34px; }
.login-form { margin-top: 30px; }
.stack { display: grid; gap: 18px; }
.form-shell { display: block; width: min(720px, calc(100% - 40px)); min-height: auto; margin: 0 auto; padding: 54px 0; }
.form-card { margin-top: 17px; padding: 35px; border-radius: 18px; }
.form-card h1 { font-size: 32px; }
.account-form { margin-top: 28px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; }
.checkbox-row span { margin: 0; color: var(--text); }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.back-link { color: var(--muted); text-decoration: none; }
.alert { padding: 12px 14px; border: 1px solid rgba(255, 125, 132, .26); border-radius: 10px; color: #ffb0b5; background: rgba(255, 125, 132, .08); }
.alert.compact { padding: 8px 11px; }
.field-error { display: block; margin-top: 6px; color: var(--red); }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-card, .hero-row { align-items: stretch; flex-direction: column; }
  .period-caption { align-self: flex-start; }
}

@media (max-width: 600px) {
  .page-shell { width: min(100% - 24px, 1560px); padding-top: 30px; }
  .topbar { padding: 11px 14px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 125px; }
  .period-form { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .period-form input { width: 100%; }
  .period-form .button { grid-column: span 2; }
  .login-card, .form-card { padding: 26px 22px; }
  .hero-row .button { width: 100%; }
}
