@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

:root {
  color-scheme: light;
  --background: #f3f6fb;
  --surface: #ffffff;
  --surface-secondary: #f7f9fd;
  --primary: #2864dc;
  --primary-hover: #1c52c2;
  --primary-soft: #e9f0ff;
  --text: #16243a;
  --text-muted: #66758d;
  --border: #dce4ef;
  --shadow: 0 18px 48px rgba(27, 53, 92, .09);
  --success: #168653;
  --success-soft: #e8f7ef;
  --danger: #cf3f4d;
  --danger-soft: #fff0f1;
  --warning: #a86c0b;
  --warning-soft: #fff5df;
  --focus: rgba(40, 100, 220, .25);
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #091321;
  --surface: #111e30;
  --surface-secondary: #15253a;
  --primary: #59a2ff;
  --primary-hover: #78b4ff;
  --primary-soft: #1c3452;
  --text: #edf3fc;
  --text-muted: #91a1b8;
  --border: #263852;
  --shadow: 0 20px 55px rgba(0, 0, 0, .3);
  --success: #5bd49a;
  --success-soft: #183a32;
  --danger: #ff7b85;
  --danger-soft: #41242e;
  --warning: #f2bd58;
  --warning-soft: #3d3321;
  --focus: rgba(89, 162, 255, .3);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
  min-height: 100vh; margin: 0; color: var(--text); background: var(--background);
  font-family: var(--sans); transition: background-color .2s ease, color .2s ease;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.auth-page { display: grid; place-items: center; padding: 70px 20px 32px; position: relative; }
.auth-page::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, rgba(52, 112, 221, .09), transparent 45%);
}
.page-tools { position: absolute; right: clamp(18px, 4vw, 44px); top: 22px; z-index: 2; }
.theme-toggle {
  min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text-muted);
  background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 600;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .15s ease;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.theme-icon { color: var(--primary); font-size: 16px; line-height: 1; }
.auth-card {
  position: relative; z-index: 1; width: min(100%, 430px); padding: 40px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); animation: rise-in .35s ease both;
}
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 25px;
  border: 1px solid rgba(40, 100, 220, .2); border-radius: 14px; color: var(--primary);
  background: var(--primary-soft); font-size: 22px; font-weight: 800; letter-spacing: -.08em;
}
.brand-mark span { color: var(--text); font-size: 15px; margin-left: 1px; }
.brand-mark.small { width: 35px; height: 35px; margin: 0; border-radius: 11px; font-size: 17px; }
.eyebrow { margin: 0 0 11px; color: var(--primary); font: 500 10px var(--mono); letter-spacing: .14em; }
.auth-card h1 { margin: 0 0 9px; font-size: 38px; line-height: 1.15; letter-spacing: -.055em; }
.auth-card h1 span, .intro h1 span, .admin-title h1 span { color: var(--primary); }
.muted, .intro > p:last-child { color: var(--text-muted); line-height: 1.7; }
.auth-card .muted { margin: 0; font-size: 14px; }
.auth-card form { margin-top: 29px; }
label, .field-label { display: block; margin-bottom: 9px; color: var(--text-muted); font: 500 10px var(--mono); letter-spacing: .1em; }
input, select {
  width: 100%; min-height: 50px; padding: 0 15px; outline: none; border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); background: var(--surface-secondary); font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .2s ease;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
.button {
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  border: 1px solid transparent; border-radius: 10px; padding: 0 18px; cursor: pointer;
  font-size: 13px; font-weight: 700; transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, .theme-toggle:focus-visible, .text-button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.button:disabled { opacity: .72; cursor: wait; }
.primary { color: #fff; background: var(--primary); box-shadow: 0 7px 16px rgba(40, 100, 220, .17); }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.auth-card .button { width: 100%; justify-content: space-between; margin-top: 14px; }
.form-message { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }
.market-clock { display: grid; justify-items: center; gap: 9px; width: 100%; min-width: 0; margin: 0 0 17px; padding: 21px 24px 20px; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 7px 22px rgba(27, 53, 92, .045); }
.clock-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(100%, 680px); }
.market-clock .eyebrow { margin: 0; }
.market-clock strong { max-width: 100%; color: var(--text); font: 500 clamp(38px, 9vw, 62px)/1.08 var(--mono); letter-spacing: .035em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock-zone { max-width: 100%; color: var(--text-muted); text-align: center; font: 11px/1.5 var(--mono); overflow-wrap: anywhere; }
.clock-status { flex: 0 0 auto; color: var(--success); font: 9px var(--mono); letter-spacing: .08em; }
.signal-countdown { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 14px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-secondary); }
.signal-countdown span { color: var(--text-muted); font: 10px var(--mono); letter-spacing: .05em; }
.signal-countdown strong { color: var(--primary); font: 500 18px var(--mono); font-variant-numeric: tabular-nums; }
.signal-countdown.expired strong, .signal-countdown.expired span { color: var(--danger); }
.admin-link { display: inline-block; margin-top: 19px; color: var(--text-muted); font-size: 12px; text-decoration: none; }
.admin-link:hover { color: var(--primary); }
.auth-footer { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-muted); font: 10px var(--mono); }
.auth-footer span { padding: 0 5px; color: var(--primary); }

