/* =====================================================================
 *  IDEAL Sales — Design System v5 (tablet-first, CTC-grade polish)
 * ===================================================================== */

:root {
    --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    --sidebar-w: 272px;
    --topbar-h: 60px;
    --surface: #ffffff;
    --surface-2: #f6f6f8;
    --surface-border: rgba(24, 24, 28, 0.08);
    --glass: rgba(255, 255, 255, 0.82);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --radius-xl: 20px;
    --shadow-soft: 0 2px 8px rgba(10, 10, 12, 0.04), 0 8px 24px rgba(10, 10, 12, 0.06);
    --shadow-card: 0 1px 2px rgba(10, 10, 12, 0.05), 0 12px 40px rgba(10, 10, 12, 0.08);
    --shadow-lift: 0 16px 48px rgba(10, 10, 12, 0.12);
}

html { font-feature-settings: 'cv11', 'ss01'; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

body {
    background: var(--surface-2);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body.app-auth {
    padding-top: 0;
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
}

@media (min-width: 768px) {
    body.app-auth {
        padding-bottom: var(--safe-bottom);
    }
}

/* ---------- App shell (tablet sidebar) ---------- */
.app-shell {
    display: flex;
    min-height: 100dvh;
}

.app-sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 70;
    flex-direction: column;
    padding: calc(16px + var(--safe-top)) 14px calc(16px + var(--safe-bottom));
    background: linear-gradient(180deg, #0c0c0f 0%, #141418 50%, #0a0a0c 100%);
    border-right: 1px solid rgba(199, 154, 48, 0.22);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.2);
}

@media (min-width: 768px) {
    .app-sidebar {
        display: flex;
    }
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
}

.sidebar-brand strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
}

.sidebar-brand small {
    display: block;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sidebar-brand img {
    filter: drop-shadow(0 4px 12px rgba(199, 154, 48, 0.45));
}

.sidebar-section-label {
    margin: 20px 10px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    transition: background 0.18s var(--ease-out), color 0.18s, transform 0.18s;
    touch-action: manipulation;
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar-link.is-active {
    background: linear-gradient(135deg, rgba(199, 154, 48, 0.28), rgba(199, 154, 48, 0.12));
    color: var(--gold-200);
    box-shadow: inset 0 0 0 1px rgba(199, 154, 48, 0.35);
    border-left: 3px solid var(--gold-400);
    padding-left: 11px;
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: #fff;
    font-size: 0.88rem;
}

.sidebar-user .avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--gold-grad);
    display: grid;
    place-items: center;
    font-weight: 800;
    color: var(--ink-900);
}

.sidebar-user small {
    display: block;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.75rem;
}

.sidebar-logout {
    display: block;
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-logout:hover {
    background: rgba(200, 54, 74, 0.15);
    color: #ffb4bc;
    border-color: rgba(200, 54, 74, 0.35);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 12, 0.5);
    z-index: 65;
    backdrop-filter: blur(4px);
}

.sidebar-backdrop[hidden] {
    display: none !important;
}

@media (min-width: 768px) {
    .sidebar-backdrop {
        display: none !important;
    }
}

.app-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

@media (min-width: 768px) {
    .app-stage {
        margin-left: var(--sidebar-w);
    }
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) 16px 0 16px;
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--surface-border);
    box-shadow: var(--shadow-soft);
}

.topbar-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--ink-200);
    border-radius: 12px;
    background: #fff;
    color: var(--ink-800);
    cursor: pointer;
}

.topbar-menu svg {
    width: 22px;
    height: 22px;
}

@media (min-width: 768px) {
    .topbar-menu {
        display: none;
    }
}

.topbar-titles {
    flex: 1;
    min-width: 0;
}

.topbar-kicker {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold-600);
}

.topbar-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title:empty::before {
    content: 'IDEAL Sales';
}

.topbar-user .avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--gold-grad);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--ink-900);
}

@media (max-width: 767px) {
    .app-sidebar.is-open {
        display: flex;
    }
}

.shell {
    padding: 20px clamp(16px, 3vw, 32px) 32px;
    max-width: 1400px;
}

