* { box-sizing: border-box; }
body {
    margin: 0;
    background: #f4f6fb;
    color: #1b1d22;
    font-family: "Tahoma", "Microsoft YaHei", sans-serif;
}
a { color: #3a61d8; text-decoration: none; }
.topbar {
    background: #fff;
    border-bottom: 1px solid #dce3ef;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar .brand { font-weight: 700; }
.topbar nav { display: flex; gap: 14px; font-size: 14px; }
.container { max-width: 1200px; margin: 20px auto; padding: 0 16px 40px; }
.card {
    background: #fff;
    border: 1px solid #dce3ef;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}
h1, h2, h3 { margin: 0 0 12px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border: 1px solid #d9dfeb; padding: 8px; font-size: 13px; }
th { background: #edf2ff; text-align: left; }
label { font-size: 13px; display: block; margin: 8px 0 4px; }
input, select, textarea, button {
    width: 100%;
    padding: 8px;
    border: 1px solid #cfd7e6;
    border-radius: 6px;
    font: inherit;
}
button {
    cursor: pointer;
    background: #3a61d8;
    color: #fff;
    border: none;
}
.btn-inline { 
    display: inline-block;
    width: auto; 
    padding: 8px 16px; 
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    transition: opacity 0.2s;
}
.btn-inline:hover { opacity: 0.9; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.auth-body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid #dce3ef;
    border-radius: 10px;
    padding: 20px;
}
.flash { padding: 10px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; }
.flash.success { background: #e8f7ef; color: #1d7c45; }
.flash.error { background: #fdeaea; color: #9f2a2a; }
.logo-preview { max-height: 80px; max-width: 200px; }
.small { font-size: 12px; color: #667; }
.row-actions { display: flex; gap: 8px; }
.row-actions a, .row-actions button { width: auto; }

/* Print Styles */
.no-print { display: block; }

@media print {
    @page {
        margin: 0; /* This hides browser headers/footers */
    }
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }
    /* Add padding to the actual document root so content isn't at the very edge */
    #doc-root {
        padding: 1cm !important;
        margin: 0 !important;
        width: 100% !important;
        box-shadow: none !important;
    }
    /* Hide everything by default */
    body * {
        visibility: hidden !important;
    }
    /* Show the document and its children */
    #doc-root, #doc-root * {
        visibility: visible !important;
    }
    /* Position the document at the very top left of the printed page */
    #doc-root {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
    }
    /* Hide the topbar and action area explicitly */
    .topbar, .no-print, footer, .btn-inline {
        display: none !important;
    }
}

/* Document High-Fidelity Styles (Matching Image) */
.quote-precision {
    width: 900px;
    margin: 0 auto;
    padding: 30px;
    background: #fff;
    color: #000;
    font-size: 13px;
    line-height: 1.4; /* Slightly reduced */
    font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;
}
.quote-precision .header-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}
.quote-precision .co-info-left .co-name-big {
    font-size: 24px;
    font-weight: bold;
    font-style: italic;
    margin-bottom: 5px;
}
.quote-precision .co-info-left .co-logo-img {
    max-height: 50px;
    margin-bottom: 10px;
}
.quote-precision .co-details-text {
    font-size: 12px;
    line-height: 1.4;
}
.quote-precision .header-right {
    text-align: right;
}
.quote-precision .title-main {
    font-size: 32px;
    color: #4f6ca6;
    font-weight: normal;
    margin-bottom: 15px;
}
.quote-precision .meta-info {
    display: inline-block;
    text-align: left;
}
.quote-precision .meta-line {
    display: flex;
    justify-content: space-between;
    width: 220px;
    margin-bottom: 4px;
    font-weight: normal;
}
.quote-precision .meta-line span:first-child {
    font-weight: bold;
}
.quote-precision .meta-line span:last-child {
    border-bottom: 1px solid #000;
    min-width: 140px;
    text-align: left;
    display: inline-block;
    font-weight: normal;
}

.quote-precision .section-bar {
    background: #2e4a88;
    color: #fff;
    font-weight: bold;
    padding: 1px 0;
    margin-bottom: 5px;
    font-size: 13px;
    display: block;
    width: 100%;
}
.quote-precision .section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}
.quote-precision .section-content {
    font-size: 12px;
    line-height: 1.4;
    padding-left: 0;
}

/* Specific line spacing for Customer and Shipping sections */
.quote-precision .customer-content,
.quote-precision .shipping-content {
    line-height: 1.6;
}

/* Key-Value alignment for Shipping Details */
.quote-precision .kv-row {
    display: flex;
    margin-bottom: 1px;
}
.quote-precision .kv-label {
    min-width: 140px; /* Reduced */
    display: inline-block;
}
.quote-precision .kv-value {
    flex: 1;
}

.quote-precision .items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.quote-precision .items-table th, 
.quote-precision .items-table td {
    border: 1px solid #000;
    padding: 3px 5px;
    font-size: 11px;
}
.quote-precision .items-table th {
    background: #fff;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
}
.quote-precision .items-table td {
    height: 22px;
}

.quote-precision .summary-area {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
}
.quote-precision .special-note-box {
    width: 60%;
}
.quote-precision .totals-box {
    width: 35%;
    margin-left: auto;
}
.quote-precision .totals-line {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
    font-size: 12px;
}
.quote-precision .totals-line.total-row {
    background: #e6e6e6;
    font-weight: bold;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 3px 0;
    margin-top: 4px;
}
.quote-precision .currency-row {
    font-weight: bold;
    margin-top: 4px;
    text-align: right;
}

.quote-precision .footer-sign-stamp {
    margin-top: 40px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}
.quote-precision .sign-column, 
.quote-precision .stamp-column {
    position: relative;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.quote-precision .sign-wrapper,
.quote-precision .stamp-wrapper {
    position: relative;
    width: 100%;
}
.quote-precision .sign-line,
.quote-precision .stamp-line {
    border-top: 1px solid #000;
    padding-top: 3px;
    font-size: 12px;
    width: 100%;
    text-align: left;
}
.quote-precision .img-signature-overlay {
    position: absolute;
    left: 20px;
    bottom: 20px;
    max-height: 60px;
    max-width: 80%;
    z-index: 2;
}
.quote-precision .img-stamp-overlay {
    position: absolute;
    left: 40px;
    bottom: 5px;
    max-height: 100px;
    max-width: 90%;
    opacity: 0.8;
    z-index: 1;
}

/* Dashboard Styles */
.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}
.stat-icon {
    font-size: 40px;
    color: #3a61d8;
    background: #edf2ff;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.stat-info h3 { margin: 0; font-size: 16px; color: #667; }
.stat-info p { margin: 4px 0 0; font-size: 28px; font-weight: 700; }

.action-icons { display: flex; gap: 12px; font-size: 16px; }
.action-icons a { color: #667; transition: color 0.2s; }
.action-icons a:hover { color: #3a61d8; }
.action-icons a.delete:hover { color: #e74c3c; }

/* Dropdown logic */
.dropdown { 
    position: relative; 
    display: inline-block; 
    font-family: "Tahoma", "Microsoft YaHei", "微软雅黑", sans-serif;
}
.dropdown-content {
    display: none !important; /* Force hidden by default */
    position: absolute;
    left: 0;
    top: 100%;
    background-color: #fff !important;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 9999; /* Ensure it's on top */
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dce3ef;
    font-family: "Tahoma", "Microsoft YaHei", "微软雅黑", sans-serif;
}
/* Show on hover or when parent has .active class */
.dropdown:hover .dropdown-content,
.dropdown.active .dropdown-content {
    display: block !important;
}

.dropdown-content button, 
.dropdown-content a {
    color: #333 !important;
    padding: 12px 16px !important;
    text-decoration: none !important;
    display: block !important;
    width: 100% !important;
    text-align: left !important;
    background: #fff !important;
    border: none !important;
    border-radius: 0 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    margin: 0 !important;
}
.dropdown-content button:hover,
.dropdown-content a:hover { 
    background-color: #f0f4ff !important; 
    color: #3a61d8 !important; 
}

.doc-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 1px solid #dce3ef;
    border-radius: 8px;
    min-width: 90px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.doc-badge:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    filter: brightness(0.95);
}
.doc-badge i { font-size: 28px; margin-bottom: 2px; }
.doc-badge span { font-size: 12px; font-weight: 700; text-align: center; }

/* Document Type Specific Colors - Solid backgrounds */
.doc-badge.contract { background-color: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.doc-badge.contract i { color: #4338ca; }
.doc-badge.customs { background-color: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.doc-badge.customs i { color: #c2410c; }
.doc-badge.invoice { background-color: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.doc-badge.invoice i { color: #15803d; }
.doc-badge.packing { background-color: #faf5ff; border-color: #e9d5ff; color: #7e22ce; }
.doc-badge.packing i { color: #7e22ce; }

.doc-wrapper {
    width: 1024px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #111;
    padding: 24px;
}
.doc-title {
    text-align: center;
    font-size: 38px;
    color: #8aa2e7;
    font-weight: 700;
    margin-bottom: 8px;
}
.doc-subtitle {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}
.section-title {
    background: #9cb0e8;
    color: #fff;
    font-weight: 700;
    padding: 4px 8px;
    margin-top: 8px;
}
.doc-sign-line {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
}
.doc-sign-line > div { width: 45%; border-top: 1px solid #111; padding-top: 6px; }

.print-layout {
    width: 1080px;
    min-height: 1480px;
    border: 2px solid #222;
    padding: 36px 42px;
    font-size: 13px;
    line-height: 1.2;
}
.print-top {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
}
.co-name { font-size: 40px; font-weight: 700; font-style: italic; margin-bottom: 10px; }
.co-logo { min-height: 46px; margin-bottom: 6px; }
.co-lines div { margin-bottom: 2px; }
.print-title {
    color: #8fa7e6;
    font-size: 50px;
    text-align: center;
    font-weight: 700;
    letter-spacing: 1px;
}
.print-sub { text-align: center; font-size: 32px; margin: 2px 0 8px; font-weight: 700; }
.meta-table td { border: none; border-bottom: 2px solid #222; padding: 2px 4px; }
.meta-table td:first-child { width: 45%; font-weight: 700; border-bottom: none; }
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin: 8px 0;
}
.blue-bar {
    background: #8ea6df;
    color: #fff;
    font-weight: 700;
    padding: 3px 8px;
    margin: 8px 0 2px;
}
.doc-table th, .doc-table td {
    border: 1px solid #111;
    font-size: 12px;
    padding: 2px 4px;
}
.doc-table th {
    background: #fff;
    text-align: center;
    font-weight: 700;
}
.bottom-panels {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 14px;
    margin-top: 6px;
}
.panel-left { border: 1px solid #111; min-height: 120px; padding: 0 6px 6px; }
.panel-right { padding-top: 18px; }
.panel-right div {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #ddd;
    padding: 2px 0;
    font-weight: 700;
}
.panel-right .total-line {
    border-top: 2px solid #111;
    border-bottom: 2px solid #111;
    font-size: 20px;
    margin-top: 4px;
}
.pay-line {
    color: #0639f5;
    font-size: 26px;
    font-weight: 700;
    margin: 12px 0 20px;
}
.customs-layout {
    width: 1280px;
    min-height: 1050px;
    padding: 20px;
    border: 1px solid #111;
}
.customs-title {
    text-align: center;
    font-size: 44px;
    margin-bottom: 14px;
}
