/* TidalWaveAxis — Core Theme
   Ocean/tidal palette. Default: dark mode.
   Toggle via <html class="dark-mode"> / twaTheme.toggle()
*/

/* ── Variables ──────────────────────────────────────────────────────── */
:root {
    /* Light mode */
    --bg-page:          #f7fafc;
    --bg-card:          #ffffff;
    --bg-sidebar:       #0d1b2e;
    --text-main:        #0f1b2d;
    --text-muted:       #64748b;
    --text-sidebar:     rgba(255,255,255,0.72);
    --text-sidebar-hi:  #ffffff;

    --accent-tide:      #0ea5b7;
    --accent-deep:      #1e5aa8;
    --accent-tide-dim:  rgba(14,165,183,0.15);

    --status-ok:        #22c55e;
    --status-warn:      #f59e0b;
    --status-err:       #ef4444;

    --shadow:           0 4px 20px rgba(0,0,0,0.08);
    --shadow-card:      0 2px 10px rgba(0,0,0,0.06);
    --transition:       all 0.25s ease;
    --border-color:     #e2e8f0;
    --border-radius:    8px;

    /* Typography */
    --font-display:     'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body:        'Albert Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    /* Motion system (Impeccable-derived: 3 easings, no bounce/elastic) */
    --ease-out-quart:   cubic-bezier(0.25, 1, 0.5, 1);
    --ease-out-quint:   cubic-bezier(0.22, 1, 0.36, 1);
    --ease-out-expo:    cubic-bezier(0.16, 1, 0.3, 1);

    /* Sidebar always dark */
    --sidebar-bg:       #0d1b2e;
    --sidebar-border:   rgba(255,255,255,0.07);
    --sidebar-active:   rgba(14,165,183,0.18);
    --sidebar-width:    240px;

    /* Topbar */
    --topbar-bg:        var(--bg-card);
    --topbar-border:    var(--border-color);
    --topbar-height:    56px;

    /* Form controls (2026-07-24 beautify) — native widgets (date pickers, select lists,
       scrollbars) follow the theme via color-scheme */
    color-scheme:       light;
    --ctl-border-hover: #b3c1d6;
    --ctl-chevron:      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

:root.dark-mode {
    --bg-page:          #0a1220;
    --bg-card:          #101b2d;
    --text-main:        #e8f0f8;
    --text-muted:       #8ba3c0;
    --border-color:     rgba(255,255,255,0.08);
    --shadow:           0 4px 20px rgba(0,0,0,0.35);
    --shadow-card:      0 2px 10px rgba(0,0,0,0.25);
    --topbar-bg:        #101b2d;
    --topbar-border:    rgba(255,255,255,0.08);
    color-scheme:       dark;
    --ctl-border-hover: rgba(255,255,255,0.22);
    --ctl-chevron:      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%238ba3c0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ── Lion Bytes market overrides (data-market="lb" on <html>) ────────── */
[data-market="lb"] {
    --accent-tide:      #007CFB;
    --accent-deep:      #031246;
    --accent-tide-dim:  rgba(0,124,251,0.15);
    --sidebar-bg:       #031246;
    --bg-sidebar:       #031246;
    --sidebar-active:   rgba(0,124,251,0.18);
}

[data-market="lb"] .twa-login-bg {
    background: linear-gradient(145deg, #020e35 0%, #031246 45%, #3a4268 100%);
}

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

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background-color: var(--bg-page);
    color: var(--text-main);
    transition: background-color 0.25s, color 0.25s;
}

a {
    color: var(--accent-tide);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Form controls (global, 2026-07-24) ──────────────────────────────────
   House look for EVERY bare input/select/textarea (Perfil, Soporte, QC notes,
   Calls, …) — pages no longer need a .twa-form wrapper to look right. Inputs
   sit slightly inset (page bg on card bg), one radius, accent focus ring.
   Scoped blocks (.twa-form, .twa-filter-bar, .twa-login-card) only override
   spacing — the visual language lives here. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="tel"],
input[type="url"],
input:not([type]),
select,
textarea {
    background-color: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    padding: 8px 12px;
    transition: border-color 0.15s var(--ease-out-quart),
                box-shadow   0.15s var(--ease-out-quart),
                background-color 0.15s var(--ease-out-quart);
}

input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
    border-color: var(--ctl-border-hover);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-tide);
    box-shadow: 0 0 0 3px var(--accent-tide-dim);
    background-color: var(--bg-card);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.75;
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--ctl-chevron);
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

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

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent-tide);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

