:root {
    --bg: #f4f6f8;
    --ink: #101320;
    --muted: #616b78;
    --card: rgba(255, 255, 255, 0.84);
    --panel-solid: #ffffff;
    --line: rgba(16, 19, 32, 0.1);
    --primary: #1b2f8f;
    --secondary: #e31837;
    --success: #117a4f;
    --danger: #af2133;
    --input-bg: rgba(255, 255, 255, 0.95);
    --bg-gradient: radial-gradient(circle at 15% 10%, #ffffff 0%, #edf2f7 45%, #e6ebf2 100%);
    --nav-link-bg: rgba(255, 255, 255, 0.6);
    --nav-link-color: #101320;
}

:root[data-theme="dark"] {
    --bg: #0f1627;
    --ink: #e7ecf6;
    --muted: #aebad1;
    --card: rgba(22, 30, 49, 0.9);
    --panel-solid: #1a243a;
    --line: rgba(220, 228, 241, 0.18);
    --primary: #91aafc;
    --secondary: #ff6c73;
    --success: #30c97f;
    --danger: #ff5c76;
    --input-bg: rgba(18, 26, 44, 0.95);
    --bg-gradient: radial-gradient(circle at 15% 10%, #23304e 0%, #151d30 42%, #0f1627 100%);
    --nav-link-bg: rgba(35, 49, 78, 0.92);
    --nav-link-color: #d4deef;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    color: var(--ink);
    background: var(--bg-gradient);
    min-height: 100vh;
}

h1, h2, h3 {
    font-family: 'Playfair Display', serif;
    margin-top: 0;
}

.bg-shape {
    position: fixed;
    width: 45vw;
    height: 45vw;
    border-radius: 45% 55% 70% 30% / 38% 31% 69% 62%;
    filter: blur(40px);
    opacity: 0.16;
    z-index: -1;
}

.bg-shape-a {
    background: #1b2f8f;
    left: -18vw;
    top: -20vw;
}

.bg-shape-b {
    background: #e31837;
    right: -18vw;
    bottom: -20vw;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

:root[data-theme="dark"] .topbar {
    background: rgba(16, 27, 47, 0.95);
}

.brand-link {
    display: inline-flex;
}

.logo-aysaray {
    width: auto;
    height: 58px;
    max-width: 170px;
    border-radius: 8px;
}

.logo-firm {
    width: 180px;
    max-width: 40vw;
    object-fit: contain;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.theme-toggle {
    min-width: 110px;
}

.badge-role {
    padding: 6px 10px;
    border-radius: 20px;
    background: #101320;
    color: #fff;
    font-size: 12px;
}

.nav-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 24px;
}

:root[data-theme="dark"] body.has-sidebar-nav .nav-wrap {
    background: rgba(16, 27, 47, 0.97);
}

.nav-wrap a {
    text-decoration: none;
    color: var(--nav-link-color);
    border: 1px solid var(--line);
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--nav-link-bg);
}

body.has-sidebar-nav .nav-wrap a {
    width: 100%;
}

.container {
    width: min(1240px, 94vw);
    margin: 20px auto 40px;
    display: grid;
    gap: 18px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 14px 34px rgba(15, 24, 48, 0.08);
}

.hero-card {
    background: linear-gradient(135deg, rgba(27, 47, 143, 0.95), rgba(227, 24, 55, 0.92));
    color: #fff;
}

.hero-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.form-grid {
    display: grid;
    gap: 12px;
}

.form-3 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-4 {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.grid-12 {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 12px;
}

.rate-form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-start;
    margin-top: 4px;
}

.rate-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.rate-reset-form {
    margin: 0;
}

.rate-toolbar .btn,
.rate-reset-form .btn,
.rate-form-actions .btn {
    min-width: 160px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--input-bg);
    color: var(--ink);
}

input[type="file"] {
    width: 100%;
    padding: 8px;
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(120deg, var(--secondary), #ff5f45);
    color: #fff;
}

.btn-success {
    background: linear-gradient(120deg, #0f8e5f, #24b36b);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-ghost {
    background: rgba(132, 146, 170, 0.22);
    color: var(--ink);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-big {
    height: 100%;
    min-height: 44px;
}

.alert {
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(17, 122, 79, 0.1);
    border-color: rgba(17, 122, 79, 0.3);
}

.alert-error {
    background: rgba(175, 33, 51, 0.1);
    border-color: rgba(175, 33, 51, 0.3);
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 9px;
    vertical-align: middle;
}

.sort-link {
    color: inherit;
    text-decoration: none;
}

.sort-link:hover {
    text-decoration: underline;
}

.inline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-actions form {
    margin: 0;
}

.thumb-logo {
    width: 110px;
    height: 36px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
}

.thumb-product {
    width: 84px;
    height: 64px;
    object-fit: cover;
    border-radius: 10px;
}

.thumb-product.zoomable {
    cursor: zoom-in;
}

.qty-input {
    width: 80px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.metric-card {
    border-radius: 16px;
    padding: 16px;
    background: var(--panel-solid);
    border: 1px solid var(--line);
}

.metric-card strong {
    font-size: 32px;
    display: block;
}

.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.history-actions .btn {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 34px;
}

.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

#networkState {
    padding: 6px 12px;
    border-radius: 18px;
    font-weight: 700;
    font-size: 12px;
}

#networkState.online {
    background: rgba(17, 122, 79, 0.14);
    color: #0e6e46;
}

#networkState.offline {
    background: rgba(175, 33, 51, 0.16);
    color: #8f1f2e;
}

.offer-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 19, 32, 0.52);
    z-index: 40;
}

