:root {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --panel-subtle: #f1f5f9;
    --border: #cbd5e1;
    --border-subtle: #e2e8f0;
    --border-card: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #334155;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-subtle: #eff6ff;
    --accent-text: #1d4ed8;
    --accent-2: #059669;
    --accent-2-subtle: #ecfdf5;
    --warn: #d97706;
    --warn-subtle: #fffbeb;
    --danger: #dc2626;
    --danger-subtle: #fef2f2;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-card: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.shell { display: flex; min-height: 100vh; }

/* Sidebar Navigation (Light Corporate) */
.sidebar {
    width: 245px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 1px 0 3px rgba(15, 23, 42, 0.03);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    padding: 0 4px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: #ffffff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.brand-title {
    font-weight: 700;
    font-size: 15.5px;
    color: var(--text);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
}

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

.sidebar nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s ease-in-out;
}

.sidebar nav a .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: color 0.15s ease-in-out;
}

.sidebar nav a:hover { 
    background: var(--panel-2); 
    color: var(--text); 
}

.sidebar nav a:hover .nav-icon {
    color: var(--text);
}

.sidebar nav a.active { 
    background: var(--accent-subtle); 
    color: var(--accent-text); 
    font-weight: 600;
    border: 1px solid #bfdbfe;
}

.sidebar nav a.active .nav-icon {
    color: var(--accent);
}

