:root {
    --th-bg: #f5f7fa;
    --th-surface: #ffffff;
    --th-surface-2: #eef1f5;
    --th-border: #d5dbe3;
    --th-text: #1a1f26;
    --th-muted: #5c6773;
    --th-accent: #2f81f7;
    --th-up: #1a7f4b;
    --th-down: #d1373c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--th-bg);
    color: var(--th-text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--th-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.th-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--th-surface);
    border-bottom: 1px solid var(--th-border);
}

.th-brand a { display: inline-flex; align-items: center; line-height: 0; }
.th-brand img { display: block; width: 152px; height: 32px; }

.th-nav { display: flex; gap: 1rem; flex: 1; }
.th-nav a { color: var(--th-muted); }
.th-nav a:hover { color: var(--th-text); text-decoration: none; }

.th-user { display: flex; align-items: center; gap: 0.75rem; }
.th-user-name { color: var(--th-muted); }

.th-main { flex: 1; padding: 1.5rem; }

.th-footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--th-border);
    color: var(--th-muted);
    font-size: 0.85rem;
}

.th-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--th-border);
    background: var(--th-surface-2);
    color: var(--th-text);
    cursor: pointer;
    font-size: 0.9rem;
}
.th-btn:hover { text-decoration: none; border-color: var(--th-accent); }
.th-btn-primary { background: var(--th-accent); border-color: var(--th-accent); color: #fff; }
.th-btn-link { background: transparent; border: none; color: var(--th-accent); padding: 0; }
.th-logout-form { display: inline; margin: 0; }

.th-hero { max-width: 640px; margin: 4rem auto; text-align: center; }
.th-hero h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.th-hero p { color: var(--th-muted); margin-bottom: 1.5rem; }
.th-landing-hero { max-width: 1180px; margin: 2rem auto 5rem; padding: 4rem 3rem; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 4rem; align-items: center; border-radius: 24px; background: radial-gradient(circle at 80% 15%, #294b78 0, #14253e 36%, #0b1525 100%); color: #f8fbff; overflow: hidden; }
.th-landing-copy { max-width: 620px; }
.th-eyebrow { color: #64dbc8; font-size: 0.75rem; letter-spacing: 0.16em; font-weight: 700; }
.th-landing-hero h1 { margin: 1rem 0; font-size: clamp(2.5rem, 5vw, 4.8rem); line-height: 1.05; letter-spacing: -0.04em; }
.th-landing-hero h1 strong { color: #64dbc8; font-weight: 700; }
.th-landing-hero p { max-width: 530px; color: #bfd0e4; font-size: 1.1rem; line-height: 1.7; }
.th-landing-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.th-landing-actions .th-btn:not(.th-btn-primary) { border-color: #49627e; background: transparent; color: #f8fbff; }
.th-landing-panel { padding: 1.5rem; border: 1px solid #3b5876; border-radius: 18px; background: linear-gradient(145deg, rgba(43, 76, 116, 0.82), rgba(13, 28, 48, 0.95)); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3); }
.th-preview-top, .th-preview-stats { display: flex; justify-content: space-between; gap: 0.75rem; color: #9db5ce; font-size: 0.72rem; letter-spacing: 0.1em; }
.th-live-dot, .th-preview-symbol span { color: #64dbc8; }
.th-preview-symbol { margin-top: 2.5rem; font-size: 1.2rem; font-weight: 600; }
.th-preview-symbol span { float: right; font-size: 0.85rem; }
.th-preview-price { margin: 0.35rem 0 1.25rem; font-size: 3.2rem; font-weight: 700; letter-spacing: -0.06em; }
.th-preview-chart { height: 130px; display: flex; align-items: end; gap: 0.45rem; padding: 0.5rem 0; border-bottom: 1px solid #3b5876; }
.th-preview-chart i { flex: 1; display: block; border-radius: 5px 5px 0 0; background: linear-gradient(#64dbc8, #2f81f7); }
.th-preview-chart i:nth-child(1) { height: 28%; }.th-preview-chart i:nth-child(2) { height: 45%; }.th-preview-chart i:nth-child(3) { height: 38%; }.th-preview-chart i:nth-child(4) { height: 61%; }.th-preview-chart i:nth-child(5) { height: 54%; }.th-preview-chart i:nth-child(6) { height: 76%; }.th-preview-chart i:nth-child(7) { height: 68%; }.th-preview-chart i:nth-child(8) { height: 94%; }
.th-preview-stats { margin-top: 1rem; letter-spacing: normal; }.th-preview-stats b { display: block; margin-top: 0.25rem; color: #f8fbff; font-size: 0.9rem; }
.th-landing-section { max-width: 1120px; margin: 0 auto 5rem; }.th-section-intro { max-width: 650px; margin-bottom: 2rem; }.th-section-intro h2 { margin: 0.6rem 0; font-size: 2.3rem; letter-spacing: -0.03em; }.th-section-intro p { color: var(--th-muted); font-size: 1.05rem; }
.th-feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }.th-feature-card { padding: 1.5rem; border: 1px solid var(--th-border); border-radius: 14px; background: var(--th-surface); }.th-feature-icon { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 10px; color: #fff; background: linear-gradient(135deg, var(--th-accent), #18a999); font-size: 1.4rem; }.th-feature-card h3 { margin-bottom: 0.5rem; }.th-feature-card p { color: var(--th-muted); line-height: 1.6; }
.th-landing-logo { display: block; width: 230px; height: auto; margin-bottom: 2rem; padding: 0.75rem 1rem; border-radius: 12px; background: #fff; }
.th-metric-grid { max-width: 1120px; margin: -2rem auto 5rem; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; position: relative; }
.th-metric { padding: 1.35rem 1.5rem; border: 1px solid var(--th-border); border-radius: 14px; background: var(--th-surface); box-shadow: 0 12px 30px rgba(26, 31, 38, 0.06); }.th-metric strong { display: block; font-size: 1.8rem; letter-spacing: -0.04em; }.th-metric span { color: var(--th-muted); font-size: 0.85rem; }
.th-flow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }.th-flow-step { padding: 1.5rem 0; border-top: 2px solid var(--th-accent); }.th-flow-step span { color: var(--th-accent); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; }.th-flow-step h3 { margin: 1.5rem 0 0.5rem; }.th-flow-step p { color: var(--th-muted); line-height: 1.6; }
.th-status-strip { max-width: 1120px; margin: 0 auto 4rem; padding: 2rem 2.25rem; display: flex; align-items: center; justify-content: space-between; gap: 2rem; border-radius: 16px; background: var(--th-surface-2); }.th-status-strip h2 { margin: 0.5rem 0; }.th-status-strip p { margin: 0; color: var(--th-muted); }

.th-card {
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}
@media (max-width: 800px) { .th-landing-hero { grid-template-columns: 1fr; gap: 2rem; padding: 2rem 1.5rem; }.th-metric-grid, .th-feature-grid, .th-flow-grid { grid-template-columns: repeat(2, 1fr); }.th-status-strip { align-items: flex-start; flex-direction: column; } }
@media (max-width: 520px) { .th-metric-grid, .th-feature-grid, .th-flow-grid { grid-template-columns: 1fr; margin-left: 0.5rem; margin-right: 0.5rem; }.th-landing-hero { margin: 0.5rem auto 3rem; }.th-main { padding: 0.75rem; } }

.th-grid { display: grid; gap: 1rem; }
.th-grid-2 { grid-template-columns: repeat(2, 1fr); }
.th-grid-3 { grid-template-columns: repeat(3, 1fr); }

.th-form { width: 100%; margin: 0; }
.th-form-narrow { max-width: 560px; }
.th-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.th-form .th-field { display: flex; flex-direction: column; gap: 0.35rem; }
.th-form label { color: var(--th-muted); font-size: 0.85rem; }
.th-login-page { max-width: 440px; margin: 3rem auto 0; }
.th-login-logo { display: block; width: 220px; height: auto; margin: 0 auto 1.5rem; }
.th-login-intro { color: var(--th-muted); text-align: center; margin: -0.75rem 0 1.75rem; }
.th-login-page h1, .th-login-page h2 { text-align: center; }
.th-form input, .th-form select, .th-form textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--th-border);
    background: var(--th-surface-2);
    color: var(--th-text);
}
.th-password-input { position: relative; display: flex; align-items: stretch; }
.th-password-input input { padding-right: 4.5rem; }
.th-password-toggle {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.3rem 0.55rem;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--th-accent);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}
.th-password-toggle:hover { background: var(--th-surface-2); }
.th-remember-row { display: flex; align-items: center; gap: 0.55rem; margin: 0.85rem 0 1rem; }
.th-remember-row input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--th-accent); }
.th-remember-row label { margin: 0; color: var(--th-muted); font-size: 0.85rem; cursor: pointer; }
.th-form-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; align-items: center; }
.th-order-card { max-width: 860px; margin: 0 auto; padding: 1.75rem; border-radius: 14px; box-shadow: 0 14px 40px rgba(26, 31, 38, 0.07); }
.th-order-ticket-heading { margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--th-border); }
.th-order-ticket-heading h2 { margin: 0.35rem 0; font-size: 1.5rem; }
.th-order-ticket-heading p { margin: 0; }
.th-order-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 1.5rem; }
.th-order-form .th-validation:first-child { grid-column: 1 / -1; }
.th-order-form .th-field { display: flex; flex-direction: column; gap: 0.35rem; }
.th-order-form .th-field > label { color: var(--th-text); font-size: 0.9rem; font-weight: 650; }
.th-order-form .th-field select, .th-order-form .th-field input:not([type="radio"]) { width: 100%; min-height: 2.9rem; padding: 0.7rem 0.8rem; border: 1px solid var(--th-border); border-radius: 8px; background: var(--th-surface); }
.th-order-form .th-field select:focus, .th-order-form .th-field input:focus { outline: 2px solid rgba(47, 129, 247, 0.2); border-color: var(--th-accent); }
.th-order-field-wide { grid-column: 1 / -1; }
.th-order-form .th-order-side-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.th-order-form .th-side-button { justify-content: center; min-height: 3.1rem; border-width: 2px; font-size: 1rem; }
.th-order-form .th-side-button input { width: auto; margin: 0; accent-color: currentColor; }
.th-order-form .th-form-actions { grid-column: 1 / -1; }
.th-order-form .th-form-actions { justify-content: flex-end; margin-top: 0.25rem; padding-top: 1.25rem; border-top: 1px solid var(--th-border); }
.th-checkbox-field { justify-content: flex-end; }
.th-checkbox-field label { display: flex; align-items: center; gap: 0.5rem; }
.th-checkbox-field input { width: auto; }
.th-active-field { display: flex; align-items: end; }
.th-checkbox-label { display: inline-flex; align-items: center; gap: 0.65rem; min-height: 2.75rem; padding: 0.65rem 0.85rem; border: 1px solid var(--th-border); border-radius: 0.5rem; background: var(--th-surface); color: var(--th-text); cursor: pointer; }
.th-checkbox-label input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--th-primary); }
.th-money-input { text-align: right; font-variant-numeric: tabular-nums; }
.th-danger-link { color: var(--th-down); }
.th-validation { color: var(--th-down); font-size: 0.85rem; }

.th-page-heading, .th-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.th-page-heading { margin-bottom: 1.5rem; }
.th-page-heading h1 { margin-bottom: 0.35rem; }
.th-section { margin-top: 2rem; }
.th-section > h2 { margin-bottom: 0.75rem; }
.th-broker-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1rem; }
.th-broker-card h3 { margin: 0; }
.th-broker-card h4 { margin: 1.25rem 0 0.5rem; color: var(--th-muted); }
.th-badge, .th-status-active, .th-status-inactive { font-size: 0.78rem; border-radius: 999px; padding: 0.25rem 0.55rem; white-space: nowrap; }
.th-badge, .th-status-active { background: #e3f5eb; color: var(--th-up); }
.th-status-inactive { background: #fbe6e7; color: var(--th-down); }
.th-user-list { display: grid; gap: 0.5rem; }
.th-user-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.65rem 0; border-bottom: 1px solid var(--th-border); }
.th-user-row > div:first-child, .th-account-row > div:first-child { display: flex; flex-direction: column; gap: 0.15rem; }
.th-user-status { display: flex; align-items: center; gap: 0.5rem; }
.th-user-status form { display: inline; margin: 0; }
.th-account-row { padding: 0.75rem; margin-top: 0.5rem; border: 1px solid var(--th-border); border-radius: 6px; background: var(--th-surface-2); }
.th-account-row .th-user-list { margin-top: 0.5rem; }
.th-alert { padding: 0.75rem 1rem; margin-bottom: 1rem; border: 1px solid #f0c36d; border-radius: 6px; background: #fff8e5; color: #6a4b00; }
.th-actions { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.th-view-toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.th-view-toolbar label { color: var(--th-muted); font-size: 0.85rem; }
.th-view-toolbar input, .th-view-toolbar select { min-width: 150px; padding: 0.5rem 0.7rem; border: 1px solid var(--th-border); border-radius: 6px; background: var(--th-surface-2); color: var(--th-text); }
.th-view-workspace { display: grid; gap: 1rem; }
.th-workspace-tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--th-border); }
.th-workspace-tab { display: inline-flex; align-items: center; padding: 0.65rem 0.9rem; border: 1px solid var(--th-border); border-bottom: 0; border-radius: 8px 8px 0 0; color: var(--th-muted); background: var(--th-surface-2); cursor: pointer; }
.th-workspace-tab.active { color: var(--th-text); background: var(--th-surface); border-top: 2px solid var(--th-accent); }
.th-new-tab-form { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; padding-bottom: 0.35rem; }
.th-new-tab-form input, .th-watchlist-add select, .th-inline-filter input, .th-inline-filter select { min-width: 180px; padding: 0.5rem 0.7rem; border: 1px solid var(--th-border); border-radius: 6px; background: var(--th-surface); color: var(--th-text); }
.th-watchlist-add { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem; }
.th-watchlist-add select { flex: 1; }
.th-inline-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.th-inline-filter label { color: var(--th-muted); }
.th-table-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; }
.th-table-actions form { margin: 0; }
.th-filter-row input { width: 100%; min-width: 72px; padding: 0.35rem; border: 1px solid var(--th-border); border-radius: 4px; }
.th-interactive-table thead tr:last-child th[draggable="true"] { cursor: grab; user-select: none; }
.th-interactive-table thead tr:last-child th[draggable="true"]:active { cursor: grabbing; }
.th-order-side-buttons { display: flex; gap: 0.6rem; }
.th-side-button { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.65rem 1rem; border: 1px solid var(--th-border); border-radius: 8px; cursor: pointer; font-weight: 700; }
.th-side-button input { width: auto; }
.th-side-buy:has(input:checked) { border-color: var(--th-up); color: var(--th-up); background: #e3f5eb; }
.th-side-sell:has(input:checked) { border-color: var(--th-down); color: var(--th-down); background: #fbe6e7; }
.th-stock-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 1.25rem; }
.th-stock-summary > div { display: flex; flex-direction: column; gap: 0.35rem; }
.th-stock-summary h2, .th-stock-summary p { margin: 0; }
.th-stock-summary strong { font-size: 1.05rem; }
.th-order-view { min-width: 0; }
.th-order-view h2 { margin-top: 0; }
.th-view-filters { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.th-view-filters label { display: flex; flex-direction: column; gap: 0.35rem; color: var(--th-muted); font-size: 0.85rem; }
.th-view-filters input, .th-view-filters select { min-width: 150px; padding: 0.5rem 0.7rem; border: 1px solid var(--th-border); border-radius: 6px; background: var(--th-surface-2); color: var(--th-text); }
.th-order-view-table th[data-sort] { cursor: pointer; }
.th-order-view-table th[data-sort]:hover { color: var(--th-accent); }
.th-order-view-table th[draggable="true"] { cursor: grab; user-select: none; }
.th-table-scroll { overflow-x: auto; }

.up { color: var(--th-up); }
.down { color: var(--th-down); }

.th-muted { color: var(--th-muted); font-size: 0.85rem; }

.th-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.th-table th, .th-table td {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--th-border);
}
.th-table th { color: var(--th-muted); font-weight: 600; }
.th-table tbody tr:hover { background: var(--th-surface-2); }

@media (max-width: 700px) {
    .th-header { flex-wrap: wrap; }
    .th-nav { order: 3; flex-basis: 100%; flex-wrap: wrap; }
    .th-page-heading, .th-card-heading, .th-user-row { flex-direction: column; }
    .th-user-status { align-self: stretch; justify-content: space-between; }
    .th-broker-grid { grid-template-columns: 1fr; }
    .th-order-form { grid-template-columns: 1fr; }
    .th-order-card { padding: 1.1rem; }
    .th-order-field-wide { grid-column: auto; }
    .th-order-form .th-form-actions { grid-column: auto; }
    .th-landing-hero { grid-template-columns: 1fr; margin: 0 -0.5rem 3rem; padding: 2.5rem 1.5rem; gap: 2rem; border-radius: 16px; }
    .th-feature-grid { grid-template-columns: 1fr; }
}

.th-error { max-width: 640px; margin: 4rem auto; text-align: center; }