.offer-popup {
    position: fixed;
    z-index: 50;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(1280px, 96vw);
    max-height: 90vh;
    overflow: auto;
    background: var(--panel-solid);
    color: var(--ink);
}

.offer-popup-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.list-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.pagination-wrap {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#pageInfo {
    min-width: 140px;
    text-align: center;
    font-weight: 700;
}

body.modal-open {
    overflow: hidden;
}

.customer-shell {
    padding: 14px;
}

.customer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.customer-brand-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.customer-brand-left h1 {
    margin: 0;
}

.customer-brand-left p {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.customer-firm-logo {
    max-height: 80px;
}

.offer-flow-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 10px;
}

.offer-flow-head p {
    margin-bottom: 0;
}

.offer-back-btn {
    white-space: nowrap;
}

.firm-pick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.firm-pick-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    background: var(--panel-solid);
    text-decoration: none;
    color: var(--ink);
    display: grid;
    place-items: center;
    gap: 8px;
}

.firm-pick-card img {
    width: 140px;
    height: 56px;
    object-fit: contain;
}

.firm-pick-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(27, 47, 143, 0.15);
}

.touch-flow-card h2 {
    margin-bottom: 6px;
}

.month-touch-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(90px, 1fr));
    gap: 10px;
    margin: 14px 0;
}

.month-touch-btn {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 10px;
    background: var(--panel-solid);
    cursor: pointer;
    font-weight: 700;
}

.month-touch-btn.selected {
    background: linear-gradient(120deg, var(--secondary), #ff5f45);
    color: #fff;
    border-color: transparent;
}

.touch-toolbar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.touch-jump-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.touch-jump-wrap input {
    width: 120px;
}

.maturity-compact-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin: 10px 0 14px;
}

.maturity-selected-pill {
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-solid);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.offer-submit-row {
    margin-top: 14px;
    display: grid;
}

.offer-submit-row .touch-submit {
    width: 100%;
}

.touch-page-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-solid);
    font-weight: 700;
}

.touch-product-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.touch-product-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-solid);
    padding: 12px;
    display: grid;
    gap: 10px;
}

.touch-product-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(27, 47, 143, 0.14);
}

.touch-product-image {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 12px;
}

.touch-product-image.touch-zoomable {
    cursor: zoom-in;
}

.touch-product-meta {
    display: grid;
    gap: 4px;
}

.touch-product-meta small {
    color: var(--muted);
}

.touch-qty-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.touch-qty-wrap .qty-input {
    width: 90px;
    text-align: center;
}

.touch-submit {
    min-height: 48px;
    font-size: 18px;
}

.product-check {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.auth-wrap {
    min-height: 80vh;
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(520px, 94vw);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    padding: 28px;
    color: #18233d;
    box-shadow: 0 20px 44px rgba(9, 17, 33, 0.16);
}

.auth-card h1 {
    margin: 10px 0 8px;
    color: #18233d;
}

.auth-card p {
    margin: 0 0 18px;
    color: #55627b;
    font-weight: 600;
}

.auth-card label {
    color: #5a6881;
    font-weight: 700;
}

.auth-logo {
    width: 220px;
    border-radius: 12px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
}

.product-card {
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.product-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 10px;
}

.price {
    font-weight: 800;
    color: var(--secondary);
    font-size: 20px;
}

.loading-card {
    text-align: center;
}

.request-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 28, 0.64);
    z-index: 80;
}

.request-popup {
    position: fixed;
    z-index: 90;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(680px, 92vw);
    text-align: center;
    color: #f6f8ff;
    background: linear-gradient(145deg, #1c2b7d 0%, #571638 60%, #101320 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 28px 20px;
    box-shadow: 0 24px 60px rgba(8, 12, 28, 0.45);
}

.image-lightbox-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 28, 0.72);
    z-index: 110;
}

.image-lightbox {
    position: fixed;
    z-index: 120;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(980px, 95vw);
    max-height: 92vh;
    overflow: auto;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
}

.image-lightbox-close {
    margin-bottom: 10px;
}