.sidebar-user {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 6px;
    background: var(--panel-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--accent);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.user-role {
    font-size: 10px;
    color: var(--muted);
    font-weight: 500;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.btn-logout:hover {
    background: var(--danger-subtle);
    color: var(--danger);
}

/* Content Area */
.content { 
    flex: 1; 
    padding: 28px 36px 60px; 
    max-width: 1240px; 
}

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

h1 { 
    font-size: 21px; 
    margin: 0; 
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

h2 { 
    font-size: 16px; 
    margin: 28px 0 12px; 
    font-weight: 700;
    color: var(--text); 
    letter-spacing: -0.01em;
}

h3 { 
    font-size: 13.5px; 
    margin: 18px 0 8px; 
    color: var(--text-secondary); 
    font-weight: 600;
}

h4 { 
    font-size: 12.5px; 
    margin: 14px 0 6px; 
    color: var(--text-secondary); 
    font-weight: 600;
    letter-spacing: 0.02em; 
}

p.hint { 
    color: var(--muted); 
    margin: -10px 0 20px; 
    font-size: 13px;
    line-height: 1.5;
}

/* Cards & Containers (High-Contrast Corporate Framing) */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}

.card h3:first-child, .card h2:first-child { 
    margin-top: 0; 
}

/* Metric / Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat .label {
    font-size: 11.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.stat .value {
    font-size: 22px;
    font-weight: 700;
    margin-top: 6px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.stat.accent {
    border-color: #93c5fd;
    background: #f8fbff;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.08);
}

.stat.accent .value { 
    color: var(--accent); 
}

/* Forms & Inputs Alignment */
.row { 
    display: flex; 
    gap: 16px; 
    flex-wrap: wrap; 
    align-items: flex-start; 
}

.row.align-center { align-items: center; }
.row.align-end { align-items: flex-end; }

.grid-3 { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 16px; 
    align-items: flex-start;
}

.field { 
    display: flex; 
    flex-direction: column; 
    gap: 4px; 
    justify-content: flex-start;
}

label { 
    font-size: 12px; 
    font-weight: 600; 
    color: var(--text-secondary); 
    min-height: 18px;
    display: flex;
    align-items: center;
}

input, select, textarea {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text);
    height: 38px;
    padding: 6px 11px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s ease-in-out;
    width: 100%;
}

textarea { height: auto; min-height: 80px; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input[type="number"] { font-variant-numeric: tabular-nums; }

button, .btn {
    background: var(--accent);
    color: #ffffff;
    border: 1px solid var(--accent);
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

button:hover, .btn:hover { 
    background: var(--accent-hover); 
    border-color: var(--accent-hover);
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.12);
}

button.secondary, .btn.secondary {
    background: #ffffff;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

button.secondary:hover, .btn.secondary:hover {
    background: var(--panel-2);
    color: var(--text);
    border-color: #94a3b8;
}

button.danger, .btn.danger {
    background: #ffffff;
    color: var(--danger);
    border: 1px solid #fca5a5;
}

button.danger:hover, .btn.danger:hover {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}

/* Item row builder */
.item-row {
    display: grid;
    grid-template-columns: 4fr 1.5fr auto;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.item-row label {
    min-height: 18px;
    margin-bottom: 4px;
    display: block;
}

.item-row select, .item-row input { width: 100%; }

.item-row .remove-row {
    margin-top: 22px;
}

/* Tables (High Contrast Headers & Clean Cell Lines) */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 10px;
    font-size: 13px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }

tbody tr:hover { 
    background: #f8fafc; 
}

.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions-col { text-align: right; white-space: nowrap; }

tr.total-row td {
    font-weight: 700;
    background: #f8fafc;
    border-top: 2px solid var(--border);
    border-bottom: none;
    color: var(--text);
}

tr.selected-row { 
    background: #f0fdf4 !important; 
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    background: #f1f5f9;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-accent {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
    font-weight: 700;
}

.badge-success {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
    font-weight: 700;
}

.badge-method {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-method.courier { 
    background: #fff7ed; 
    color: #c2410c; 
    border: 1px solid #fed7aa;
}

.badge-method.air { 
    background: #eff6ff; 
    color: #1d4ed8; 
    border: 1px solid #bfdbfe;
}

.badge-method.sea { 
    background: #ecfeff; 
    color: #0e7490; 
    border: 1px solid #a5f3fc;
}

.badge-transit {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    background: #f8fafc;
    color: #475569;
    border: 1px solid var(--border);
}

/* Item row builder */
.item-row {
    display: grid;
    grid-template-columns: 4fr 1.5fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.item-row select, .item-row input { width: 100%; }

.live-model-info {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    font-size: 11.5px;
    flex-wrap: wrap;
}

.live-model-info span {
    background: var(--panel-2);
    padding: 2px 7px;
    border-radius: 4px;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    font-weight: 500;
}

/* Flash Messages */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.flash ul { margin: 0; padding-left: 18px; }

.flash-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.flash-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.flash-warn {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

/* Tab Navigation */
.planner-tabs {
    display: flex;
    gap: 4px;
    background: #e2e8f0;
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    width: fit-content;
    border: 1px solid var(--border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    height: 34px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: none;
    transition: all 0.15s;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.7);
}

.tab-btn.active {
    background: #ffffff;
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
    border: 1px solid var(--border);
}

/* Comparison Cards Grid & High-Contrast Design */
.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-bottom: 30px;
}

.comparison-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow-card);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s ease-in-out;
}

/* Color Accent Bars per Method */
.comparison-card.method-courier {
    border-top: 4px solid #f97316;
}

.comparison-card.method-air {
    border-top: 4px solid #2563eb;
}

.comparison-card.method-sea {
    border-top: 4px solid #0891b2;
}

.comparison-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #94a3b8;
}

.comparison-card.best {
    border: 2px solid #059669 !important;
    background: #fafdfb;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.12);
}

.best-tag {
    position: absolute;
    top: -11px;
    right: 14px;
    background: #059669;
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 9px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}

.provider-title {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text);
    margin: 8px 0 12px;
}

.cost-hero {
    margin: 12px 0 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.grand-total {
    font-size: 25px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.unit-total {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
}

.diff-badge {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
}

.diff-zero {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.diff-more {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.cost-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12.5px;
    margin-bottom: 16px;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
}

.cost-row .val {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* Preset Buttons */
.preset-btn {
    background: #ffffff;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
    height: auto;
}

.preset-btn:hover {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: #93c5fd;
}

/* Toast Notifications */
.toast-notice {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0f172a;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.toast-notice.show {
    opacity: 1;
    transform: translateY(0);
}

.mini {
    font-size: 11.5px;
    color: var(--muted);
}

a { color: var(--accent); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; color: var(--accent-hover); }

/* Interactive SaaS Tooltips */
.tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: help;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-size: 10px;
    font-weight: 700;
    font-family: inherit;
    line-height: 1;
}

.tooltip-text {
    visibility: hidden;
    opacity: 0;
    width: 240px;
    background: #0f172a;
    color: #ffffff;
    text-align: left;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 11.5px;
    font-weight: 400;
    line-height: 1.4;
    position: absolute;
    z-index: 999;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: var(--shadow-lg);
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #0f172a transparent transparent transparent;
}

.tooltip-wrap:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Step Indicators for Guided Workflow */
.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.step-subtitle {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 0 auto;
}

/* Empty State Containers */
.empty-state {
    text-align: center;
    padding: 36px 20px;
    background: #ffffff;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin: 20px 0;
}

.empty-state-icon {
    font-size: 36px;
    margin-bottom: 10px;
    color: var(--muted);
}

.empty-state h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px;
    text-transform: none;
}

.empty-state p {
    font-size: 13px;
    color: var(--muted);
    max-width: 460px;
    margin: 0 auto 16px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #ffffff;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 18px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-card);
}

/* Print Styles */
.print-only-header { display: none; }

@media print {
    .sidebar, .planner-tabs, #form-products, #form-weight, #calc-form, .filter-bar, .actions-col, button, .btn, .best-tag {
        display: none !important;
    }
    .print-only-header {
        display: block !important;
        margin-bottom: 20px;
        padding-bottom: 12px;
        border-bottom: 2px solid #000;
    }
    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 11pt !important;
    }
    .shell { display: block !important; }
    .content { padding: 0 !important; max-width: 100% !important; }
    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        padding: 12px !important;
        margin-bottom: 14px !important;
    }
    table {
        border: 1px solid #999 !important;
        box-shadow: none !important;
        font-size: 10pt !important;
    }
    th, td {
        border-bottom: 1px solid #ddd !important;
        padding: 5px 8px !important;
    }
    th { background: #f0f0f0 !important; color: #000 !important; }
    .grand-total, .stat .value { color: #000 !important; }
}
