/* ==========================================================================
   Trade Toolkit PRO — Institutional Design System
   Modern Dark/Light Glassmorphism & High-Performance Trading Aesthetics
   ========================================================================== */

/* --- Google Fonts Fallbacks & Base Tokens --- */
:root {
  color-scheme: dark;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Theme: Cyber Dark (Default) */
  --bg: #080b11;
  --bg-secondary: #0e131f;
  --bg-tertiary: #141c2e;

  --surface: rgba(14, 20, 33, 0.78);
  --surface2: rgba(22, 31, 50, 0.75);
  --surface-solid: #111827;
  --surface-elevated: #1a2337;
  --surface-hover: rgba(28, 39, 64, 0.85);

  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: #6366f1;

  --text: #f1f5f9;
  --text-muted: #8b9bb4;
  --text-dim: #54647d;
  --text-inverse: #080b11;

  /* Trading Accent Colors */
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: rgba(99, 102, 241, 0.15);
  --accent-glow: rgba(99, 102, 241, 0.4);

  --green: #10b981;
  --green-hover: #059669;
  --green-light: rgba(16, 185, 129, 0.12);
  --green-glow: rgba(16, 185, 129, 0.35);

  --red: #f43f5e;
  --red-hover: #e11d48;
  --red-light: rgba(244, 63, 94, 0.12);
  --red-glow: rgba(244, 63, 94, 0.35);

  --amber: #f59e0b;
  --amber-light: rgba(245, 158, 11, 0.12);
  --amber-glow: rgba(245, 158, 11, 0.3);

  --cyan: #06b6d4;
  --cyan-light: rgba(6, 182, 212, 0.12);

  /* Charts & Grids */
  --chart: #10b981;
  --grid: rgba(255, 255, 255, 0.06);

  /* Glassmorphism & Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.06);
  --shadow-lg: 0 20px 45px -10px rgba(0, 0, 0, 0.65), 0 0 2px 1px rgba(255, 255, 255, 0.09);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.2);

  --glass-blur: blur(16px);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 9999px;

  /* Legacy mappings */
  --muted: var(--text-muted);
}

/* --- Theme: Pristine Light Mode --- */
html[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f7fb;
  --bg-secondary: #eaf0f7;
  --bg-tertiary: #dfe7f2;

  --surface: rgba(255, 255, 255, 0.88);
  --surface2: rgba(246, 249, 254, 0.85);
  --surface-solid: #ffffff;
  --surface-elevated: #f8fafc;
  --surface-hover: rgba(255, 255, 255, 1);

  --border: rgba(203, 213, 225, 0.8);
  --border-subtle: rgba(226, 232, 240, 0.7);
  --border-strong: rgba(148, 163, 184, 0.6);
  --border-focus: #4f46e5;

  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --text-inverse: #ffffff;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: rgba(79, 70, 229, 0.08);
  --accent-glow: rgba(79, 70, 229, 0.2);

  --green: #059669;
  --green-hover: #047857;
  --green-light: rgba(5, 150, 105, 0.08);
  --green-glow: rgba(5, 150, 105, 0.2);

  --red: #e11d48;
  --red-hover: #be123c;
  --red-light: rgba(225, 29, 72, 0.08);
  --red-glow: rgba(225, 29, 72, 0.2);

  --amber: #d97706;
  --amber-light: rgba(217, 119, 6, 0.08);
  --amber-glow: rgba(217, 119, 6, 0.2);

  --cyan: #0891b2;
  --cyan-light: rgba(8, 145, 178, 0.08);

  --chart: #059669;
  --grid: rgba(0, 0, 0, 0.06);

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.07), 0 0 1px 1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 40px -10px rgba(15, 23, 42, 0.1), 0 0 2px 1px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.15);

  --muted: var(--text-muted);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  position: relative;
  overflow-x: hidden;
  transition: background 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Ambient Radial Backlights */
body::before {
  content: '';
  position: fixed;
  top: -240px;
  left: 12%;
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 68%);
  pointer-events: none;
  z-index: -1;
  filter: blur(40px);
}