.image-lightbox img#imageLightboxMain {
    width: 100%;
    max-height: 68vh;
    object-fit: contain;
    border-radius: 12px;
    background: #eef1f5;
}

.image-lightbox-thumbs {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.image-lightbox-thumb {
    border: 1px solid var(--line);
    background: var(--panel-solid);
    border-radius: 8px;
    padding: 0;
    cursor: pointer;
}

.image-lightbox-thumb img {
    width: 88px;
    height: 66px;
    object-fit: cover;
    display: block;
    border-radius: 8px;
}

.image-lightbox-thumb.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(27, 47, 143, 0.2);
}

.ring-loader {
    width: 88px;
    height: 88px;
    margin: 16px auto;
    border-radius: 50%;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-right-color: #ff6a5f;
    animation: ringSpin 0.9s linear infinite;
}

@keyframes ringSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.digital-loader {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 8px 0;
}

.digital-loader span {
    width: 12px;
    height: 12px;
    border-radius: 100%;
    background: var(--primary);
    animation: pulse 1.2s infinite;
}

.digital-loader span:nth-child(2) { animation-delay: 0.2s; }
.digital-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 100% { transform: scale(0.6); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
}

.hidden {
    display: none;
}

.row-selected {
    background: rgba(227, 24, 55, 0.08);
}

.marketing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
}

@media (min-width: 1280px) {
    body.has-sidebar-nav .topbar {
        position: sticky;
        top: 0;
        z-index: 70;
    }

    body.has-sidebar-nav .nav-wrap {
        position: fixed;
        left: 0;
        top: 86px;
        width: 230px;
        height: calc(100vh - 86px);
        overflow-y: auto;
        padding: 18px 14px 14px;
        border-right: 1px solid var(--line);
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(8px);
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
    }

    body.has-sidebar-nav .container {
        width: min(1240px, calc(100vw - 270px));
        margin: 20px 20px 40px 250px;
    }
}

@media print {
    body {
        background: #fff;
    }

    .bg-shape,
    .topbar,
    .nav-wrap,
    .status-row,
    .month-touch-grid,
    .touch-toolbar,
    .touch-product-grid,
    .firm-pick-grid,
    .customer-shell,
    .request-popup,
    .request-popup-backdrop,
    .offer-popup,
    .offer-popup-backdrop,
    #offlineConfig {
        display: none !important;
    }

    main.container > section.card {
        display: none !important;
    }

    #quoteResult {
        display: block !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #fff !important;
    }

    #quoteResult .quick-actions {
        display: none !important;
    }

    #quoteResult .table-wrap {
        overflow: visible;
    }

    #quoteResult table {
        min-width: 0;
        width: 100%;
        font-size: 12px;
    }
}

@media (max-width: 1279px) {
    body.has-sidebar-nav .nav-wrap {
        position: static;
        width: auto;
        height: auto;
        border-right: 0;
        background: transparent;
        backdrop-filter: none;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    body.has-sidebar-nav .nav-wrap a {
        width: auto;
    }

    body.has-sidebar-nav .container {
        width: min(1240px, 94vw);
        margin: 20px auto 40px;
    }
}

@media (max-width: 900px) {
    .rate-toolbar .btn,
    .rate-reset-form,
    .rate-reset-form .btn,
    .rate-form-actions .btn {
        width: 100%;
    }

    .offer-flow-head {
        flex-direction: column;
        align-items: stretch;
    }

    .offer-back-btn {
        width: 100%;
        text-align: center;
    }

    .topbar {
        padding: 10px 14px;
    }

    .logo-aysaray {
        height: 50px;
        max-width: 140px;
    }

    .quick-actions .btn {
        width: 100%;
    }

    .table-wrap table {
        min-width: 760px;
    }

    .inline-actions {
        flex-wrap: wrap;
    }

    .grid-12 {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }

    .hero-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .offer-popup {
        width: 98vw;
        max-height: 92vh;
    }

    .month-touch-grid {
        grid-template-columns: repeat(4, minmax(90px, 1fr));
    }

    .touch-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .touch-jump-wrap {
        grid-column: span 2;
        justify-content: flex-end;
    }

    .maturity-compact-row {
        grid-template-columns: 1fr 1fr;
    }

    .touch-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

#quoteResult.offer-popup {
    width: min(1120px, 95vw);
    max-height: 92vh;
}

@media (max-width: 600px) {
    .grid-12 {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .month-touch-grid {
        grid-template-columns: repeat(3, minmax(90px, 1fr));
    }

    .customer-head,
    .customer-brand-left {
        flex-direction: column;
        align-items: flex-start;
    }

    .touch-product-grid {
        grid-template-columns: 1fr;
    }

    .touch-jump-wrap {
        grid-column: span 1;
        justify-content: stretch;
    }

    .maturity-compact-row {
        grid-template-columns: 1fr;
    }
}