.app-footer--slim {
    margin-top: auto;
    padding: 14px 20px calc(14px + var(--safe-bottom));
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.78rem;
    background: transparent;
    border-top: 1px solid var(--surface-border);
    color: var(--ink-500);
}

.app-footer--slim a {
    color: var(--gold-600);
}

html.standalone .app-footer--slim {
    display: none;
}

/* Bottom nav: phone only */
@media (min-width: 768px) {
    .bottom-nav {
        display: none !important;
    }
}

/* ---------- Toasts ---------- */
.toast {
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-soft);
    animation: slideDown 0.35s var(--ease-out);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast-success {
    background: #e8f4ec;
    color: #1c4f2e;
    border-left: 4px solid var(--success);
}

.toast-error {
    background: #fbeaec;
    color: #6f1822;
    border-left: 4px solid var(--danger);
}

.toast-info {
    background: #eaf2fb;
    color: #1a3f6b;
    border-left: 4px solid var(--info);
}

/* ---------- Cards & stats ---------- */
.card--elevated {
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s var(--ease-out);
}

.card--elevated:hover {
    box-shadow: var(--shadow-lift);
}

.card-sub {
    margin: 4px 0 0;
    font-size: 0.85rem;
}

.card-body--flush {
    padding: 0 !important;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    padding: 18px 20px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.stat-card--gold {
    background: linear-gradient(135deg, #fff 0%, #fffaf0 100%);
    border-color: rgba(199, 154, 48, 0.25);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-500);
    margin-bottom: 6px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ink-900);
    font-variant-numeric: tabular-nums;
}

.stat-value--sm {
    font-size: 1.2rem;
}

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

.page-eyebrow {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 3vw, 1.85rem);
    font-weight: 800;
    color: var(--ink-900);
}

.page-sub {
    margin: 4px 0 0;
    color: var(--ink-500);
}

.mono {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--ink-700);
}

.btn-touch-row {
    min-width: 52px;
    min-height: 44px;
}

/* Tables v5 */
table.data thead th {
    background: var(--surface-2);
    color: var(--ink-700);
    font-size: 0.72rem;
    border-bottom: 1px solid var(--ink-200);
    box-shadow: none;
}

table.data tbody td {
    padding: 14px 16px;
}

@media (min-width: 768px) {
    .table-wrap.table-scroll-y {
        max-height: min(65vh, 560px);
    }
}

/* Buttons v5 */
.btn-primary {
    font-weight: 700;
    letter-spacing: 0.01em;
}

.btn-ghost-dark {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-ghost-dark:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.text-gradient {
    background: var(--gold-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Animations */
.animate-in {
    animation: fadeUp 0.55s var(--ease-out) both;
}

.animate-in.delay-1 {
    animation-delay: 0.08s;
}
.animate-in.delay-2 {
    animation-delay: 0.16s;
}
.animate-in.delay-3 {
    animation-delay: 0.24s;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Guest split (login) ---------- */
.guest-split {
    display: grid;
    min-height: 100dvh;
}

@media (min-width: 900px) {
    .guest-split {
        grid-template-columns: 1fr 1fr;
    }
}

.guest-split-brand {
    position: relative;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(28px, 5vw, 48px);
    background: var(--ink-900);
    color: #fff;
    overflow: hidden;
}

@media (min-width: 900px) {
    .guest-split-brand {
        display: flex;
    }
}

.guest-split-glow {
    position: absolute;
    width: 28rem;
    height: 28rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(199, 154, 48, 0.35), transparent 70%);
    top: -8rem;
    right: -6rem;
    filter: blur(40px);
    pointer-events: none;
}

.guest-split-glow::after {
    content: '';
    position: absolute;
    width: 22rem;
    height: 22rem;
    bottom: -14rem;
    left: -10rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(199, 154, 48, 0.2), transparent 70%);
}

.guest-split-logo {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: #fff;
}

.guest-split-logo strong {
    font-family: var(--font-display);
    font-size: 1.2rem;
}

.guest-split-logo small {
    display: block;
    font-size: 0.7rem;
    opacity: 0.55;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.guest-split-quote {
    position: relative;
    max-width: 28rem;
}

.guest-split-quote h2 {
    color: #fff;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    line-height: 1.15;
    margin-bottom: 12px;
}

.guest-split-quote p {
    color: rgba(255, 255, 255, 0.65);
    margin: 0;
}

.guest-split-metrics {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 360px;
}

.guest-split-metrics div {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 14px;
    backdrop-filter: blur(8px);
}

.guest-split-metrics strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.1rem;
}

.guest-split-metrics span {
    font-size: 0.72rem;
    opacity: 0.55;
}

.guest-split-copy {
    position: relative;
    font-size: 0.75rem;
    opacity: 0.4;
    margin: 0;
}

.guest-split-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px clamp(20px, 4vw, 48px);
    background: var(--surface-2);
}

.login-card-v5 {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: clamp(28px, 4vw, 36px);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--surface-border);
}