body::after {
  content: '';
  position: fixed;
  top: 35%;
  right: 5%;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
  filter: blur(50px);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  padding: 16px max(28px, calc((100vw - 1380px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.mark::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0%, transparent 100%);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

header h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.pro-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-light);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

header p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.market-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.market-tag strong {
  color: var(--text);
}

/* Theme Toggle Button */
.themebutton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.themebutton:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.themebutton:active {
  transform: translateY(0);
}

.themebutton span:first-child {
  font-size: 15px;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
main {
  max-width: 1380px;
  margin: 28px auto 60px;
  padding: 0 24px;
}

/* Tab Navigation Bar */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  flex: 1;
  min-width: 160px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.tabs button .tab-icon {
  font-size: 16px;
  opacity: 0.8;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.tabs button:hover {
  background: var(--surface2);
  color: var(--text);
}

.tabs button:hover .tab-icon {
  opacity: 1;
  transform: scale(1.1);
}

.tabs button[aria-selected="true"] {
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.tabs button[aria-selected="true"] .tab-icon {
  opacity: 1;
}

.tabs button .tab-label {
  display: inline;
}

.matrix-mobile-sub {
  display: none;
}

.show-mobile {
  display: none;
}

.hide-mobile {
  display: inline;
}

/* Intro Section Headers */
.intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.intro h2, h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text);
  margin: 0;
  line-height: 1.25;
}

.intro p, .orderheading p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

/* General Buttons */
button {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

button:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  color: #ffffff !important;
  border-color: transparent;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.primary:hover {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #6d28d9 100%);
  box-shadow: 0 6px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(244, 63, 94, 0.3);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.danger:hover {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red-hover);
}

/* ==========================================================================
   Card Surfaces & Form Controls
   ========================================================================== */
.controls {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 22px;
  position: relative;
  overflow: hidden;
}

/* Glowing Top Accent on Card */
.controls::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #06b6d4, #10b981);
}

.input-field {
  display: flex;
  flex-direction: column;
  position: relative;
}

label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 14px;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dim);
  pointer-events: none;
}

input, select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.has-prefix input {
  padding-left: 36px;
}

input:hover, select:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

input:focus, select:focus {
  border-color: var(--border-focus);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px var(--accent-light), inset 0 2px 4px rgba(0, 0, 0, 0.1);
  outline: none;
}

small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 7px;
  line-height: 1.4;
  font-weight: 500;
}

/* Quick Preset Chips */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.preset-chip {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Error Messages */
.error {
  background: var(--red-light);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--red);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ==========================================================================
   KPI Summary Bento Cards
   ========================================================================== */
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 26px 0;
}

.stat {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.stat::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 4px;
  border-radius: 0 4px 4px 0;
}

.stat:nth-child(1)::before {
  background: linear-gradient(180deg, #6366f1, #a855f7);
}

.stat:nth-child(2)::before {
  background: linear-gradient(180deg, #06b6d4, #3b82f6);
}

.stat:nth-child(3)::before {
  background: linear-gradient(180deg, #10b981, #059669);
}

.stat span {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.stat strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 800;
  margin-top: 10px;
  letter-spacing: -0.7px;
  color: var(--text);
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.stat small {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

/* Hero / Highlighted Stat Card (First item in Order & Lot summaries) */
#order-panel .stat:first-child {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18) 0%, rgba(16, 185, 129, 0.12) 100%), var(--surface);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: var(--shadow), 0 0 25px rgba(99, 102, 241, 0.12);
}

#order-panel .stat:first-child::before {
  background: linear-gradient(180deg, #6366f1, #10b981);
}

/* ==========================================================================
   Trading Tables
   ========================================================================== */
.tablebox {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.tablehead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  gap: 12px;
}

.tablehead h3 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tablehead span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-search {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  width: 170px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.table-action-btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
}

.table-action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.scroll {
  overflow-x: auto;
  max-height: 600px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.scroll::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.scroll::-webkit-scrollbar-track {
  background: transparent;
}

.scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13.5px;
  font-family: var(--font-mono);
}

th {
  text-align: right;
  white-space: nowrap;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

th:first-child, td:first-child {
  text-align: left;
}

td {
  text-align: right;
  white-space: nowrap;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  font-weight: 600;
  transition: background 0.15s ease;
}

td:first-child {
  font-weight: 700;
  color: var(--text);
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:hover {
  background: var(--surface-hover) !important;
}

/* Pills & Semantic Badges */
.gain {
  color: var(--green) !important;
  font-weight: 700;
}

.loss {
  color: var(--red) !important;
  font-weight: 700;
}

.lot {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.gain-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--green-light);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}

.loss-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--red-light);
  color: var(--red);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}

.year-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

tr.year-milestone td {
  border-bottom: 2px solid rgba(99, 102, 241, 0.35) !important;
}

tr.year-milestone {
  background: rgba(99, 102, 241, 0.04) !important;
}

/* Order Table Inputs */
.orderinput {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  padding: 7px 10px;
  width: 120px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: right;
}

.orderinput:focus {
  border-color: var(--border-focus);
}

.ordertotal, .ordertotal td {
  background: var(--surface2) !important;
  font-weight: 800;
  border-top: 2px solid var(--border-strong);
  color: var(--text);
  font-size: 14px;
}

/* Notes & Footers */
.notes {
  display: flex;
  justify-content: space-between;
  gap: 25px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 18px 4px 30px;
}

.notes p {
  margin: 0;
}

.calculation {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-block;
  margin-top: 4px;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 45px !important;
  font-style: italic;
}

/* ==========================================================================
   Order Grid & Quantity Layout
   ========================================================================== */
.ordergrid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  align-items: start;
}

.ordergrid .controls {
  grid-template-columns: 1fr 1fr;
}

.ordergrid h3 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 16px;
}

.ordergrid aside {
  display: flex;
  flex-direction: column;
}

.ordergrid aside .stat {
  margin-bottom: 16px;
}

/* ==========================================================================
   Charts & Visualizations
   ========================================================================== */
.chartbox {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.chartbox svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chartbox svg text {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--text-muted);
}

.chartmeta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.chartmeta strong {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
}

.chartempty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Range Slider Control */
.rangecontrol {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rangecontrol label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.rangecontrol label span {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
}

.rangecontrol input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface2);
  border: 1px solid var(--border);
  outline: none;
  padding: 0;
  cursor: pointer;
}

