/* FinTrack — shared site styles */

:root {
    color-scheme: light;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bg: #eef2f1;
    --bg-accent: #e4ecea;
    --panel: #ffffff;
    --panel-soft: #f3f7f6;
    --ink: #14201d;
    --muted: #5f6d69;
    --line: #d5dedb;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --accent-soft: #d9f0ec;
    --danger: #b42318;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(20, 32, 29, .05);
    --shadow-md: 0 8px 24px rgba(20, 32, 29, .08);
    --shell-pad: 20px;
    --focus-ring: 2px solid rgba(15, 118, 110, .2);
    --hover-line: #9ec7c1;
    --label: #2a3d38;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    padding-inline: var(--shell-pad);
    background: linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 180px, var(--bg) 100%);
    color: var(--ink);
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h2 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.muted {
    color: var(--muted);
}

.link {
    color: var(--accent-dark);
    font-weight: 700;
}

.shell {
    width: min(1080px, 100%);
    margin: 0 auto;
}

.stack {
    display: grid;
    gap: 12px;
}

.inline-form {
    margin: 0;
    display: inline-flex;
}

.actions,
.toolbar-actions,
.form-action-buttons,
.note-actions,
.trade-compact-actions,
.rich-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.actions,
.toolbar-actions,
.form-action-buttons {
    gap: 8px;
}

.note-actions,
.rich-toolbar {
    gap: 6px;
}

.trade-compact-actions {
    gap: 4px;
}

.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block;
}

/* —— Topbar —— */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    margin-inline: calc(0px - var(--shell-pad));
    padding-inline: var(--shell-pad);
    padding-top: env(safe-area-inset-top, 0px);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(10px);
}

.topbar-inner {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--accent-dark);
    letter-spacing: -.02em;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: 24px;
    flex-shrink: 0;
}

.topbar-nav a {
    color: var(--muted);
    font-size: .88rem;
    font-weight: 600;
}

.topbar-nav a:hover,
.topbar-nav a.is-active {
    color: var(--ink);
}

.topbar .actions {
    gap: 10px;
}

.topbar .muted {
    font-size: .88rem;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-search {
    flex: 1 1 180px;
    min-width: 0;
    max-width: 320px;
    margin-left: auto;
}

.topbar-search input {
    width: 100%;
    min-height: 36px;
    margin: 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    font-size: .86rem;
}

.topbar-search input::-webkit-search-decoration,
.topbar-search input::-webkit-search-cancel-button {
    -webkit-appearance: searchfield-cancel-button;
}

/* —— Page chrome —— */

.page {
    padding-block: 20px 48px;
    padding-bottom: max(48px, calc(24px + env(safe-area-inset-bottom, 0px)));
}

.page-intro {
    margin-bottom: 18px;
}

.page-title {
    margin: 0 0 4px;
    font-size: clamp(1.5rem, 4vw, 1.85rem);
    line-height: 1.15;
    letter-spacing: -.02em;
}

.page-subtitle {
    margin: 0;
    font-size: .92rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 8px 0 0;
    font-size: clamp(1.4rem, 4vw, 1.75rem);
}

.back-link {
    display: inline-block;
    margin-bottom: 10px;
    font-size: .88rem;
}

.compact-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: stretch;
    justify-content: space-between;
    margin-bottom: 12px;
}

