:root {
  --ink: #1c1a18;
  --ink-2: #2c2926;
  --paper: #f5f1e9;
  --paper-2: #ebe4d8;
  --line: #d6ccbd;
  --muted: #786f65;
  --coral: #d94a3f;
  --coral-dark: #b7332c;
  --amber: #e7a13b;
  --green: #2e8b63;
  --white: #fffefa;
  --shadow: 0 18px 50px rgba(45, 36, 27, .09);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.grain { position: fixed; inset: 0; opacity: .035; pointer-events: none; z-index: 10; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr minmax(440px, .75fr); gap: 6vw; align-items: center; padding: clamp(28px, 7vw, 110px); background: var(--ink); color: var(--paper); }
.login-shell::before { content: ""; position: fixed; width: 48vw; aspect-ratio: 1; left: -20vw; bottom: -26vw; border: 1px solid rgba(231,161,59,.35); border-radius: 50%; box-shadow: 0 0 0 7vw rgba(231,161,59,.04), 0 0 0 14vw rgba(231,161,59,.025); }
.login-brand { display: flex; align-items: center; gap: 24px; position: relative; }
.login-brand h1 { margin: 2px 0 0; font-family: Georgia, serif; font-size: clamp(48px, 7vw, 100px); font-weight: 500; letter-spacing: -.06em; line-height: .9; }
.brand-mark { width: 92px; height: 92px; border: 2px solid var(--amber); color: var(--amber); border-radius: 50% 48% 50% 42%; display: grid; place-items: center; font: 700 44px Georgia, serif; transform: rotate(-6deg); flex: none; }
.brand-mark.small { width: 42px; height: 42px; font-size: 21px; border-width: 1.5px; }
.eyebrow, .kicker { margin: 0; color: var(--coral); text-transform: uppercase; letter-spacing: .15em; font-size: 11px; font-weight: 800; }
.login-brand .eyebrow { color: var(--amber); }
.login-card { position: relative; background: var(--paper); color: var(--ink); padding: clamp(28px, 5vw, 58px); border-radius: 3px; box-shadow: 18px 18px 0 rgba(217,74,63,.8); }
.login-card h2 { margin: 15px 0 22px; font: 500 clamp(34px, 4vw, 60px)/.97 Georgia, serif; letter-spacing: -.04em; }
.login-copy { color: var(--muted); line-height: 1.6; max-width: 48ch; }
label, .control-label { display: block; margin: 28px 0 9px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
input, select { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--white); color: var(--ink); padding: 13px 14px; outline: none; border-radius: 2px; }
input:focus, select:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(217,74,63,.12); }
.button { border: 0; padding: 0 23px; font-weight: 800; }
.button.primary { background: var(--coral); color: white; }
.button.primary:hover { background: var(--coral-dark); }
.form-error { min-height: 20px; color: var(--coral-dark); font-size: 13px; }
.login-foot { margin: 18px 0 0; font-size: 12px; color: var(--muted); }