.rangecontrol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rangecontrol input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.18);
  box-shadow: 0 0 16px var(--accent-glow);
}

.rangecontrol input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Growth Controls Grid */
.growthcontrols {
  grid-template-columns: repeat(4, 1fr);
}

.projectionnote {
  background: var(--amber-light);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: var(--amber);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.6;
  margin: 16px 0 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* ==========================================================================
   Lot Reference Matrix Cards Grid
   ========================================================================== */
.matrix-jump-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.jump-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  letter-spacing: 0.6px;
  margin-right: 4px;
}

.matrix-jump-btn {
  font-size: 11.5px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
}

.matrix-jump-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.lot-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  max-height: 580px;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.lot-cards-grid::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.lot-cards-grid::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}

.lot-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  user-select: none;
  content-visibility: auto;
  contain-intrinsic-size: 115px;
}

.lot-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  background: linear-gradient(90deg, var(--accent), var(--chart));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.lot-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28), 0 0 15px var(--accent-glow);
}

.lot-card:hover::before {
  opacity: 1;
}

.lot-card.active-lot {
  border-color: var(--accent) !important;
  background: var(--surface-elevated) !important;
  box-shadow: 0 0 0 2px var(--accent), 0 8px 24px var(--accent-glow) !important;
}

.lot-card.active-lot::before {
  opacity: 1 !important;
}

.lot-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lot-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

.lot-card-qty {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.lot-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lot-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}

.lot-card-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
}

/* ==========================================================================
   Quick Trader Calculator — Circle Circle Visual Style
   ========================================================================== */
.calc-layout {
  display: grid;
  grid-template-columns: 430px 1fr;
  gap: 28px;
  align-items: start;
}

.calc-device {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  padding: 26px 24px;
  box-shadow: var(--shadow-lg), 0 0 30px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.calc-device::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #06b6d4, #10b981);
}

/* Calculator Screen Display */
.calc-screen {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  min-height: 110px;
  position: relative;
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.25);
}

.calc-copy-btn {
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.8;
  transition: all 0.15s ease;
}