.eyebrow,
.hero-stat-label,
.form-action-date-label {
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.eyebrow {
    font-size: .75rem;
    letter-spacing: .05em;
}

.hero-stat-label {
    font-size: .64rem;
}

.form-action-date-label {
    color: var(--accent-dark);
    font-size: .72rem;
    letter-spacing: .08em;
    white-space: nowrap;
}

.panel-title {
    margin-bottom: 14px;
    font-size: 1rem;
}

.panel,
.card,
.instrument-card,
.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.panel {
    padding: 18px;
}

.card {
    padding: 14px 16px;
}

.empty-state {
    display: grid;
    gap: 12px;
    text-align: center;
}

.empty-state .btn {
    justify-self: center;
}

.note-card {
    background: #fff9ed;
    border-color: #edd9a8;
}

.trade-card {
    background: #f4f5f4;
    border-color: #dde0dd;
}

.exchange-update-timeline-card {
    background: #fafbfb;
    border-color: #eceeed;
}

.exchange-update-card {
    background: #f7f9fc;
    border-color: #d8e0ea;
}

/* —— Sort chips & instrument cards —— */

.sort-chips {
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.sort-chips::-webkit-scrollbar {
    display: none;
}

.sort-chip,
.type-badge,
.trade-type,
.exchange-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
}

.sort-chip {
    flex: 0 0 auto;
    padding: 7px 12px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: .78rem;
}

.sort-chip.is-active {
    border-color: var(--hover-line);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.instrument-cards {
    gap: 10px;
}

.instrument-card {
    display: block;
    padding: 14px;
    transition: border-color .15s, box-shadow .15s;
}

.instrument-card:active {
    border-color: var(--hover-line);
    box-shadow: var(--shadow-md);
}

.instrument-card-head,
.trade-compact-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.instrument-card-head {
    margin-bottom: 8px;
}

.instrument-card-title,
.instrument-card-price {
    display: grid;
    gap: 2px;
}

.instrument-card-title {
    min-width: 0;
}

.instrument-card-title strong,
.instrument-card-price-value {
    font-size: .95rem;
}

.instrument-card-title strong {
    line-height: 1.3;
}

.instrument-card-title .muted {
    font-size: .78rem;
}

.instrument-card-price {
    justify-items: end;
    gap: 1px;
    flex-shrink: 0;
}

.instrument-card-price-value {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--accent-dark);
    white-space: nowrap;
}

.instrument-card-price .price-source {
    font-size: .62rem;
}

.instrument-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
    color: var(--muted);
    font-size: .72rem;
    line-height: 1.35;
}

.instrument-card-meta .type-badge {
    font-size: .62rem;
}

.instrument-card-xirr.is-positive {
    color: #1a6b4d;
    font-weight: 700;
}

.instrument-card-xirr.is-negative {
    color: #9b2c2c;
    font-weight: 700;
}

/* —— Instrument hero —— */

.instrument-hero {
    margin-bottom: 14px;
}

.instrument-hero-row,
.instrument-hero-metrics {
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: var(--panel);
}

.instrument-hero-row {
    display: flex;
    align-items: center;
    gap: 10px 16px;
    flex-wrap: wrap;
    border-bottom: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    box-shadow: var(--shadow-sm);
}

.instrument-hero-primary {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 10px;
    min-width: 0;
    flex: 1;
}

.instrument-title {
    margin: 0;
    font-size: clamp(1.1rem, 3.2vw, 1.45rem);
    line-height: 1.2;
    letter-spacing: -.02em;
    white-space: nowrap;
}

.instrument-meta {
    font-size: .76rem;
    font-weight: 600;
    color: var(--muted);
    line-height: 1.4;
}

.meta-divider {
    margin: 0 5px;
    opacity: .55;
}

.instrument-meta .price-source {
    margin-left: 4px;
    font-size: .62rem;
    text-transform: uppercase;
}

.instrument-meta .price-source::before {
    content: '(';
}

.instrument-meta .price-source::after {
    content: ')';
}

