/* Design Tokens & Theme Variables */
:root {
    /* Color Palette */
    --primary: #5856d6;
    --primary-light: #ececfb;
    --primary-grad: linear-gradient(135deg, #7f00ff, #e100ff);
    --secondary: #8e8e93;
    --success: #34c759;
    --success-light: #eafaf1;
    --success-grad: linear-gradient(135deg, #11998e, #38ef7d);
    --danger: #ff3b30;
    --danger-light: #ffebeb;
    --danger-outline: #ff4d4d;
    --warning: #ffcc00;
    --bg-main: #f5f7fb;
    --bg-card: #ffffff;
    --text-main: #1d1d1f;
    --text-muted: #86868b;
    --border-color: #e5e5ea;
    
    /* Courier specific gradients */
    --courier-orange-grad: linear-gradient(135deg, #ff9900, #ff5e00); /* Shopee */
    --courier-blue-grad: linear-gradient(135deg, #00c6ff, #0072ff); /* Lazada / Lex */
    --courier-yellow-grad: linear-gradient(135deg, #ffdb01, #e1ad01); /* Flash */
    --courier-red-grad: linear-gradient(135deg, #ff416c, #ff4b2b); /* J&T */
    --courier-purple-grad: linear-gradient(135deg, #8a2387, #e94057); /* Tiktok */
    --courier-green-grad: linear-gradient(135deg, #11998e, #38ef7d); /* Custom Green */
    
    /* Layout & Effects */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px rgba(90, 97, 105, 0.1);
    --shadow-lg: 0 15px 35px rgba(0, 0, 0, 0.1);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Noto Sans Thai', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar Style */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar navigation */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1e1e38 0%, #151527 100%);
    color: #ffffff;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2.5rem;
}

.brand-icon {
    background: var(--primary-grad);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(127, 0, 255, 0.3);
}

.brand-icon i {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.brand-info h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #ffffff, #d3d3ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-info span {
    font-size: 0.75rem;
    color: #8c8cbd;
    display: block;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.menu-item {
    background: transparent;
    border: none;
    color: #9d9dbd;
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    transition: var(--transition);
    width: 100%;
}

.menu-item i {
    width: 20px;
    height: 20px;
    transition: var(--transition);
}

.menu-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.menu-item.active {
    color: #ffffff;
    background: rgba(88, 86, 214, 0.25);
    border-left: 4px solid #5856d6;
}

.menu-item.active i {
    color: #5856d6;
    transform: scale(1.1);
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1.5rem;
    font-size: 0.75rem;
    color: #5d5d7d;
    text-align: center;
}

.sidebar-footer p:first-child {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.header-title h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.header-title .subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.date-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.date-selector-wrapper label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.date-selector-wrapper label i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.date-input {
    border: none;
    outline: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    background: transparent;
    cursor: pointer;
}

/* Tab Management */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* Cards & Layout */
.grid-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 2rem;
    align-items: start;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.8rem;
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 12px 30px rgba(90, 97, 105, 0.12);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-title i {
    color: var(--primary);
    width: 24px;
    height: 24px;
}

.card-title h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.helper-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.gradient-border {
    position: relative;
}
.gradient-border::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: var(--primary-grad);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Courier Inputs */
.courier-inputs-grid {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.courier-input-card {
    display: flex;
    align-items: center;
    background: var(--bg-main);
    padding: 1rem 1.2rem;
    border-radius: var(--radius-md);
    gap: 1rem;
    border: 1px solid transparent;
    transition: var(--transition);
}

.courier-input-card:focus-within {
    background: #ffffff;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(88, 86, 214, 0.1), var(--shadow-sm);
}

.courier-indicator {
    width: 14px;
    height: 45px;
    border-radius: 6px;
    flex-shrink: 0;
}

.courier-info {
    width: 160px;
    flex-shrink: 0;
}

.courier-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.courier-subname {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.shop-inputs-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.shop-box-wrapper {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: var(--transition);
    width: 76px;
    height: 44px;
    position: relative;
}

.shop-box-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(88, 86, 214, 0.1);
}

.shop-field {
    width: 52px;
    height: 100%;
    background: transparent;
    border: none;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    outline: none;
    padding-left: 4px;
}

/* Stacked adjustment buttons on the right side */
.shop-adjust-stack {
    display: flex;
    flex-direction: column;
    width: 24px;
    height: 100%;
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
}

.shop-stack-btn {
    background: var(--bg-main);
    border: none;
    width: 100%;
    height: 50%;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    user-select: none;
    line-height: 1;
}

.shop-stack-btn.plus {
    border-bottom: 1px solid var(--border-color);
}

.shop-stack-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.shop-stack-btn.plus:hover {
    background: var(--success-light);
    color: var(--success);
}

.shop-stack-btn.minus:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Chrome, Safari, Edge, Opera: Remove spin buttons */
.shop-field::-webkit-outer-spin-button,
.shop-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox: Remove spin buttons */
.shop-field[type=number] {
    -moz-appearance: textfield;
}

.plus-separator {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-muted);
    user-select: none;
}

.btn-add-shop {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-add-shop:hover {
    background: var(--primary);
    color: #ffffff;
}

.btn-remove-shop {
    background: var(--danger-light);
    color: var(--danger);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-remove-shop:hover {
    background: var(--danger);
    color: #ffffff;
}

.courier-result {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 130px;
    flex-shrink: 0;
}

.courier-sum {
    font-size: 1.35rem;
    font-weight: 850;
    color: var(--text-main);
}

.courier-breakdown {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    text-align: right;
    margin-top: 0.1rem;
}

/* Stats Dashboard */
.summary-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    background: var(--bg-main);
    padding: 1.2rem;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.stat-item::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0; height: 3px;
    background: var(--secondary);
}

.stat-item.total-parcels::after {
    background: var(--primary-grad);
}

.stat-item.total-shops::after {
    background: var(--success-grad);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.stat-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 0.2rem;
}

.courier-summary-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    max-height: 250px;
    overflow-y: auto;
}

.courier-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 0.2rem 0;
}

.summary-row-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.summary-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.summary-row-value {
    font-weight: 700;
    color: var(--text-main);
}

/* Actions Card */
.button-stack {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.btn-group {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 0.8rem;
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 1.5rem;
    transition: var(--transition);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-lg {
    padding: 1.1rem 2rem;
    font-size: 1.05rem;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-full {
    width: 100%;
}

.btn-primary {
    background: var(--success-grad); /* Highlight copy action */
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(56, 239, 125, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 12px 24px rgba(56, 239, 125, 0.4);
    filter: brightness(1.05);
}

.btn-success {
    background: var(--primary-grad);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(127, 0, 255, 0.2);
}

.btn-success:hover {
    box-shadow: 0 12px 24px rgba(127, 0, 255, 0.35);
    filter: brightness(1.05);
}

.btn-secondary {
    background: var(--primary-light);
    color: var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: #ffffff;
}

.btn-danger-outline {
    background: transparent;
    border: 1.5px solid var(--danger-outline);
    color: var(--danger-outline);
}

.btn-danger-outline:hover {
    background: var(--danger-light);
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* Pulse animation for the primary copy button */
.pulse-effect {
    position: relative;
    overflow: hidden;
}

/* Line Preview Box */
.line-preview-box {
    background: #eef7ee; /* LINE Light green theme preview */
    border: 1px solid #cce2cc;
    border-radius: var(--radius-md);
    padding: 1.2rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #1e5a1e;
    margin-bottom: 0.8rem;
    border-bottom: 1px dashed #b7d6b7;
    padding-bottom: 0.5rem;
}

.tag {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
}

.tag-success {
    background: #cce2cc;
    color: #1e5a1e;
}

#line-message-preview {
    font-family: 'Inter', 'Noto Sans Thai', monospace;
    font-size: 0.95rem;
    font-weight: 550;
    line-height: 1.5;
    color: #2b5c2b;
    white-space: pre-wrap;
    word-break: break-all;
}

/* History Section Styles */
.history-header {
    align-items: center;
}

.history-table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
    min-height: 200px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.history-table th, .history-table td {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
}

.history-table th {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-table td {
    font-size: 0.95rem;
    color: var(--text-main);
}

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

.history-table tbody tr:hover {
    background-color: var(--bg-main);
}

.actions-column {
    text-align: right;
    width: 140px;
}

.action-row-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.btn-action-edit {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-action-edit:hover {
    background: var(--primary);
    color: white;
}

.btn-action-delete {
    background: var(--danger-light);
    color: var(--danger);
    border: none;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-action-delete:hover {
    background: var(--danger);
    color: white;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    stroke-width: 1.5;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Settings Styles */
.card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    width: 100%;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1.5rem;
    align-items: start;
}

.sub-card {
    background: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.sub-card h4 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sub-card h4 i {
    color: var(--primary);
    width: 20px;
    height: 20px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.form-group input[type="text"] {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
}

.form-group input[type="text"]:focus {
    border-color: var(--primary);
}

.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.color-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    background: #ffffff;
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
}

.color-option input {
    display: none;
}

.color-circle {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

.color-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.channel-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.channel-settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.channel-name-tag {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.channel-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.channel-actions {
    display: flex;
    gap: 0.4rem;
}

.btn-channel-delete {
    background: transparent;
    border: none;
    color: var(--danger-outline);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
    transition: var(--transition);
}

.btn-channel-delete:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1c1c1e;
    color: #ffffff;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transform: translateY(100px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.toast-content i {
    width: 18px;
    height: 18px;
    color: var(--success);
}

/* Responsive adjustments */
@media (max-width: 1100px) {
    .grid-layout {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        position: relative;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    }
    
    .brand {
        margin-bottom: 1rem;
        justify-content: center;
    }
    
    .menu {
        flex-direction: row;
        justify-content: space-around;
        gap: 0.2rem;
    }
    
    .menu-item {
        flex-direction: column;
        align-items: center;
        gap: 0.3rem;
        font-size: 0.75rem;
        padding: 0.6rem 0.5rem;
        text-align: center;
    }
    
    .menu-item.active {
        border-left: none;
        border-bottom: 3px solid #5856d6;
    }
    
    .sidebar-footer {
        display: none;
    }
    
    .main-content {
        padding: 1.2rem;
    }
    
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .date-selector-wrapper {
        width: 100%;
        justify-content: space-between;
    }
    
    .card {
        padding: 1.2rem;
    }
    
    .courier-input-card {
        flex-wrap: wrap;
        padding: 0.8rem;
    }
    
    .courier-info {
        width: 45%;
    }
    
    .courier-result {
        width: 45%;
        text-align: right;
    }
    
    .shop-inputs-container {
        width: 100%;
        order: 3;
        margin-top: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Cloud Status Badge */
.cloud-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.75rem;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
    user-select: none;
}

.cloud-status-badge i {
    width: 14px;
    height: 14px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Connecting State */
.cloud-status-badge.connecting {
    color: #ff9500;
    background: #fff9e6;
    border-color: #ffe699;
}
.cloud-status-badge.connecting .status-dot {
    background: #ffcc00;
    animation: statusPulse 1.2s infinite;
}

/* Online State */
.cloud-status-badge.online {
    color: #1e5a1e;
    background: #eef7ee;
    border-color: #cce2cc;
}
.cloud-status-badge.online .status-dot {
    background: #34c759;
}

/* Offline / Error State */
.cloud-status-badge.offline {
    color: #ff3b30;
    background: #ffebeb;
    border-color: #ffcccc;
}
.cloud-status-badge.offline .status-dot {
    background: #ff3b30;
    animation: statusPulse 0.8s infinite;
}

@keyframes statusPulse {
    0% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1.0; transform: scale(1.1); }
    100% { opacity: 0.3; transform: scale(0.8); }
}

/* Accordion / History Styles */
.history-date-header {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.history-date-header:hover {
    background-color: var(--bg-hover) !important;
}

.history-date-header.active {
    background-color: rgba(88, 86, 214, 0.04) !important;
}

.history-detail-row {
    background-color: #fafaff;
}

.history-detail-container {
    padding: 0.8rem 1.2rem;
    border-left: 3px solid var(--primary);
    background: #fdfdff;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.sub-record-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sub-record-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    gap: 1rem;
    flex-wrap: wrap;
    transition: var(--transition);
}

.sub-record-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border-color: #d1d1f0;
}

.sub-record-time {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.95rem;
}

.sub-record-total {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.sub-record-total strong {
    color: var(--primary);
    font-size: 1.05rem;
}

.sub-record-details {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    min-width: 200px;
}

.sub-record-actions {
    display: flex;
    gap: 0.4rem;
}

.sub-record-actions button {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    border: 1px solid transparent;
    transition: var(--transition);
}

.sub-record-actions .btn-sub-edit {
    background: var(--primary-light);
    color: var(--primary);
}

.sub-record-actions .btn-sub-edit:hover {
    background: var(--primary);
    color: #ffffff;
}

.sub-record-actions .btn-sub-delete {
    background: var(--danger-light);
    color: var(--danger);
}

.sub-record-actions .btn-sub-delete:hover {
    background: var(--danger);
    color: #ffffff;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.history-date-header.active .toggle-icon {
    transform: rotate(180deg);
}

/* iOS Switch Styling */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e4e4e7;
    transition: 0.3s ease;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s ease;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}