.calc-copy-btn:hover {
  opacity: 1;
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.calc-expr {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 20px;
  word-break: break-all;
  text-align: right;
  margin-bottom: 4px;
}

.calc-display {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1.1;
  word-break: break-all;
  text-align: right;
  transition: transform 0.1s ease;
}

.calc-pulse {
  animation: calc-result-pulse 0.25s ease-out;
}

@keyframes calc-result-pulse {
  0% { transform: scale(0.97); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* Quick % Target Deltas Bar */
.calc-quick-deltas {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.calc-quick-deltas::-webkit-scrollbar {
  display: none;
}

.calc-delta-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.calc-delta-chip.pos:hover {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
  transform: translateY(-1px);
}

.calc-delta-chip.neg:hover {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red);
  transform: translateY(-1px);
}

/* CIRCLE CIRCLE Keypad Grid */
.calc-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  justify-items: center;
  align-items: center;
}

/* Pure Circle Buttons */
.calc-circle-btn {
  width: 66px;
  height: 66px;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  padding: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.calc-circle-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.calc-circle-btn:active,
.calc-circle-btn.calc-active-press {
  transform: scale(0.92);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Number Circle */
.calc-btn-num {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

.calc-btn-num:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

/* Function Circle (C, ±, %, DEL) */
.calc-btn-fn {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  border-color: var(--border);
  font-size: 19px;
}

.calc-btn-fn:hover {
  background: rgba(148, 163, 184, 0.22);
  color: var(--text);
}

.calc-btn-clear {
  color: var(--amber) !important;
}

.calc-btn-clear:hover {
  background: var(--amber-light) !important;
  border-color: var(--amber) !important;
}

/* Operator Circle (+, −, ×, ÷) */
.calc-btn-op {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(124, 58, 237, 0.25) 100%);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.4);
  font-size: 24px;
}

.calc-btn-op:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.45) 0%, rgba(124, 58, 237, 0.45) 100%);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 16px var(--accent-glow);
}

/* Equals Circle (=) - Hero Circle */
.calc-btn-eq {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  font-size: 25px;
  box-shadow: 0 4px 18px var(--green-glow);
}

.calc-btn-eq:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  box-shadow: 0 6px 24px var(--green-glow);
  transform: scale(1.08);
}

/* Side History Tape & Trader Tools */
.calc-side-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.calc-history-box {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calc-history-list {
  max-height: 290px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
}

.calc-history-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.calc-history-item:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateX(3px);
}

.calc-history-expr {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.calc-history-res {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--green);
}

.calc-tool-card {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.calc-tool-card h4 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.calc-tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: flex-end;
}

.calc-tool-grid .input-field label {
  font-size: 11px;
}

.calc-tool-grid input {
  font-size: 16px;
  padding: 8px 12px;
  min-height: 40px;
}

.calc-tool-result {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  color: var(--text);
}

/* ==========================================================================
   Responsive Breakpoints & Mobile Optimization
   ========================================================================== */

/* Tablets and small laptops (<= 1050px) */
@media (max-width: 1050px) {
  .ordergrid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .growthcontrols {
    grid-template-columns: repeat(2, 1fr);
  }
  .calc-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .calc-device {
    width: 100%;
    max-width: 420px;
  }
  .calc-side-panel {
    width: 100%;
    max-width: 420px;
  }
}

