/* ===========================================================
   新上元管理系统 - 前端统一样式 v2.0 (手机端)
   方案A · 商务蓝灰风格
   更新：2026-04-09
   =========================================================== */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;
    --sidebar-bg: #1e293b;
    --sidebar-light: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --bg-body: #f1f5f9;
    --bg-white: #ffffff;
    --bg-muted: #f8fafc;
    --border: #e2e8f0;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

/* === Accessibility: Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === Accessibility: Focus States === */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* === Button Loading State === */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}
.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    top: 50%; left: 50%;
    margin: -8px 0 0 -8px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%; min-height: 100vh;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ==================== HEADER ==================== */
.app-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 16px 15px 20px;
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: -50%; right: -30%;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.header-row {
    display: flex; justify-content: space-between; align-items: center;
    position: relative; z-index: 1;
    margin-bottom: 12px;
}

.header-greeting {
    color: rgba(255,255,255,0.85);
    font-size: 12px; font-weight: 500;
}

.header-user {
    color: #fff; font-size: 12px; font-weight: 600;
    background: rgba(255,255,255,0.1);
    padding: 3px 10px; border-radius: 20px;
}

.header-title {
    position: relative; z-index: 1;
    color: #fff;
    font-size: 20px; font-weight: 700;
    letter-spacing: 0.5px;
}

.header-subtitle {
    position: relative; z-index: 1;
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    margin-top: 2px;
}

/* 返回按钮 */
.back-btn {
    position: absolute; left: 12px; top: 16px; z-index: 2;
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px;
}

.back-btn:active { background: rgba(255,255,255,0.2); }

/* ==================== STATS CARD ==================== */
.stats-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px;
    margin: -12px 15px 12px;
    position: relative; z-index: 2;
    box-shadow: var(--shadow-md);
}