input[type="file"] {
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type="file"]::file-selector-button {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 12px;
    margin-right: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

input[type="file"]::file-selector-button:hover {
    border-color: var(--accent-tide);
    color: var(--accent-tide);
}

/* ── Dashboard shell ─────────────────────────────────────────────────── */
.twa-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.twa-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--text-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: var(--transition);
}

.twa-sidebar-brand {
    padding: 18px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-tide);
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--sidebar-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.twa-sidebar-section {
    padding: 18px 20px 6px;
    font-size: 0.65rem;
    font-weight: 800;
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.twa-sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    flex: 1;
}

.twa-sidebar-nav li {
    margin: 0;
}

.twa-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
}

.twa-sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-sidebar-hi);
    text-decoration: none;
}

/* notification bubble on a sidebar item (e.g. open support tickets) — hidden when count is 0 */
.twa-nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--status-err);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
}

.twa-sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--text-sidebar-hi);
    border-left-color: var(--accent-tide);
}

.twa-sidebar-placeholder {
    padding: 8px 20px;
    color: rgba(255,255,255,0.25);
    font-size: 0.8rem;
    font-style: italic;
}

/* ── Content area ────────────────────────────────────────────────────── */
.twa-content-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────────────────── */
.twa-topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 90;
    transition: var(--transition);
}

.twa-topbar-user {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-right: auto;
}

.twa-topbar a {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.twa-topbar a:hover {
    color: var(--text-main);
    text-decoration: none;
}

/* ── Main content ────────────────────────────────────────────────────── */
.twa-content {
    flex: 1;
    padding: 28px 32px;
}

.twa-content h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 24px;
    color: var(--text-main);
}

/* ── Stat tiles ──────────────────────────────────────────────────────── */
.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-tile {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.stat-tile-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-tile-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-tile-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Public nav ──────────────────────────────────────────────────────── */
.twa-public-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 32px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.twa-public-brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-tide);
    letter-spacing: 0.02em;
}

.twa-nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.twa-nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
    transition: var(--transition);
}

.twa-nav-link:hover {
    color: var(--accent-tide);
    text-decoration: none;
}

/* ── Public footer ───────────────────────────────────────────────────── */
.twa-public-footer {
    padding: 24px 32px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    transition: var(--transition);
}

/* ── Login page ──────────────────────────────────────────────────────── */
.twa-login-bg {
    min-height: calc(100vh - 60px - 73px);
    background: linear-gradient(145deg, #061424 0%, #0a2040 45%, #0e3060 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}

.twa-login-card {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 40px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.twa-login-card h2 {
    margin: 0 0 4px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-tide);
}

.twa-login-card p {
    margin: 0 0 28px;
    color: rgba(255,255,255,0.55);
    font-size: 0.875rem;
}

.twa-login-card label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.65);
    margin-bottom: 6px;
    letter-spacing: 0.03em;
}

.twa-login-card input[type="email"],
.twa-login-card input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #ffffff;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    margin-bottom: 18px;
}

.twa-login-card input:focus {
    outline: none;
    border-color: var(--accent-tide);
}

.twa-login-card input::placeholder {
    color: rgba(255,255,255,0.3);
}

/* alert text colors: dark tones for light mode (QC 2026-07-23: pale-on-pale was unreadable),
   the original pale tones restored under .dark-mode */
.twa-alert-error {
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.4);
    border-radius: 6px;
    padding: 10px 14px;
    color: #b91c1c;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.twa-alert-ok {
    background: rgba(34,197,94,0.15);
    border: 1px solid rgba(34,197,94,0.4);
    border-radius: 6px;
    padding: 10px 14px;
    color: #15803d;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