/* Medium Tablets & Large Phones (<= 820px) */
@media (max-width: 820px) {
  header {
    padding: 12px 18px;
    gap: 12px;
  }
  .controls {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 20px 18px;
  }
  .growthcontrols {
    grid-template-columns: 1fr 1fr;
  }
  .summary {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .intro {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .intro button {
    width: auto;
  }
}

/* Small Tablets & Mobile Devices (<= 640px) */
@media (max-width: 640px) {
  body::before {
    width: 350px;
    height: 350px;
    top: -120px;
    left: -50px;
  }
  body::after {
    width: 320px;
    height: 320px;
    bottom: -80px;
    right: -40px;
  }

  /* Compact Single-Row Mobile Header */
  header {
    padding: 10px 14px;
    gap: 8px;
  }
  .brand-wrapper {
    gap: 10px;
    min-width: 0;
  }
  .mark {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-radius: 10px;
    flex-shrink: 0;
  }
  .mark svg {
    width: 18px;
    height: 18px;
  }
  .brand-text {
    min-width: 0;
  }
  header h1 {
    font-size: 16px;
    letter-spacing: -0.4px;
  }
  .pro-badge {
    font-size: 9px;
    padding: 1px 5px;
  }
  .live-indicator {
    font-size: 9.5px;
    padding: 1px 6px;
  }
  .live-dot {
    width: 5px;
    height: 5px;
  }
  header p {
    display: none; /* Hide subtitle to preserve clean single header row */
  }
  .header-actions {
    gap: 6px;
    flex-shrink: 0;
  }
  .market-tag {
    padding: 5px 8px;
    font-size: 11px;
    border-radius: var(--radius-sm);
  }
  .market-tag span {
    display: none; /* Show only currency code */
  }
  #print-btn {
    padding: 5px 8px;
    font-size: 11.5px;
  }
  .themebutton {
    padding: 6px 10px;
    font-size: 13px;
  }
  .themebutton .themelabel {
    display: none; /* Show only icon */
  }

  /* Horizontal Smooth-Scroll Touch Pill Tab Bar */
  main {
    margin: 14px auto 40px;
    padding: 0 12px;
  }
  /* Full-View Mobile Expanding Tabs: Unselected = Icon Only, Selected = Icon + Name */
  .tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
    width: 100%;
    padding: 4px;
    gap: 4px;
    border-radius: 16px;
    margin-bottom: 20px;
    justify-content: space-between;
    box-sizing: border-box;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  /* Inactive Tab: Icon Only, 40-42px width */
  .tabs button[aria-selected="false"] {
    flex: 0 0 42px;
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .tabs button[aria-selected="false"] .tab-label {
    display: none !important;
  }
  .tabs button[aria-selected="false"] .tab-icon {
    font-size: 18px;
    margin: 0;
    opacity: 0.85;
  }
  /* Active Tab: Expands to show Icon + Name */
  .tabs button[aria-selected="true"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 42px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .tabs button[aria-selected="true"] .tab-icon {
    font-size: 16px;
    flex-shrink: 0;
  }
  .tabs button[aria-selected="true"] .tab-label {
    display: inline-block !important;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: tab-label-fade 0.2s ease-out;
  }

  @keyframes tab-label-fade {
    from { opacity: 0; transform: translateX(-4px); }
    to { opacity: 1; transform: translateX(0); }
  }

  /* Headings & Intros */
  .intro {
    margin-bottom: 16px;
    gap: 10px;
  }
  .intro h2, h2 {
    font-size: 21px;
    letter-spacing: -0.5px;
  }
  .intro p, .orderheading p {
    font-size: 13px;
  }
  .intro button {
    width: 100%;
    min-height: 42px;
  }

  /* Forms, Inputs & Presets */
  .controls {
    padding: 16px 14px;
    gap: 16px;
    border-radius: 16px;
    margin-bottom: 18px;
  }
  label {
    font-size: 12px;
    margin-bottom: 6px;
  }
  input, select {
    font-size: 16px !important; /* Prevents auto-zoom on mobile browsers */
    padding: 10px 12px;
    min-height: 44px; /* Standard 44px touch target */
    border-radius: 10px;
  }
  .has-prefix input {
    padding-left: 32px;
  }
  .input-prefix {
    left: 12px;
    font-size: 15px;
  }
  small {
    font-size: 11.5px;
    margin-top: 5px;
  }
  .presets {
    gap: 5px;
    margin-top: 8px;
  }
  .preset-chip {
    padding: 5px 10px;
    font-size: 11px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
  }

  /* Bento Stat Cards */
  .summary {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 18px 0;
  }
  .stat {
    padding: 16px 18px;
    border-radius: 14px;
  }
  .stat span {
    font-size: 11.5px;
  }
  .stat strong {
    font-size: 24px;
    margin-top: 6px;
  }
  .stat small {
    font-size: 11px;
    margin-top: 4px;
  }

  /* Tables & Horizontal Scroll Container */
  .tablebox {
    border-radius: 16px;
    margin-bottom: 18px;
  }
  .tablehead {
    padding: 14px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .tablehead h3 {
    font-size: 15px;
  }
  .tablehead span {
    font-size: 11.5px;
  }
  .table-toolbar {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .table-search {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    padding: 8px 10px;
  }
  .table-action-btn {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 12px;
  }
  .scroll {
    max-height: 440px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  th {
    padding: 11px 12px;
    font-size: 10.5px;
  }
  td {
    padding: 11px 12px;
    font-size: 12.5px;
  }

  /* Price Scenario Matrix — Mobile Viewport Fit (100% Width, Zero Horizontal Scroll) */
  #lot-panel .tablebox .scroll {
    overflow-x: hidden !important;
    max-height: 520px;
  }
  #lot-panel table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse;
  }
  .hide-mobile-col {
    display: none !important;
  }
  .hide-mobile {
    display: none !important;
  }
  .show-mobile {
    display: inline !important;
  }
  .matrix-mobile-sub {
    display: block !important;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    margin-top: 2px;
    line-height: 1.15;
  }
  #lot-panel th.col-price, #lot-panel td.col-price {
    width: 25%;
    text-align: left;
    padding: 10px 8px;
    font-size: 12px;
  }
  #lot-panel th.col-capital, #lot-panel td.col-capital {
    width: 29%;
    text-align: right;
    padding: 10px 8px;
    font-size: 12px;
  }
  #lot-panel th.col-profit, #lot-panel td.col-profit {
    width: 24%;
    text-align: right;
    padding: 10px 8px;
    font-size: 11.5px;
  }
  #lot-panel th.col-lots, #lot-panel td.col-lots {
    width: 22%;
    text-align: right;
    padding: 10px 8px;
    font-size: 11px;
  }
  #lot-panel .lot .lot-label {
    display: none !important;
  }
  #lot-panel .lot {
    padding: 2px 6px;
    font-size: 11px;
    min-width: auto;
  }
  #lot-panel th {
    font-size: 10.5px;
    padding: 10px 8px;
    letter-spacing: 0.3px;
  }

  .orderinput {
    width: 88px;
    min-height: 38px;
    font-size: 15px;
    padding: 6px 8px;
  }
  .notes {
    flex-direction: column;
    gap: 8px;
    font-size: 11.5px;
    margin: 14px 4px 22px;
  }

  /* Charts */
  .chartbox {
    padding: 16px 14px;
    border-radius: 16px;
  }
  .chartmeta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 10px;
  }
  .chartmeta strong {
    font-size: 20px;
  }
  .rangecontrol {
    margin-top: 16px;
  }
  .rangecontrol input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }
  .rangecontrol input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
  }

  /* Lot Reference Matrix Cards */
  .lot-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px;
    max-height: 480px;
  }
  .lot-card {
    padding: 12px 14px;
    gap: 8px;
    border-radius: 12px;
  }
  .lot-badge {
    font-size: 11px;
    padding: 2px 7px;
  }
  .lot-card-qty {
    font-size: 11px;
  }
  .lot-card-val {
    font-size: 16px;
  }
  .matrix-jump-bar {
    padding: 10px 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
  }
  .matrix-jump-bar::-webkit-scrollbar {
    display: none;
  }
  .matrix-jump-btn {
    flex: 0 0 auto;
    padding: 4px 9px;
    font-size: 11px;
  }

  /* Calculator Mobile Styling */
  .calc-device {
    width: 100%;
    max-width: 380px;
    padding: 18px 14px;
    border-radius: 24px;
    gap: 14px;
  }
  .calc-screen {
    padding: 14px 16px;
    min-height: 90px;
    border-radius: 14px;
  }
  .calc-display {
    font-size: 30px;
  }
  .calc-quick-deltas {
    gap: 5px;
  }
  .calc-delta-chip {
    padding: 4px 8px;
    font-size: 11px;
  }
  .calc-keypad {
    gap: 10px;
  }
  .calc-circle-btn {
    width: 58px;
    height: 58px;
    font-size: 19px;
  }
  .calc-btn-op {
    font-size: 22px;
  }
  .calc-side-panel {
    width: 100%;
    max-width: 380px;
    gap: 16px;
  }
  .calc-tool-card {
    padding: 16px 14px;
    border-radius: 16px;
  }
  .calc-tool-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .calc-tool-grid button {
    width: 100%;
    min-height: 42px;
  }

  /* Toast Notifications Centered on Mobile */
  #toast-container {
    left: 14px;
    right: 14px;
    bottom: 14px;
    align-items: center;
  }
  .toast {
    max-width: 100%;
    width: 100%;
    justify-content: center;
    font-size: 13px;
    padding: 10px 14px;
  }
}

/* Extra Small Phones (<= 380px, e.g. iPhone SE, compact Androids) */
@media (max-width: 380px) {
  main {
    padding: 0 8px;
  }
  header {
    padding: 8px 10px;
  }
  header h1 {
    font-size: 15px;
  }
  .growthcontrols {
    grid-template-columns: 1fr;
  }
  .lot-cards-grid {
    grid-template-columns: 1fr;
  }
  .calc-circle-btn {
    width: 50px;
    height: 50px;
    font-size: 17px;
  }
  .calc-btn-op {
    font-size: 19px;
  }
  .calc-keypad {
    gap: 8px;
  }
  .calc-display {
    font-size: 26px;
  }
}

/* Accessibility / Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Print Optimization */
@media print {
  header, .tabs, .themebutton, button, .presets, .table-toolbar {
    display: none !important;
  }
  body, main, .controls, .stat, .tablebox, .chartbox {
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    border-color: #cccccc !important;
  }
  .scroll {
    max-height: none !important;
    overflow: visible !important;
  }
  th {
    position: static !important;
  }
}