.stats-scroll {
    display: flex; gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.stats-scroll::-webkit-scrollbar { display: none; }

.stat-item {
    text-align: center;
    padding: 12px 16px;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    min-width: 90px;
}

.stat-val {
    font-size: 20px; font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}

.stat-label {
    font-size: 11px; color: var(--text-tertiary);
    margin-top: 4px;
}

/* ==================== SEARCH ==================== */
.search-bar {
    background: var(--bg-white);
    margin: 0 15px 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.search-bar .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 13px;
}

.search-box { display: flex; gap: 8px; }

.search-input {
    flex: 1; padding: 9px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-body);
    color: var(--text-primary);
    transition: all var(--transition);
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.search-input::placeholder { color: var(--text-tertiary); }

.search-btn {
    background: var(--primary);
    color: #fff; border: none;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.search-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.search-btn:active { background: var(--primary-dark); transform: translateY(0); }

/* ==================== TABS ==================== */
.tab-bar {
    display: flex;
    background: var(--bg-white);
    margin: 0 15px 12px;
    border-radius: var(--radius-sm);
    padding: 4px;
    box-shadow: var(--shadow);
}

.tab-item {
    flex: 1;
    text-align: center;
    padding: 9px 6px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.tab-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

/* ==================== LIST CARD ==================== */
.list-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    margin: 0 15px 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.list-header {
    padding: 14px 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-header h3 {
    font-size: 14px; font-weight: 700;
    color: var(--text-primary);
}

.list-actions { display: flex; gap: 6px; }

.list-btn {
    background: var(--bg-body);
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
}

.list-btn:active { background: #e2e8f0; }

/* ==================== LIST CONTENT ==================== */
.list-content { max-height: none; overflow: visible; }
/* Module grid override — homeGrid uses .list-content for layout */
#homeGrid { max-height: none; overflow: visible; padding-bottom: 12px; }

/* ==================== LIST ITEM ==================== */
.list-item {
    padding: 14px 15px;
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.2s ease;
}

.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--primary-light); }

.item-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px; gap: 8px;
}

.item-id {
    font-weight: 700; color: var(--primary); font-size: 13px;
}

.item-date {
    color: var(--text-tertiary); font-size: 10px;
    background: var(--bg-body); padding: 2px 8px;
    border-radius: 10px; white-space: nowrap;
}

.item-name {
    font-size: 13px; color: var(--text-primary);
    margin-bottom: 8px; font-weight: 500;
}

.item-bottom {
    display: flex; justify-content: space-between; align-items: center;
    gap: 8px;
}

.item-info { font-size: 11px; color: var(--text-tertiary); }

.item-amount {
    font-size: 15px; font-weight: 700; white-space: nowrap;
}

.item-amount.positive { color: var(--danger); }
.item-amount.negative { color: var(--success); }
.item-amount.zero { color: var(--text-tertiary); }

/* ==================== BADGES ==================== */
.badge-tag {
    font-size: 10px; font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #ecfdf5; color: var(--success); }
.badge-warning { background: #fffbeb; color: var(--warning); }
.badge-danger { background: #fef2f2; color: var(--danger); }
.badge-gray { background: var(--bg-body); color: var(--text-secondary); }
.badge-orange { background: #FFF3E0; color: #E65100; }
.badge-purple { background: #F3E5F5; color: #7B1FA2; }

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

.empty-icon {
    font-size: 48px; margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p { font-size: 13px; }

/* ==================== LOADING ==================== */
.loading {
    text-align: center;
    padding: 30px;
    color: var(--text-tertiary);
}

.loading-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== ERROR ==================== */
.error-msg {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 10px 14px;
    margin: 0 15px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: none;
}

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
}

.modal-overlay.show { display: flex; }

.modal-box {
    background: var(--bg-white);
    border-radius: var(--radius);
    width: 90%; max-width: 480px;
    max-height: 80vh; overflow-y: auto;
}

.modal-hd {
    padding: 18px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}

.modal-hd h4 { font-size: 16px; font-weight: 700; }

.modal-close {
    background: none; border: none;
    font-size: 22px; color: var(--text-tertiary);
    cursor: pointer; padding: 0 4px;
}

.modal-bd { padding: 18px; }

.modal-ft {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    text-align: right;
}

.modal-action {
    background: var(--primary);
    color: #fff; border: none;
    padding: 9px 22px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
}

/* ==================== DETAIL TABLE ==================== */
.detail-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.detail-table tr { border-bottom: 1px solid #f5f5f5; }
.detail-table tr:last-child { border-bottom: none; }
.detail-table td {
    padding: 10px 0; font-size: 13px;
}
.detail-table td:first-child {
    color: var(--text-tertiary); width: 80px;
}
.detail-table td:last-child {
    color: var(--text-primary); font-weight: 500;
    text-align: right;
}
.detail-total { background: var(--bg-body); font-weight: 700; }

/* ==================== BUTTONS ==================== */
.btn-primary-full {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff; border: none;
    border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary-full:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}
.btn-primary-full:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}
.btn-primary-full:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-outline-full {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

/* ==================== FOOTER ==================== */
.app-footer {
    text-align: center;
    padding: 18px 15px 28px;
    color: var(--text-tertiary);
    font-size: 11px;
}

/* ==================== FORM ==================== */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block; font-size: 12px;
    font-weight: 600; color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-input {
    width: 100%; height: 42px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    font-size: 14px;
    background: var(--bg-body);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
}
.form-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ==================== ENV BLOCK ==================== */
.env-block {
    display: none;
    position: fixed; inset: 0;
    background: var(--bg-body);
    z-index: 9999;
    align-items: center; justify-content: center;
    flex-direction: column;
    text-align: center;
    padding: 40px;
}
.env-block .eb-icon { font-size: 48px; margin-bottom: 16px; }
.env-block h2 { font-size: 18px; color: var(--text-primary); margin-bottom: 8px; }
.env-block p { font-size: 13px; color: var(--text-secondary); }


/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 480px) {
    .modal-box {
        width: 95% !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }
    .modal-bd { padding: 14px 12px; }
    .modal-hd { padding: 14px 12px; }
    .modal-ft { padding: 12px; }
    .modal-hd h4 { font-size: 15px; }
    
    .form-input, .form-select, select,
    input[type="text"], input[type="number"],
    input[type="date"], input[type="password"] {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    input[type="date"], input[type="number"] {
        -webkit-appearance: none;
        -moz-appearance: textfield;
        appearance: none;
    }
    input[type="number"]::-webkit-outer-spin-button,
    input[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    
    .modal-bd, .modal-ft, .modal-hd {
        overflow-x: hidden;
        max-width: 100%;
    }
    .modal-bd .ss-wrap { max-width: 100%; }
}

/* ==================== MISSING FORM ELEMENTS ==================== */
.form-select {
    width: 100%; height: 42px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    font-size: 14px;
    background: var(--bg-body);
    color: var(--text-primary);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.form-select:focus {
    border-color: var(--primary);
    background-color: #fff;
}

/* Sales detail table */
.section-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 16px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--primary); }
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.items-table th { background: var(--bg-body); padding: 10px 8px; text-align: right; font-weight: 600; color: var(--text-primary); border-bottom: 2px solid #e0e0e0; }
.items-table th:first-child { text-align: left; }
.items-table td { padding: 10px 8px; border-bottom: 1px solid #f5f5f5; text-align: right; }
.items-table td:first-child { text-align: left; color: var(--text-primary); }
.items-table .total-row { background: var(--bg-body); font-weight: 700; }
.items-table .total-row td { color: var(--danger); }

/* ===========================================================
   v2.1 统一组件库
   更新：2026-04-20
   =========================================================== */

/* ==================== MODULE HEADER ==================== */
.mod-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 32px 24px 48px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.mod-header::before {
    content: '';
    position: absolute;
    top: -40%; right: -20%;
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.mod-header::after {
    content: '';
    position: absolute;
    bottom: -30%; left: -15%;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.mod-header h1 {
    position: relative; z-index: 1;
    color: #fff;
    font-size: 24px; font-weight: 700;
    letter-spacing: 2px;
    margin: 0;
}
.mod-header p {
    position: relative; z-index: 1;
    color: rgba(255,255,255,0.75);
    font-size: 13px;
    margin-top: 6px;
}

/* ==================== MODULE BACK BUTTON ==================== */
.mod-back-btn {
    position: absolute; left: 16px; top: 16px; z-index: 2;
    padding: 6px 14px;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px; font-weight: 600;
    transition: background var(--transition);
    backdrop-filter: blur(10px);
}
.mod-back-btn:active { background: rgba(255,255,255,0.3); }

/* ==================== SECTION HEADER ==================== */
.sec-header {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-white);
}
.sec-header h2 {
    font-size: 16px; font-weight: 700; color: var(--text-primary);
    margin: 0;
}

/* ==================== PERIOD BAR ==================== */
.period-bar {
    background: var(--bg-white);
    margin: 0 15px 12px;
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: flex; justify-content: space-between; align-items: center;
}
.period-bar span {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
}

/* ==================== DETAIL CONTENT ==================== */
.detail-content {
    background: var(--bg-body);
    min-height: calc(100vh - 80px);
}

/* ==================== BUTTON SYSTEM ==================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 8px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:active:not(:disabled) { background: #059669; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:active:not(:disabled) { background: #d97706; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active:not(:disabled) { background: #dc2626; }

.btn-outline {
    background: transparent; color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:active:not(:disabled) { background: var(--primary-light); }

.btn-ghost {
    background: var(--bg-body); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:active:not(:disabled) { background: #e2e8f0; }

.btn-link {
    background: none; border: none; color: var(--primary);
    padding: 4px 8px; font-size: 12px;
}
.btn-link:active { text-decoration: underline; }

/* ==================== CARD COMPONENT ==================== */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 14px 15px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.card-header h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 15px; }
.card-footer {
    padding: 14px 15px;
    border-top: 1px solid var(--border);
    text-align: right;
}

/* ==================== SUMMARY CARD ==================== */
.summary-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px;
    margin: 0 15px 12px;
    box-shadow: var(--shadow);
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 12px;
}
.summary-item {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
}
.summary-item .val {
    font-size: 20px; font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}
.summary-item .label {
    font-size: 11px; color: var(--text-tertiary);
    margin-top: 4px;
}

/* ==================== WAREHOUSE GRID ==================== */
.wh-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 15px;
}
.wh-card {
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
}
.wh-card:active { border-color: var(--primary); }
.wh-card .wh-name {
    font-size: 13px; font-weight: 700; color: var(--text-primary);
    margin-bottom: 4px;
}
.wh-card .wh-code {
    font-size: 11px; color: var(--text-tertiary);
    margin-bottom: 8px;
}
.wh-card .wh-count {
    font-size: 20px; font-weight: 800; color: var(--primary);
}
.wh-card .wh-label {
    font-size: 10px; color: var(--text-tertiary);
}

/* ==================== SEARCHABLE SELECT (ss-wrap) ==================== */
.ss-wrap {
    position: relative;
    width: 100%;
}
.ss-wrap .ss-input {
    width: 100%;
}
.ss-wrap .ss-dd {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 4px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.ss-wrap .ss-dd.open {
    display: block;
}
.ss-wrap .ss-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ==================== SS-ITEM (Sales/Stock Item) ==================== */
.ss-item {
    padding: 14px 15px;
    border-bottom: 1px solid #f5f5f5;
    transition: background var(--transition);
}
.ss-item:last-child { border-bottom: none; }
.ss-item:active { background: var(--primary-light); }

/* ==================== LIST INFO ==================== */
.list-info {
    font-size: 12px; color: var(--text-secondary); font-weight: 500;
}

/* ==================== LIST TAGS ==================== */
.list-tag-blue { background: var(--primary-light); color: var(--primary); }
.list-tag-cyan { background: #ecfeff; color: #0891b2; }
.list-tag-green { background: #ecfdf5; color: var(--success); }
.list-tag-info { background: #ecfeff; color: #0891b2; }
.list-tag-orange { background: #fff7ed; color: #ea580c; }
.list-tag-purple { background: #faf5ff; color: #9333ea; }
.list-tag-yellow { background: #fefce8; color: #ca8a04; }
.list-tag-gray { background: var(--bg-body); color: var(--text-secondary); }
.list-tag-brown { background: #fef3e8; color: #8b5e3c; }
.list-tag-strike { text-decoration: line-through; opacity: 0.6; }
.list-tag {
    font-size: 10px; font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
}

/* ==================== BADGES ==================== */
.badge-info { background: #ecfeff; color: #0891b2; }

/* ==================== UTILITY CLASSES ==================== */
/* Font sizes */
.text-xs { font-size: 10px; }
.text-sm { font-size: 11px; }
.text-base { font-size: 12px; }
.text-md { font-size: 13px; }
.text-lg { font-size: 14px; }
.text-xl { font-size: 16px; }
.text-2xl { font-size: 20px; }
.text-3xl { font-size: 24px; }

/* Font weights */
.fw-normal { font-weight: 400; }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.fw-extrabold { font-weight: 800; }

/* Text colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

/* Spacing - gap */
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 16px; }

/* Spacing - margin */
.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 12px; }
.mt-lg { margin-top: 16px; }
.mb-xs { margin-bottom: 4px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 12px; }
.mb-lg { margin-bottom: 16px; }

/* Spacing - padding */
.p-xs { padding: 4px; }
.p-sm { padding: 8px; }
.p-md { padding: 12px; }
.p-lg { padding: 16px; }

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.grow { flex: 1; }

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Shadows */
.shadow-sm { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Border radius */
.rounded-sm { border-radius: 6px; }
.rounded { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius); }
.rounded-full { border-radius: 50%; }

/* Width */
.w-full { width: 100%; }

/* Overflow */
.overflow-auto { overflow: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ==================== FORM ACTIONS ==================== */
.action-row {
    display: flex; gap: 8px; padding: 12px 15px;
    border-top: 1px solid var(--border);
}
.action-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    border: none; cursor: pointer;
    text-align: center;
    transition: all var(--transition);
}
.action-btn:active { transform: scale(0.97); }

/* ==================== CONTRACT CARD ==================== */
.contract-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    margin: 0 15px 12px;
    padding: 15px;
    box-shadow: var(--shadow);
}

/* ==================== RECONCILIATION ROW ==================== */
.rec-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 13px;
}
.rec-row:last-child { border-bottom: none; }

/* ==================== STEP ARROW ==================== */
.step-arrow {
    display: flex; align-items: center; justify-content: center;
    padding: 16px 15px;
    gap: 4px;
    font-size: 11px; color: var(--text-tertiary);
}
.step-arrow .step {
    padding: 4px 8px;
    background: var(--bg-body);
    border-radius: 6px;
    white-space: nowrap;
}
.step-arrow .step.active {
    background: var(--primary);
    color: #fff;
}
.step-arrow .arrow {
    color: var(--text-tertiary);
    font-size: 12px;
}

/* ==================== REPORT CARD ==================== */
.rpt-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 15px;
    margin: 0 15px 12px;
    box-shadow: var(--shadow);
}
.rpt-row {
    display: flex; justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 13px;
}
.rpt-row:last-child { border-bottom: none; }

/* ==================== TOTAL ROW ==================== */
.total-row {
    background: var(--bg-body);
    font-weight: 700;
}

/* ==================== CF ROW (Cash Flow) ==================== */
.cf-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}
.cf-row:last-child { border-bottom: none; }

/* ==================== INLINE ROW ==================== */
.inline-row {
    display: flex; gap: 8px; align-items: center;
    margin-bottom: 12px;
}

/* ==================== FILTER CARD (Advanced Query) ==================== */
.filter-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 15px;
    margin: 0 15px 12px;
    box-shadow: var(--shadow);
}
.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.filter-item {
    display: flex; flex-direction: column; gap: 4px;
}
.filter-item label {
    font-size: 12px; font-weight: 600; color: var(--text-secondary);
}

/* ==================== RESULT CARD ==================== */
.result-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    margin: 0 15px 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f5f5f5;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px;
}
.result-item:last-child { border-bottom: none; }

/* ==================== ITEMS TABLE (enhanced) ==================== */
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th { background: var(--bg-body); padding: 10px 8px; text-align: right; font-weight: 600; color: var(--text-primary); border-bottom: 2px solid #e0e0e0; }
.items-table th:first-child { text-align: left; }
.items-table td { padding: 10px 8px; border-bottom: 1px solid #f5f5f5; text-align: right; }
.items-table td:first-child { text-align: left; }
.items-table .total-row { background: var(--bg-body); font-weight: 700; }
.items-table .total-row td { color: var(--danger); }

/* ==================== MODAL ENHANCEMENTS ==================== */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal.show { display: flex; }
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal-body { padding: 18px; }
.modal-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end;
}
.modal-header {
    padding: 18px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h4 { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none; border: none;
    font-size: 22px; color: var(--text-tertiary);
    cursor: pointer; padding: 0 4px;
}
.modal-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    border: none; cursor: pointer;
}

/* ==================== BACK BUTTON (legacy alias) ==================== */
.back-btn {
    position: absolute; left: 12px; top: 16px; z-index: 2;
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px;
}
.back-btn:active { background: rgba(255,255,255,0.2); }

/* ==================== HOME HERO ==================== */
.home-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 32px 24px 48px;
    text-align: center;
    position: relative;
    overflow: hidden;
    color: #fff;
}
.home-hero::before {
    content: '';
    position: absolute;
    top: -40%; right: -20%;
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    pointer-events: none;
}
.home-hero::after {
    content: '';
    position: absolute;
    bottom: -30%; left: -15%;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.home-hero h1 {
    font-size: 24px; font-weight: 700;
    letter-spacing: 2px;
    margin: 0;
    position: relative; z-index: 1;
}
.home-hero p {
    font-size: 13px;
    color: rgba(255,255,255,0.75);
    margin-top: 6px;
    position: relative; z-index: 1;
}

/* ==================== MOD CARD ==================== */
.mod-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    margin: 0 15px 12px;
    padding: 20px 16px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}
.mod-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.mod-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
}
.mod-card:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}
.mod-card:hover::before,
.mod-card:active::before {
    opacity: 1;
}
.mod-card-icon {
    font-size: 28px;
    margin-bottom: 4px;
}
.mod-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.mod-card-subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
    line-height: 1.4;
}

/* ==================== SECTION ACTIONS ==================== */
.section-actions {
    padding: 0 15px 10px;
    display: flex; gap: 8px;
}

/* ==================== TABLE CELL UTILS ==================== */
.td-r { text-align: right; padding: 8px 6px; }
.td-l { text-align: left; padding: 8px 6px; }
.td-c { padding: 8px 6px; }
.td-empty { padding: 12px; text-align: center; color: var(--text-tertiary); }
.td-empty-big { padding: 20px; text-align: center; color: var(--text-tertiary); }

/* ==================== COLOR UTILS ==================== */
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-tertiary); }
.fw-bold { font-weight: 600; }

/* ==================== SPACING UTILS ==================== */
.bg-body { background: var(--bg-body); }
.bg-muted { background: #f5f5f5; }
.border-b { border-bottom: 1px solid #f5f5f5; }
.border-t { border-top: 1px solid var(--border); }
.pt-md { padding-top: 12px; }
.p-lg { padding: 20px; }
.px-sm { padding-left: 4px; padding-right: 4px; }

/* ==================== DROPDOWN ITEM ==================== */
.dd-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f5f5f5; font-size: 13px; }
.dd-item:last-child { border-bottom: none; }
.dd-item:active { background: #fff3e0; }

/* ==================== SALES DETAIL UTILS ==================== */
.detail-sub { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 2px; }
.detail-input { font-size: 13px; padding: 6px 8px; width: 100%; }
.mb-md { margin-bottom: 12px; }
.mb-sm { margin-bottom: 6px; }
.mt-md { margin-top: 10px; }
.detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.td-r-lg { text-align: right; padding: 10px 8px; }
.td-r-pad { text-align: right; padding: 10px; }
.min-w-sm { min-width: 30px; }
.flex-1 { flex: 1; }
.px-sm { padding-left: 6px; padding-right: 6px; }
.py-sm { padding-top: 6px; padding-bottom: 6px; }
.bg-muted { background: #f5f5f5; }
/* ==================== PURCHASE DETAIL UTILS ==================== */
.dropdown-list {
    display: none; max-height: 180px; overflow-y: auto;
    border: 1px solid var(--border); border-top: none;
    border-radius: 0 0 8px 8px; background: var(--bg-white);
}
.search-input-full {
    width: 100%; padding: 8px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 13px;
}
.data-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.td-r-sm { text-align: right; padding: 3px 4px; }
.mt-lg { margin-top: 16px; }

/* ==================== SALES DETAIL UTILS ==================== */
.ml-sm { margin-left: 6px; }
.ml-0 { margin-left: 0; }
.modal-close-x {
    position: absolute; top: 8px; right: 8px;
    background: none; border: none; color: var(--text-tertiary);
    font-size: 20px; cursor: pointer;
}

/* ==================== PRODUCTION CARD ==================== */
.prod-card {
    background: var(--bg-white); border-radius: var(--radius);
    padding: 18px 12px; box-shadow: var(--shadow);
    cursor: pointer; text-align: center;
}
.prod-card-icon { font-size: 26px; margin-bottom: 6px; }
.prod-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.prod-card-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }

/* ==================== ADDITIONAL UTILS ==================== */
.td-r-sm2 { text-align: right; padding: 6px 4px; }
.td-r-sm3 { text-align: right; padding: 8px 4px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 6px; }
.gap-md { gap: 12px; }