.topbar { height: 72px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 0 clamp(18px, 4vw, 62px); position: sticky; top: 0; z-index: 5; background: rgba(245,241,233,.94); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand b, .brand small { display: block; }
.brand b { font-family: Georgia, serif; font-size: 18px; }
.brand small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 11px; }
.live-dot { font-size: 12px; color: var(--muted); }
.live-dot i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; box-shadow: 0 0 0 4px rgba(46,139,99,.12); }
.role-pill, .lock { padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.icon-button { border: 0; background: transparent; color: var(--coral-dark); padding: 8px; font-size: 13px; }

main { width: min(1500px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 70px; }
.hero-row { display: flex; justify-content: space-between; gap: 40px; align-items: end; }
.hero-row h1 { margin: 7px 0 10px; font: 500 clamp(38px, 5vw, 67px)/1 Georgia, serif; letter-spacing: -.045em; }
.muted { margin: 0; color: var(--muted); font-size: 14px; }
.exchange-switch { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.exchange { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 10px 13px; border-radius: 2px; font-weight: 750; }
.exchange span { display: block; font-size: 8px; text-transform: uppercase; letter-spacing: .12em; margin-top: 3px; font-weight: 600; }
.exchange.active { border-color: var(--ink); background: var(--ink); color: var(--white); }
.exchange:disabled { cursor: default; opacity: .6; }

.scan-panel { display: grid; grid-template-columns: 1fr 1.35fr minmax(230px, .65fr); gap: 26px; align-items: end; margin: 38px 0 22px; padding: 24px; background: var(--paper-2); border: 1px solid var(--line); }
.control-label { margin: 0 0 9px; color: var(--muted); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); background: var(--white); }
.segmented button { border: 0; background: transparent; padding: 13px; color: var(--muted); font-weight: 700; }
.segmented button.active { background: var(--ink); color: var(--white); }
.amount-block { display: grid; grid-template-columns: 145px 1fr; column-gap: 12px; }
.amount-block .control-label { grid-column: 1 / -1; }
.amount-presets { display: flex; gap: 5px; align-items: stretch; }
.amount-presets button { flex: 1; border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 6px; font-size: 10px; }
.amount-presets button.active { border-color: var(--coral); color: var(--coral-dark); background: rgba(217,74,63,.06); }
.scan-button { min-height: 69px; border: 0; background: var(--coral); color: white; display: flex; align-items: center; justify-content: center; gap: 13px; padding: 13px 20px; box-shadow: 5px 5px 0 var(--ink); }
.scan-button:hover { background: var(--coral-dark); }
.scan-button:disabled { opacity: .7; cursor: wait; }
.scan-button b, .scan-button small { display: block; text-align: left; }
.scan-button small { opacity: .72; margin-top: 3px; }
.scan-icon { font-size: 25px; }
.scan-button.loading .scan-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); margin-bottom: 22px; background: var(--white); }
.metric-grid article { padding: 18px 20px; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border: 0; }
.metric-grid span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.metric-grid strong { display: block; font: 500 29px Georgia, serif; margin-top: 7px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.card { border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow); }
.card-head { min-height: 92px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 21px 24px; border-bottom: 1px solid var(--line); }
.card-head.compact { min-height: 78px; padding: 17px 19px; }
.card-head h2 { margin: 6px 0 0; font: 500 23px Georgia, serif; }
.timestamp { color: var(--muted); font-size: 12px; text-align: right; }
.loading-line { height: 3px; overflow: hidden; background: rgba(217,74,63,.13); }
.loading-line i { display: block; height: 100%; width: 35%; background: var(--coral); animation: loading 1.1s ease-in-out infinite; }
@keyframes loading { from { transform: translateX(-110%); } to { transform: translateX(320%); } }
.table-wrap { overflow-x: auto; min-height: 400px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 13px 15px; text-align: left; color: var(--muted); text-transform: uppercase; font-size: 9px; letter-spacing: .1em; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 15px; border-bottom: 1px solid #ece6dd; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #faf7f1; }
.rank { color: var(--muted); }
.nick { font-weight: 800; }
.price { font: 600 18px Georgia, serif; }
.tag { display: inline-block; padding: 5px 7px; border-radius: 99px; font-size: 10px; font-weight: 800; }
.tag.competitor { color: #9f302a; background: #fae3de; }
.tag.team { color: #226c4d; background: #dff1e7; }
.empty-row td { height: 280px; text-align: center; white-space: normal; color: var(--muted); }
.status-bar { min-height: 44px; display: flex; align-items: center; padding: 10px 20px; border-top: 1px solid var(--line); color: var(--muted); background: #faf7f1; font-size: 12px; }
.status-bar.error { color: var(--coral-dark); }

.side-stack { display: grid; gap: 22px; }
.count { width: 31px; height: 31px; border-radius: 50%; background: var(--ink); color: var(--white); display: grid; place-items: center; font-size: 12px; }
.add-form { display: grid; grid-template-columns: 1fr 105px 42px; gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); background: #faf7f1; }
.add-form input, .add-form select { padding: 10px; font-size: 12px; }
.add-form button { border: 0; background: var(--coral); color: white; font-size: 21px; }
.watch-list { max-height: 402px; overflow-y: auto; }
.watch-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 11px 16px; border-bottom: 1px solid #ece6dd; }
.watch-item:last-child { border-bottom: 0; }
.watch-item b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.watch-item small { color: var(--muted); font-size: 10px; }
.watch-item button { border: 0; background: transparent; color: #a69d91; width: 28px; height: 28px; font-size: 18px; }
.watch-item button:hover { color: var(--coral); }
.watch-empty { padding: 28px 18px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.5; }
.lock { font-size: 8px; padding: 5px 7px; }
.common-card { box-shadow: none; }
.common-card .watch-list { max-height: 260px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 360px; padding: 13px 17px; background: var(--ink); color: var(--white); box-shadow: 5px 5px 0 var(--amber); transform: translateY(120px); opacity: 0; transition: .25s ease; font-size: 13px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { box-shadow-color: var(--coral); }

@media (max-width: 1050px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { max-width: 620px; margin: auto; }
  .scan-panel { grid-template-columns: 1fr 1fr; }
  .scan-button { grid-column: 1 / -1; }
  .workspace-grid { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .login-shell { padding: 18px; }
  .login-card { padding: 28px 22px; box-shadow: 7px 7px 0 rgba(217,74,63,.8); }
  .field-row { grid-template-columns: 1fr; }
  .button { min-height: 46px; }
  .topbar { padding: 0 14px; }
  .live-dot { display: none; }
  main { width: min(100% - 24px, 1500px); padding-top: 28px; }
  .hero-row { display: block; }
  .exchange-switch { justify-content: flex-start; margin-top: 24px; }
  .scan-panel { grid-template-columns: 1fr; padding: 14px; gap: 18px; }
  .scan-button { grid-column: auto; }
  .amount-block { grid-template-columns: 1fr; }
  .amount-presets { margin-top: 7px; overflow-x: auto; }
  .amount-presets button { min-width: 62px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article:nth-child(2) { border-right: 0; }
  .metric-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .side-stack { grid-template-columns: 1fr; }
  .card-head { display: block; }
  .timestamp { display: block; text-align: left; margin-top: 8px; }
  .add-form { grid-template-columns: 1fr 42px; }
  .add-form select { grid-row: 2; grid-column: 1 / -1; }
}
:root .status-bar.warning { color: #9d5200; background: #fff4df; border-color: #dfb979; }