:root.dark-mode .twa-alert-error { color: #fca5a5; }
:root.dark-mode .twa-alert-ok    { color: #86efac; }
:root.dark-mode .twa-alert-warn  { color: #fde68a; }

.twa-alert-warn {
    background: rgba(234,179,8,0.15);
    border: 1px solid rgba(234,179,8,0.4);
    border-radius: 6px;
    padding: 10px 14px;
    color: #a16207;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.twa-module-gate-suspended,
.twa-module-gate-missing {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    margin: 16px 0;
}

.twa-module-gate-suspended {
    border-color: rgba(245,158,11,0.4);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-tide {
    display: inline-block;
    background: var(--accent-tide);
    color: #ffffff;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, opacity 0.2s;
}

.btn-tide:hover {
    background: #0c94a6;
    color: #ffffff;
    text-decoration: none;
}

.btn-tide-full {
    width: 100%;
    text-align: center;
    padding: 11px 24px;
}

/* ── Theme toggle ────────────────────────────────────────────────────── */
.btn-theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px 8px;
    transition: var(--transition);
}

.btn-theme-toggle:hover {
    color: var(--text-main);
    border-color: var(--accent-tide);
}

/* ── Public landing ──────────────────────────────────────────────────── */
.twa-hero {
    padding: 80px 32px;
    text-align: center;
    background: linear-gradient(160deg, #061424 0%, #0e3060 100%);
    color: #ffffff;
}

.twa-hero h1 {
    font-size: 2.4rem;
    font-weight: 800;
    margin: 0 0 16px;
    color: #ffffff;
}

.twa-hero p {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.65);
    max-width: 540px;
    margin: 0 auto 32px;
}

/* ── Utility ─────────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-tide   { color: var(--accent-tide); }
.text-ok     { color: var(--status-ok); }
.text-warn   { color: var(--status-warn); }
.text-err    { color: var(--status-err); }

/* ── Admin toolbar ───────────────────────────────────────────────────── */
.twa-admin-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.twa-admin-toolbar h1 {
    margin: 0;
    flex: 1;
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.twa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.twa-table th,
.twa-table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.twa-table th {
    background: var(--bg-card);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    white-space: nowrap;
}

.twa-table tbody tr:hover {
    background: var(--accent-tide-dim);
}

/* Sortable headers (SortTh component) */
.twa-th-sort {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s ease;
}
.twa-th-sort:hover,
.twa-th-sort.sorted {
    color: var(--accent-tide);
}
.twa-sort-ind {
    margin-left: 6px;
    font-size: 0.82em;
    opacity: 0.3;
}
.twa-th-sort:hover .twa-sort-ind {
    opacity: 0.75;
}
.twa-th-sort.sorted .twa-sort-ind {
    opacity: 1;
}

.twa-table tbody tr:last-child td {
    border-bottom: none;
}

.twa-table code {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--accent-tide);
}

:root.dark-mode .twa-table code {
    background: rgba(255,255,255,0.08);
}

.twa-table .actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-ok {
    background: rgba(34,197,94,0.15);
    color: #16a34a;
    border: 1px solid rgba(34,197,94,0.3);
}

:root.dark-mode .badge-ok {
    color: var(--status-ok);
}

.badge-warn {
    background: rgba(245,158,11,0.15);
    color: #b45309;
    border: 1px solid rgba(245,158,11,0.3);
}

:root.dark-mode .badge-warn {
    color: var(--status-warn);
}

.badge-err {
    background: rgba(239,68,68,0.15);
    color: #b91c1c;
    border: 1px solid rgba(239,68,68,0.3);
}

:root.dark-mode .badge-err {
    color: var(--status-err);
}

.badge-muted {
    background: rgba(100,116,139,0.12);
    color: var(--text-muted);
    border: 1px solid rgba(100,116,139,0.25);
}

/* ── Small buttons ───────────────────────────────────────────────────── */
.btn-sm {
    display: inline-block;
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 11px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-sm:hover {
    border-color: var(--accent-tide);
    color: var(--accent-tide);
    text-decoration: none;
}

.btn-sm-danger {
    border-color: rgba(239,68,68,0.5);
    color: var(--status-err);
}

.btn-sm-danger:hover {
    background: rgba(239,68,68,0.08);
    border-color: var(--status-err);
}

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

.btn-sm-primary:hover {
    background: #0c94a6;
    color: #fff;
    border-color: #0c94a6;
}

/* ── Admin forms ─────────────────────────────────────────────────────── */
.twa-form .form-group {
    margin-bottom: 16px;
}

.twa-form label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    letter-spacing: 0.02em;
}

.twa-form input[type="text"],
.twa-form input[type="email"],
.twa-form input[type="password"],
.twa-form input[type="number"],
.twa-form input[type="date"],
.twa-form input[type="datetime-local"],
.twa-form input[type="time"],
.twa-form input[type="tel"],
.twa-form input[type="url"],
.twa-form input:not([type]),
.twa-form select,
.twa-form textarea {
    width: 100%;
    padding: 9px 12px;
    margin: 0;
    background-color: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-main);
    font-size: 0.875rem;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.twa-form input:focus,
.twa-form select:focus,
.twa-form textarea:focus {
    outline: none;
    border-color: var(--accent-tide);
    box-shadow: 0 0 0 3px var(--accent-tide-dim);
}

.twa-form select {
    cursor: pointer;
    padding-right: 32px;   /* room for the global chevron */
}

.twa-form textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

.twa-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.twa-form-inline {
    display: flex;
    gap: 8px;
    align-items: center;
}

.twa-form-inline input {
    flex: 1;
}

/* ── Panel (slide-in from right) ─────────────────────────────────────── */
.twa-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 200;
    cursor: default;
}

.twa-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 460px;
    max-width: 100vw;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    z-index: 201;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: -6px 0 30px rgba(0,0,0,0.18);
}

.twa-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 1;
}

.twa-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.twa-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
}

