/**
 * View Shell - reusable layout primitives for edit/detail screens.
 *
 * Root scope: .view-shell.
 * All sub-classes are scoped under .view-shell to avoid collisions with
 * Bootstrap/MDB utilities (e.g. .panel, .stat, .hero, .icon-btn).
 *
 * Available building blocks:
 *   .util-bar, .crumbs          - secondary top bar with breadcrumbs
 *   .hero, .hero-grid           - page header with title + quick actions
 *   .status-pill[.ok|.warn|.danger|.info]
 *   .icon-btn[.danger]          - square icon-only action button
 *   .stat-strip, .stat-grid, .stat - KPI row under the hero
 *   .tab-bar, .tab-link, .tab-panel - sticky tab navigation + content
 *   .content, .panel, .panel-head, .panel-body - card/panel layout
 *   .two-col                    - label/value two-column rows inside panels
 *   .table-clean                - minimal table styling
 *   .badge-soft[.primary|.success|.warning|.danger|.info]
 *   .kv-inline                  - inline key-value list
 *   .sub-heading[.buy|.sell]    - section sub-title
 *   .hint-line[.warn|.danger]   - form helper text
 *   .empty                      - empty-state placeholder
 */

/* Collapse layout chrome above the view-shell (container-fluid mb-3) */
main > div.container-fluid:has(> .row > .col-12 > .view-shell) {
    margin-bottom: 0 !important;
    padding: 0;
}
main > div.container-fluid:has(> .row > .col-12 > .view-shell) > .row,
main > div.container-fluid:has(> .row > .col-12 > .view-shell) > .row > .col-12 {
    padding: 0;
    margin: 0;
}

/* Root shell */
.view-shell {
    --c-bg: #f7f8fa;
    --c-surface: #fff;
    --c-border: #e7eaef;
    --c-text: #1f2937;
    --c-text-mut: #6b7280;
    --c-text-soft: #9ca3af;
    --c-accent: #2563eb;
    --c-accent-soft: #eff6ff;
    --c-success: #16a34a;
    --c-warning: #ca8a04;
    --c-danger: #dc2626;
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    background: var(--c-bg);
    min-height: calc(100vh - 120px);
    border-radius: 0;
}

.view-shell .hero { border-radius: 0; }

.view-shell * { box-sizing: border-box; }

/* Utility bar */
.view-shell .util-bar {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: .5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .85rem;
}
.view-shell .util-bar .crumbs { color: var(--c-text-mut); }
.view-shell .util-bar .crumbs a { color: var(--c-text-mut); text-decoration: none; }
.view-shell .util-bar .crumbs a:hover { color: var(--c-text); }