.instrument-hero-metrics {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 18px;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: linear-gradient(180deg, #f7faf9 0%, #f2f7f5 100%);
}

.hero-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    font-size: .84rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.instrument-hero-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.price-source {
    display: inline;
    margin-left: 2px;
    font-size: .62rem;
    font-weight: 600;
    color: var(--muted);
}

/* —— Timeline —— */

.timeline-section {
    gap: 8px;
}

.timeline-section .card {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}

.timeline-section .eyebrow {
    font-size: .68rem;
    margin-bottom: 4px;
}

.timeline-section .note-body {
    font-size: .88rem;
    line-height: 1.45;
}

.timeline-section .note-header {
    gap: 8px;
}

.timeline-section .icon-btn {
    width: 30px;
    height: 30px;
}

.timeline-section .icon-btn svg,
.icon-btn-sm svg {
    width: 14px;
    height: 14px;
}

.timeline-section .panel {
    padding: 14px;
}

.timeline-section .panel-title {
    margin-bottom: 10px;
    font-size: .92rem;
}

.timeline-heading {
    margin: 0 0 4px;
    font-size: .92rem;
    font-weight: 700;
    color: var(--ink);
}

.note-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--accent-dark);
    cursor: pointer;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--panel-soft);
    border-color: var(--hover-line);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.icon-btn-sm {
    width: 32px;
    height: 32px;
}

.icon-danger {
    color: var(--danger);
}

.icon-danger:hover {
    background: #fff4f4;
    border-color: #f1b8b2;
}

.trade-compact-meta,
.exchange-update-meta {
    color: var(--muted);
    font-size: .78rem;
}

.trade-compact-meta {
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.trade-type {
    display: inline-block;
    padding: 2px 8px;
    font-size: .72rem;
    text-transform: uppercase;
}

.trade-type-buy {
    background: #e3f3eb;
    color: #1a6b4d;
}

.trade-type-sell {
    background: #fdecec;
    color: #9b2c2c;
}

.trade-type-split,
.trade-type-bonus {
    background: #e9edff;
    color: #3f4f9f;
}

.trade-card-compact {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    box-shadow: none;
}

.trade-compact-row {
    align-items: center;
    gap: 8px;
    min-height: 28px;
}

.trade-compact-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    min-width: 0;
}

.trade-card-compact .trade-type {
    padding: 1px 7px;
    font-size: .66rem;
}

.trade-card-compact .icon-btn-sm {
    width: 28px;
    height: 28px;
    min-height: 28px;
}

.trade-card-compact .icon-btn-sm svg {
    width: 13px;
    height: 13px;
}

/* —— Exchange updates —— */

.exchange-updates-feed {
    gap: 20px;
}

.exchange-updates-date {
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--ink);
}

.exchange-update-subject {
    margin: 0 0 6px;
    font-size: .95rem;
    line-height: 1.4;
}

.exchange-update-subject a,
.exchange-update-timeline-card .exchange-update-subject a {
    color: inherit;
}

.exchange-update-subject a:hover,
.exchange-update-timeline-card .exchange-update-subject a:hover {
    text-decoration: underline;
}

.exchange-update-headline {
    margin: 0 0 6px;
    font-size: .86rem;
    line-height: 1.45;
}

.exchange-update-timeline-card .exchange-update-subject {
    font-size: .88rem;
    line-height: 1.45;
}

.exchange-update-timeline-card .exchange-update-headline {
    margin: 6px 0 0;
    font-size: .82rem;
}

.exchange-update-meta {
    margin: 0;
}

.exchange-updates-meta {
    display: block;
    margin-top: 4px;
}

.exchange-updates-skipped {
    margin-bottom: 12px;
}

.exchange-badge {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 6px;
    font-size: .62rem;
    letter-spacing: .04em;
    vertical-align: middle;
}

.exchange-badge-bse {
    color: #7a4d00;
    background: #fff4df;
    border: 1px solid #edd9a8;
}

.exchange-badge-nse {
    color: #1f4f73;
    background: #eef4fb;
    border: 1px solid #d4e0ef;
}

/* —— Table —— */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.instrument-table {
    width: 100%;
    min-width: 700px;
    border-collapse: collapse;
    font-size: .84rem;
}

.instrument-table th,
.instrument-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    line-height: 1.3;
    white-space: nowrap;
}

.instrument-table th {
    background: var(--panel-soft);
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
}

.instrument-table th .sort-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: inherit;
    font: inherit;
    text-transform: inherit;
}

.instrument-table th .sort-link:hover,
.instrument-table th .sort-link.is-active {
    color: var(--accent-dark);
}