.twa-panel-close:hover {
    color: var(--text-main);
}

.twa-panel-body {
    flex: 1;
    padding: 24px;
}

.twa-panel-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ── Confirm dialog ──────────────────────────────────────────────────── */
.twa-confirm {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 28px 32px;
    z-index: 202;
    min-width: 340px;
    max-width: 480px;
    width: 90vw;
    box-shadow: var(--shadow);
}

.twa-confirm p {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
}

.twa-confirm .twa-confirm-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 20px;
    font-weight: 400;
}

.twa-confirm-actions {
    display: flex;
    gap: 10px;
}

/* ── Filter bar ──────────────────────────────────────────────────────── */
.twa-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-card);
}

.twa-filter-bar .fg {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 130px;
    max-width: 220px;
}

.twa-filter-bar .fg label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.twa-filter-bar input,
.twa-filter-bar select {
    padding: 7px 10px;
    background-color: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-main);
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.twa-filter-bar select {
    padding-right: 30px;   /* room for the global chevron */
}

.twa-filter-bar input:focus,
.twa-filter-bar select:focus {
    outline: none;
    border-color: var(--accent-tide);
}

/* ── Pagination ──────────────────────────────────────────────────────── */
.twa-pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Section heading ─────────────────────────────────────────────────── */
.twa-section {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 32px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* ── Placeholder card ────────────────────────────────────────────────── */
.twa-placeholder-card {
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    background: var(--bg-card);
}

/* ── Profile card ────────────────────────────────────────────────────── */
.twa-profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px 28px;
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.twa-profile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.twa-profile-card-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.twa-profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.twa-profile-field label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 3px;
}

.twa-profile-field span {
    font-size: 0.9rem;
    color: var(--text-main);
}

/* ── Status actions ──────────────────────────────────────────────────── */
.twa-status-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.twa-empty {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ── Module store cards ──────────────────────────────────────────────── */
.module-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
}

.module-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.module-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    flex: 1;
    line-height: 1.5;
}

.module-card-price {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 4px;
}

.module-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.badge-info {
    background: rgba(14,165,183,0.12);
    color: var(--accent-tide);
    border: 1px solid rgba(14,165,183,0.3);
}

/* ── BACKLOG C2 — customer panel: content + LB ads rail ──────────────── */
.lb-panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 28px;
    align-items: start;
}

.lb-panel-main { min-width: 0; }   /* lets wide tables scroll instead of blowing out the grid */