/* Hero */
.view-shell .hero {
    background: #f0f0f0;
    border-bottom: 1px solid var(--c-border);
    padding: 1.25rem 1.5rem;
}
.view-shell .hero-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: center;
    max-width: 1500px;
    margin: 0 auto;
}
.view-shell .hero h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 .25rem 0;
    color: var(--c-text);
}
.view-shell .hero h1 .year { color: var(--c-text-soft); font-weight: 500; }
.view-shell .hero .meta {
    color: var(--c-text-mut);
    font-size: .85rem;
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}
.view-shell .hero .meta .item { display: inline-flex; align-items: center; gap: .4rem; }
.view-shell .hero .meta .item .k { color: var(--c-text-soft); }
.view-shell .hero .status {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
    flex-wrap: wrap;
}
.view-shell .status-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
    background: #f1f3f5;
    color: #374151;
}
.view-shell .status-pill.ok { background: #ecfdf5; color: #065f46; }
.view-shell .status-pill.warn { background: #fef9c3; color: #713f12; }
.view-shell .status-pill.danger { background: #fef2f2; color: #991b1b; }
.view-shell .status-pill.info { background: var(--c-accent-soft); color: #1d4ed8; }
.view-shell .status-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .7;
}

.view-shell .hero-actions { display: flex; gap: .5rem; align-items: center; }
.view-shell .icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: .5rem;
    background: transparent;
    border: 1px solid var(--c-border);
    color: var(--c-text-mut);
    cursor: pointer;
    text-decoration: none;
}
.view-shell .icon-btn:hover { background: #f1f3f5; color: var(--c-text); }
.view-shell .icon-btn.danger:hover { background: #fef2f2; color: var(--c-danger); border-color: #fecaca; }

/* Stat strip */
.view-shell .stat-strip {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: .75rem 1.5rem;
}
.view-shell .stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    max-width: 1500px;
    margin: 0 auto;
}
.view-shell .stat {
    padding: .5rem 1.25rem;
    border-right: 1px solid var(--c-border);
}
.view-shell .stat:last-child { border-right: none; }
.view-shell .stat.tone-warn { background: rgba(202, 138, 4, .13); }
.view-shell .stat.tone-dark-blue { background: rgba(30, 58, 138, .11); }
.view-shell .stat.tone-info { background: rgba(37, 99, 235, .11); }
.view-shell .stat.tone-success { background: rgba(22, 163, 74, .11); }
.view-shell .stat.tone-light { background: rgba(107, 114, 128, .11); }
.view-shell .stat .label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--c-text-soft);
    font-weight: 600;
}
.view-shell .stat .value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--c-text);
    margin-top: .15rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.view-shell .stat .value.warn { color: var(--c-warning); }
.view-shell .stat .value.danger { color: var(--c-danger); }
.view-shell .stat .value.success { color: var(--c-success); }
.view-shell .stat .action {
    font-size: .75rem;
    color: var(--c-accent);
    text-decoration: none;
    margin-top: .15rem;
    display: inline-block;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.view-shell .stat .action:hover { text-decoration: underline; }
.view-shell .stat .sub { font-size: .75rem; color: var(--c-text-soft); }

/* Tabs */
.view-shell .tab-bar {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 90;
}
.view-shell .tab-bar .wrap {
    max-width: 1500px;
    margin: 0 auto;
    display: flex;
    gap: .25rem;
    overflow-x: auto;
}
.view-shell .tab-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .85rem 1rem;
    color: var(--c-text-mut);
    font-weight: 500;
    font-size: .9rem;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.view-shell .tab-link:hover { color: var(--c-text); }
.view-shell .tab-link.active { color: var(--c-accent); border-bottom-color: var(--c-accent); }
.view-shell .tab-link .count {
    background: #f1f3f5;
    color: var(--c-text-mut);
    font-size: .7rem;
    padding: .05rem .4rem;
    border-radius: 999px;
    font-weight: 600;
}
.view-shell .tab-link.active .count { background: var(--c-accent-soft); color: var(--c-accent); }

/* Content */
.view-shell .content {
    max-width: 1500px;
    margin: 0 auto;
    padding: 1.5rem;
    background: var(--c-bg);
}
.view-shell .content-fullscreen {
    margin: 0 auto;
    padding: 1.5rem;
    background: var(--c-bg);
}
.view-shell .panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: .75rem;
    margin-bottom: 1.25rem;
}
.view-shell .panel-head {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--c-border);
    background: #fafbfc;
    border-top-left-radius: .75rem;
    border-top-right-radius: .75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}
.view-shell .panel-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--c-text);
}
.view-shell .panel-head .hint {
    color: var(--c-text-soft);
    font-size: .8rem;
    font-weight: 400;
    margin-left: .5rem;
}
.view-shell .panel-body { padding: 1.5rem; }
.view-shell .panel-body.no-pad { padding: 0; }