.instrument-table tbody tr:hover {
    background: #f7fbfb;
}

.instrument-table tbody tr:last-child td {
    border-bottom: 0;
}

.instrument-name-cell {
    position: relative;
    min-width: 160px;
}

.instrument-name {
    display: block;
    font-weight: 700;
    color: #243833;
}

.instrument-symbol {
    display: block;
    font-size: .74rem;
}

.row-link {
    position: absolute;
    inset: 0;
}

.sector-cell {
    color: var(--muted);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.type-badge {
    display: inline-block;
    padding: 2px 7px;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
}

.value-cell {
    font-weight: 700;
    color: var(--accent-dark);
}

.numeric {
    font-variant-numeric: tabular-nums;
    text-align: right !important;
}

/* —— Forms —— */

.form-page {
    width: min(640px, 100%);
}

.form-page.stack {
    gap: 14px;
}

.bulk-help {
    margin: 0 0 14px;
    font-size: .88rem;
    line-height: 1.5;
}

.form-grid,
.rich-note {
    display: grid;
    gap: 14px;
}

.rich-note {
    gap: 6px;
}

.split {
    display: grid;
    gap: 12px;
}

.split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label,
.rich-note-label {
    display: grid;
    gap: 6px;
    color: var(--label);
    font-size: .86rem;
    font-weight: 500;
}

input,
select,
textarea,
.rich-editor {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    padding: 11px 12px;
    font-weight: 400;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input:focus,
select:focus,
textarea:focus,
.rich-editor:focus,
.topbar-search input:focus,
.form-action-date input[type="date"]:focus {
    outline: var(--focus-ring);
    border-color: var(--accent);
}

.form-action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    padding: 12px 14px;
    border: 1px solid #cfe3df;
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, rgba(255, 255, 255, .72) 0%, rgba(217, 240, 236, .55) 100%);
}

.form-action-date {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    width: auto;
    min-width: 0;
}

.form-action-date input[type="date"] {
    width: auto;
    min-width: 9.75rem;
    min-height: 38px;
    padding: 7px 10px;
    border-color: #bfd9d4;
    font-size: .88rem;
    font-weight: 500;
    border-radius: 999px;
}

.form-action-buttons {
    margin-left: auto;
}

.btn-action,
.btn-action-ghost {
    min-height: 38px;
    border-radius: 999px;
}