.login-card-v5 h1 {
    margin: 0 0 4px;
    font-size: 1.65rem;
}

/* ---------- Landing v5 ---------- */
.landing--v5 {
    position: relative;
    overflow: hidden;
    background: var(--surface-2);
}

.landing-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}

.landing-glow--1 {
    width: 40vw;
    height: 40vw;
    max-width: 480px;
    top: -10%;
    right: -5%;
    background: rgba(199, 154, 48, 0.18);
}

.landing-glow--2 {
    width: 30vw;
    height: 30vw;
    bottom: 20%;
    left: -8%;
    background: rgba(10, 10, 12, 0.06);
}

.landing-top--glass {
    background: var(--glass) !important;
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--surface-border) !important;
    position: sticky;
}

.landing-hero--v5 h1 {
    font-size: clamp(2rem, 4.5vw, 3.4rem);
    line-height: 1.08;
    font-weight: 800;
}

.landing-badges .dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold-500);
    margin-right: 6px;
    vertical-align: middle;
}

.preview-stack {
    position: relative;
    max-width: 340px;
    margin: 0 auto;
}

.preview-card {
    border-radius: 24px;
    background: var(--ink-900);
    box-shadow: var(--shadow-lift);
}

.preview-card--back {
    position: absolute;
    inset: 12px -12px -12px 12px;
    opacity: 0.45;
    transform: rotate(3deg);
}

.preview-card--main {
    position: relative;
    padding: 24px;
    border: 1px solid rgba(199, 154, 48, 0.3);
}

.preview-top {
    margin-bottom: 20px;
}

.preview-top strong {
    display: block;
    font-family: var(--font-display);
    font-size: 2rem;
    color: #fff;
    margin-top: 8px;
}

.preview-stat {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.preview-stat em {
    font-style: normal;
    color: var(--gold-300);
    font-weight: 700;
}

.preview-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    margin-top: 16px;
    overflow: hidden;
}

.preview-bar span {
    display: block;
    height: 100%;
    background: var(--gold-grad);
    border-radius: 99px;
}

.landing-features--v5 {
    position: relative;
    text-align: center;
}

.section-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-600);
    margin: 0 0 8px;
}

.landing-features--v5 h2 {
    margin-bottom: 32px;
}

.feature-card {
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card);
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(199, 154, 48, 0.2), rgba(199, 154, 48, 0.06));
    color: var(--gold-700);
    display: grid;
    place-items: center;
    margin-bottom: 14px;
}

.feature-icon svg {
    width: 24px;
    height: 24px;
}

.feature-card h3 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.feature-card p {
    margin: 0;
    color: var(--ink-500);
    font-size: 0.9rem;
}

.landing-cta-band--v5 {
    border: 1px solid rgba(199, 154, 48, 0.2);
}

/* Cart summary polish */
.cart-summary {
    border-radius: var(--radius-xl);
    border: 1px solid rgba(199, 154, 48, 0.25);
}

/* Hide legacy header if present */
.app-header {
    display: none !important;
}

.network-status {
    top: calc(var(--topbar-h) + var(--safe-top) + 8px);
}

@media (min-width: 768px) {
    .network-status {
        left: calc(var(--sidebar-w) + 50%);
        transform: translateX(-50%);
    }
}