/* Form */
.view-shell .form-label {
    font-size: .8rem;
    font-weight: 500;
    color: #4b5563;
    margin-bottom: .4rem;
}
.view-shell .form-control,
.view-shell .form-select { font-size: .9rem; border-color: var(--c-border); }
.view-shell .form-control:focus,
.view-shell .form-select:focus {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.view-shell .form-control-sm, .view-shell .form-select-sm { font-size: .85rem; }
.view-shell .hint-line { font-size: .75rem; color: var(--c-text-soft); margin-top: .25rem; }
.view-shell .hint-line.warn { color: var(--c-warning); }
.view-shell .hint-line.danger { color: var(--c-danger); }

/* Two-column layout inside panels */
.view-shell .two-col {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 1rem 1.5rem;
    align-items: start;
    padding: 1rem 0;
    border-bottom: 1px solid var(--c-border);
}
.view-shell .two-col:first-child { padding-top: 0; }
.view-shell .two-col:last-child { padding-bottom: 0; border-bottom: none; }
.view-shell .two-col > .label {
    font-size: .85rem;
    color: var(--c-text-mut);
    font-weight: 500;
    padding-top: .5rem;
}
.view-shell .two-col > .label .sub {
    display: block;
    color: var(--c-text-soft);
    font-size: .75rem;
    font-weight: 400;
    margin-top: .15rem;
}

/* Tables */
.view-shell .table-clean { margin: 0; width: 100%; }
.view-shell .table-clean thead th {
    background: #f9fafb;
    color: var(--c-text-soft);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    border-bottom: 1px solid var(--c-border);
    padding: .75rem 1rem;
}
.view-shell .table-clean tbody td {
    padding: .85rem 1rem;
    border-top: 1px solid var(--c-border);
    font-size: .88rem;
    vertical-align: middle;
}
.view-shell .table-clean tbody tr:hover { background: #fafbfc; }
.view-shell .table-clean .actions {
    display: flex;
    gap: .25rem;
    justify-content: flex-end;
}
.view-shell .table-clean .icon-btn-sm { width: 28px; height: 28px; }

/* Badges */
.view-shell .badge-soft {
    background: #f1f3f5;
    color: var(--c-text-mut);
    font-weight: 500;
    padding: .25rem .5rem;
    border-radius: .35rem;
    font-size: .75rem;
    display: inline-block;
}
.view-shell .badge-soft.primary { background: var(--c-accent-soft); color: #1d4ed8; }
.view-shell .badge-soft.success { background: #ecfdf5; color: #065f46; }
.view-shell .badge-soft.warning { background: #fef9c3; color: #854d0e; }
.view-shell .badge-soft.danger { background: #fef2f2; color: #991b1b; }
.view-shell .badge-soft.info { background: #ecfeff; color: #155e75; }

/* Empty state */
.view-shell .empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--c-text-soft);
}
.view-shell .empty i { font-size: 2.5rem; opacity: .3; margin-bottom: .75rem; }
.view-shell .empty p { margin: 0; font-size: .9rem; }

/* Tab content */
.view-shell .tab-panel { display: none; }
.view-shell .tab-panel.active { display: block; }

/* Inline key-value */
.view-shell .kv-inline {
    display: flex;
    justify-content: space-between;
    padding: .5rem 0;
    border-bottom: 1px dashed var(--c-border);
    font-size: .85rem;
}
.view-shell .kv-inline:last-child { border-bottom: none; }
.view-shell .kv-inline .k { color: var(--c-text-mut); }
.view-shell .kv-inline .v { font-weight: 600; color: var(--c-text); }

/* Sub-heading (e.g. Buy / Sell sections) */
.view-shell .sub-heading {
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: .75rem;
}
.view-shell .sub-heading.buy { color: var(--c-success); }
.view-shell .sub-heading.sell { color: var(--c-danger); }

@media (max-width: 992px) {
    .view-shell .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .view-shell .stat { border-right: none; border-bottom: 1px solid var(--c-border); }
    .view-shell .hero-grid { grid-template-columns: 1fr; }
    .view-shell .two-col { grid-template-columns: 1fr; gap: .5rem; }
    .view-shell .two-col > .label { padding-top: 0; }
}