.btn-action {
    padding: 8px 18px;
    background: linear-gradient(180deg, #14968c 0%, var(--accent) 100%);
    border-color: transparent;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 14px rgba(15, 118, 110, .22);
    letter-spacing: .01em;
}

.btn-action:hover {
    background: linear-gradient(180deg, #0f8179 0%, var(--accent-dark) 100%);
}

.btn-action-ghost {
    padding: 8px 14px;
    background: rgba(255, 255, 255, .7);
    border-color: #bfd9d4;
    color: var(--accent-dark);
    font-weight: 600;
}

.btn-action-ghost:hover {
    background: #fff;
}

.captcha-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.captcha-question {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid #bfd9d4;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: 700;
    white-space: nowrap;
}

.captcha-input {
    max-width: 7rem;
}

.rich-toolbar-btn {
    min-height: 30px;
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font-size: .78rem;
    font-weight: 500;
    cursor: pointer;
}

.rich-toolbar-btn:hover {
    background: var(--panel-soft);
}

.rich-editor {
    min-height: 120px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.rich-editor:empty:before {
    content: attr(data-placeholder);
    color: var(--muted);
    pointer-events: none;
}

.note-body {
    font-weight: 400;
    white-space: normal;
    line-height: 1.55;
    font-size: .94rem;
}

.note-body p {
    margin: 0 0 .55em;
}

.note-body p:last-child {
    margin-bottom: 0;
}

.note-body ul,
.note-body ol {
    margin: .35em 0 .55em;
    padding-left: 1.2em;
}

/* —— Buttons —— */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: .88rem;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.btn-secondary:hover {
    background: var(--panel-soft);
}

.btn-note {
    background: #fbf3d8;
    border-color: #e8d9a0;
    color: #6b5a1e;
}

.btn-note:hover {
    background: #f6ebc4;
}

.btn-trade {
    background: #d9f0e8;
    border-color: #a9d9c8;
    color: #1a5c48;
}

.btn-trade:hover {
    background: #c7e8dc;
}

.btn-compact {
    min-height: 36px;
    padding: 6px 10px;
    font-size: .76rem;
}

.btn-danger {
    background: #fff;
    border-color: #f1b8b2;
    color: var(--danger);
}

/* —— Alerts & auth —— */

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: .9rem;
    border: 1px solid transparent;
}

.alert-success {
    background: #e8f6ee;
    color: #16653a;
    border-color: #c6e8d4;
}

.alert-error {
    background: #fff3f3;
    color: var(--danger);
    border-color: #f5cfcb;
}

.alert-info {
    background: #eef4fb;
    color: #2f4f73;
    border-color: #d4e0ef;
}

.auth-wrap {
    width: min(420px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    align-content: center;
    padding: 24px 0 40px;
}

.auth-wrap h1 {
    font-size: clamp(1.6rem, 5vw, 2rem);
    margin-bottom: 6px;
}

/* —— Modal —— */

.modal {
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    color: var(--ink);
    box-shadow: var(--shadow-md);
}

.modal::backdrop {
    background: rgba(20, 32, 29, .4);
}

.modal-confirm {
    width: min(400px, calc(100vw - 24px));
}

/* —— Responsive —— */

@media (max-width: 768px) {
    .form-action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .form-action-date {
        justify-content: space-between;
    }

    .form-action-date input[type="date"] {
        flex: 1;
        min-width: 0;
    }

    .form-action-buttons {
        margin-left: 0;
    }

    .form-action-buttons .btn {
        flex: 1;
    }

    .desktop-only {
        display: none !important;
    }

    .sort-chips.mobile-only {
        display: flex !important;
        margin-top: 0;
    }

    .instrument-cards.mobile-only {
        display: grid !important;
    }

    .page {
        padding-top: 18px;
        padding-bottom: max(40px, calc(20px + env(safe-area-inset-bottom, 0px)));
    }

    .compact-toolbar {
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 10px;
        margin-bottom: 10px;
    }

    .toolbar-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .toolbar-actions .btn {
        width: 100%;
    }

    .topbar-inner {
        flex-wrap: wrap;
    }

    .topbar-search {
        flex: 1 1 120px;
        max-width: none;
        order: 3;
        width: 100%;
        margin-left: 0;
    }

    .topbar-nav {
        margin-left: 12px;
    }

    .topbar .actions {
        order: 2;
        margin-left: auto;
    }

    .topbar .muted {
        display: none;
    }

    .split,
    .page-header {
        grid-template-columns: 1fr;
    }

    .instrument-hero-row {
        gap: 8px 12px;
    }

    .instrument-hero-primary {
        flex: 1 1 auto;
    }

    .instrument-title {
        white-space: normal;
    }

    .instrument-hero-metrics {
        gap: 12px 16px;
    }

    .instrument-hero-actions {
        margin-left: 0;
        justify-content: flex-start;
        width: 100%;
    }

    .instrument-hero-actions .btn-compact {
        flex: 1 1 auto;
    }

    .timeline-section .note-header {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .note-header {
        grid-template-columns: 1fr;
    }

    .note-actions {
        justify-content: flex-end;
    }

    .btn,
    .icon-btn {
        min-height: 44px;
    }

    .icon-btn {
        width: 44px;
        height: 44px;
    }

    .trade-card-compact .icon-btn,
    .trade-card-compact .icon-btn-sm {
        width: 32px;
        height: 32px;
        min-height: 32px;
    }

    .btn-compact {
        min-height: 40px;
    }
}

@media (min-width: 769px) {
    .toolbar-actions .btn {
        min-width: 0;
    }
}