.topbar {
  min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 max(24px, calc((100% - 1080px) / 2)); border-bottom: 1px solid var(--border);
  background: var(--surface); box-shadow: 0 2px 8px rgba(27, 53, 92, .025);
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 800; letter-spacing: .01em; }
.wordmark > span:last-child { display: grid; gap: 3px; }
.wordmark small { color: var(--text-muted); font: 9px var(--mono); letter-spacing: .11em; }
.top-actions { display: flex; align-items: center; gap: 13px; }
.live-pill, .duration-pill { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 99px; padding: 8px 11px; color: var(--text-muted); background: var(--surface-secondary); font: 9px var(--mono); letter-spacing: .08em; }
.live-pill i { width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.text-button { min-height: 40px; padding: 0 8px; border: 0; color: var(--text-muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; }
.text-button:hover { color: var(--primary); }
.dashboard, .admin-page { width: min(calc(100% - 40px), 780px); margin: 54px auto; }
.intro { margin: 0 0 29px; }
.intro .eyebrow { display: flex; align-items: center; gap: 12px; }
.line { width: 30px; height: 1px; background: var(--border); }
.intro h1 { margin: 0 0 9px; font-size: clamp(33px, 5vw, 43px); line-height: 1.1; letter-spacing: -.06em; }
.intro > p:last-child { max-width: 560px; margin: 0; font-size: 14px; }
.generator-panel, .result-card, .mg-card, .empty-state, .admin-section {
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 7px 22px rgba(27, 53, 92, .045);
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.generator-panel { padding: 25px 27px 21px; }
.panel-heading, .result-top, .mg-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-heading { margin-bottom: 25px; }
.panel-heading h2, .result-top h2, .mg-heading h2, .admin-section h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.panel-heading .eyebrow { margin-bottom: 7px; }
.duration-pill { border-color: rgba(40, 100, 220, .18); color: var(--primary); background: var(--primary-soft); font-weight: 500; }
.duration-dot { width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--primary); }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 48px; cursor: pointer; font-weight: 600; }
.select-wrap select optgroup { color: var(--text-muted); font-weight: 700; }
.select-chevron { position: absolute; top: 11px; right: 16px; color: var(--primary); font-size: 19px; pointer-events: none; }
.generate-button { width: 100%; justify-content: space-between; margin-top: 7px; }
.button-arrow { font-size: 18px; }
.button-loading { display: inline-flex; align-items: center; gap: 10px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.secure-note { margin: 14px 0 0; color: var(--text-muted); text-align: center; font: 10px var(--mono); }
.secure-note span { margin-right: 5px; color: var(--primary); }
.empty-state { display: grid; justify-items: center; gap: 7px; margin-top: 17px; padding: 23px 18px; text-align: center; background: var(--surface-secondary); box-shadow: none; }
.empty-state strong { font-size: 13px; }
.empty-state > span:last-child { color: var(--text-muted); font-size: 11px; }
.empty-icon { width: 29px; height: 29px; display: grid; place-items: center; margin-bottom: 3px; border-radius: 9px; color: var(--primary); background: var(--primary-soft); font-size: 17px; }
.result-card { margin-top: 18px; padding: 25px 27px 19px; animation: rise-in .28s ease both; }
.result-top { padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.result-top .eyebrow { margin-bottom: 6px; }
.result-top h2 { font-size: 20px; letter-spacing: .01em; }
.direction-badge, .mg-direction { display: inline-flex; align-items: center; justify-content: center; min-width: 76px; padding: 10px 13px; border: 1px solid rgba(22, 134, 83, .2); border-radius: 9px; color: var(--success); background: var(--success-soft); font: 700 12px var(--mono); letter-spacing: .08em; }
.direction-badge.sell, .mg-direction.sell { border-color: rgba(207, 63, 77, .2); color: var(--danger); background: var(--danger-soft); }
.result-grid, .mg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 18px; padding: 20px 0; }
.result-grid div, .mg-grid div { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.result-grid span, .mg-grid span { color: var(--text-muted); font: 9px var(--mono); letter-spacing: .1em; }
.result-grid strong, .mg-grid strong { overflow-wrap: anywhere; font-size: 14px; font-weight: 600; }
.copy-button { width: 100%; color: #fff; background: var(--text); }
.copy-button:hover { background: var(--primary); }
.copy-feedback { min-height: 14px; margin: 9px 0 0; color: var(--success); text-align: center; font-size: 11px; }
.mg-card { margin-top: 12px; padding: 20px 25px 15px; border-left: 3px solid var(--primary); background: var(--surface-secondary); animation: rise-in .32s ease both; }
.mg-heading { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.mg-heading .eyebrow { margin-bottom: 5px; }
.mg-heading h2 { font-size: 13px; letter-spacing: .04em; }
.mg-direction { min-width: 62px; padding: 7px 9px; font-size: 10px; }
.mg-grid { grid-template-columns: repeat(3, minmax(0,1fr)); padding: 15px 0 10px; }
.mg-grid strong { font-size: 12px; }
.mg-card > p { margin: 0; color: var(--text-muted); font-size: 10px; }
.disclaimer { margin: 19px 0; color: var(--text-muted); text-align: center; font-size: 10px; }
.hidden { display: none !important; }

.admin-page { width: min(calc(100% - 40px), 940px); margin-top: 43px; }
.admin-title { margin-bottom: 24px; }
.admin-title h1 { margin: 0; font-size: 27px; letter-spacing: -.04em; }
.admin-title h1 span { margin-left: 6px; font-size: 17px; }
.admin-title .muted { margin: 6px 0 0; font-size: 13px; }
.status-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-section { min-width: 0; padding: 19px; }
.section-title { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.section-title h2 { margin: 0; font: 500 10px var(--mono); letter-spacing: .13em; }
.section-title .section-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-size: 13px; }
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.status-item { min-width: 0; min-height: 70px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-secondary); }
.status-item > span { display: block; margin-bottom: 8px; color: var(--text-muted); font: 9px var(--mono); letter-spacing: .06em; }
.status-value { display: flex; align-items: flex-start; gap: 7px; font-size: 12px; line-height: 1.45; font-weight: 600; overflow-wrap: anywhere; }
.status-value.mono { display: block; color: var(--text-muted); font: 9px/1.5 var(--mono); overflow-wrap: anywhere; }
.status-dot { width: 7px; height: 7px; flex: 0 0 7px; margin-top: 4px; border-radius: 50%; background: var(--text-muted); }
.status-dot.good { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status-dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.broker-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 13px; }
.broker-actions .button { min-height: 39px; padding: 0 13px; font-size: 11px; }
.secondary { color: var(--primary); border-color: rgba(40, 100, 220, .2); background: var(--primary-soft); }
.secondary:hover:not(:disabled) { border-color: var(--primary); }
.admin-feedback { min-height: 15px; margin: 0; color: var(--text-muted); font-size: 10px; }
.admin-feedback.error { color: var(--danger); }
.settings-section { grid-column: 1 / -1; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.settings-card { min-width: 0; padding: 17px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-secondary); }
.settings-card-heading h3 { margin: 0 0 5px; font: 500 10px var(--mono); letter-spacing: .1em; }
.settings-card-heading p { margin: 0; color: var(--text-muted); font-size: 11px; line-height: 1.55; }
.settings-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; margin: 14px 0; color: var(--text-muted); font: 9px/1.5 var(--mono); }
.settings-card form { display: grid; gap: 9px; }
.settings-card label { margin: 3px 0 0; }
.settings-card input { min-height: 43px; font-size: 12px; }
.settings-card .button { min-height: 42px; padding: 0 13px; font-size: 10px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 3px; }
.settings-actions .button { flex: 1 1 auto; }
.settings-card .admin-feedback { min-height: 16px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 680px) {
  .auth-card { padding: 31px 26px; }
  .topbar { min-height: 64px; padding: 0 15px; }
  .top-actions { gap: 7px; }
  .live-pill { display: none; }
  .theme-toggle { min-height: 38px; padding: 0 9px; }
  .dashboard, .admin-page { width: min(calc(100% - 28px), 580px); margin: 35px auto; }
  .intro { margin-bottom: 22px; }
  .intro h1 { font-size: 35px; }
  .intro > p:last-child { font-size: 13px; }
  .generator-panel, .result-card { padding: 21px 18px 17px; }
  .market-clock { gap: 8px; margin-bottom: 14px; padding: 17px 15px; }
  .clock-heading { gap: 6px; }
  .clock-heading .eyebrow { font-size: 9px; }
  .clock-status { font-size: 8px; }
  .clock-zone { font-size: 10px; }
  .panel-heading { margin-bottom: 20px; }
  .result-grid { gap: 17px 12px; }
  .result-grid strong { font-size: 13px; }
  .mg-card { padding: 17px 16px 14px; }
  .status-sections { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .admin-title h1 { font-size: 24px; }
  .admin-title h1 span { display: block; margin: 4px 0 0; font-size: 15px; }
}
@media (max-width: 380px) {
  .wordmark { gap: 7px; font-size: 12px; }
  .wordmark small { font-size: 8px; }
  .top-actions { gap: 2px; }
  .text-button { padding: 0 5px; font-size: 11px; }
  .theme-toggle { gap: 5px; padding: 0 7px; font-size: 11px; }
  .result-grid, .status-grid { grid-template-columns: 1fr 1fr; }
  .mg-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