.lb-adrail {
    position: sticky;
    top: calc(var(--topbar-height) + 20px);
    display: grid;
    gap: 14px;
}

.lb-ad {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.lb-ad:hover { border-color: var(--ctl-border-hover); }
.lb-ad-tide  { border-left-color: var(--accent-tide); }
.lb-ad-deep  { border-left-color: var(--accent-deep); }
.lb-ad-plain { border-left-color: var(--text-muted); }

.lb-ad-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
}

.lb-ad-emoji { margin-right: 6px; }

.lb-ad-body {
    margin: 8px 0 0;
    font-size: 0.84rem;
    line-height: 1.55;
    color: var(--text-muted);
}

.lb-ad-cta {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--accent-tide);
    text-decoration: none;
}

.lb-ad-cta:hover { text-decoration: underline; }

/* Below this width the rail drops under the content — it must never squeeze the panel itself. */
@media (max-width: 1180px) {
    .lb-panel-grid { grid-template-columns: minmax(0, 1fr); }
    .lb-adrail {
        position: static;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        margin-top: 8px;
    }
}

/* ── BACKLOG B3/B4 — customer guide + interactive tour ───────────────── */
.lb-guide-intro { max-width: 68ch; line-height: 1.7; margin: 0 0 24px; }

.lb-guide-toc {
    margin: 0 0 32px 20px;
    padding: 0;
    columns: 2;
    column-gap: 32px;
    line-height: 1.9;
}

.lb-guide-toc a { color: var(--accent-tide); text-decoration: none; }
.lb-guide-toc a:hover { text-decoration: underline; }

.lb-guide-step {
    max-width: 74ch;
    padding: 0 0 28px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border-color);
}

.lb-guide-step:last-of-type { border-bottom: 0; }

.lb-guide-step h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 10px;
}

.lb-guide-icon { margin-right: 8px; }
.lb-guide-step p { color: var(--text-muted); line-height: 1.7; margin: 0 0 12px; }

.lb-guide-bullets {
    margin: 0 0 12px 20px;
    padding: 0;
    color: var(--text-muted);
    line-height: 1.75;
}

.lb-guide-bullets li { margin-bottom: 6px; }

.lb-guide-tip {
    background: rgba(14,165,183,0.08);
    border-left: 3px solid var(--accent-tide);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    padding: 10px 14px;
    font-size: 0.9rem;
}

.lb-guide-shot,
.lb-tour-shot img {
    display: block;
    width: 100%;
    max-width: 720px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    margin: 4px 0 16px;
}

.lb-guide-goto a { font-weight: 600; color: var(--accent-tide); text-decoration: none; }
.lb-guide-foot { max-width: 68ch; color: var(--text-muted); font-size: 0.9rem; line-height: 1.7; }

/* B4 — the step-by-step tour */
.lb-tour { max-width: 780px; }

.lb-tour-progress { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }

.lb-tour-dot {
    width: 26px; height: 6px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.lb-tour-dot.is-done { background: rgba(14,165,183,0.45); }
.lb-tour-dot.is-on   { background: var(--accent-tide); }

.lb-tour-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    padding: 24px;
}

.lb-tour-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.lb-tour-icon { font-size: 1.7rem; line-height: 1; }
.lb-tour-count { font-size: 0.78rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }

.lb-tour-head h2 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2px 0 0;
    color: var(--text-main);
}

.lb-tour-intro { color: var(--text-muted); line-height: 1.7; margin: 0 0 14px; }
.lb-tour-shot { display: block; }
.lb-tour-nav { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 18px; }

/* B3 — print / save-as-PDF: only the guide body, no shell, no ads rail. */
@media print {
    .twa-sidebar, .twa-topbar, .lb-adrail, .lb-guide-toolbar, .twa-alert-error { display: none !important; }
    .twa-content-area { margin-left: 0 !important; }
    .twa-content { padding: 0 !important; }
    .lb-panel-grid { display: block !important; }
    .lb-guide-step { break-inside: avoid; page-break-inside: avoid; border-bottom: 0; }
    .lb-guide-shot { max-width: 100%; box-shadow: none; }
    .lb-guide-toc { columns: 1; }
    a[href]::after { content: ""; }
}
