* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }
a { text-decoration: none; color: inherit; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); }
.login-box { background: #fff; padding: 40px; border-radius: 12px; width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.login-box h1 { text-align: center; margin-bottom: 8px; color: #008c5e; }
.login-box p { text-align: center; color: #888; margin-bottom: 24px; }
.login-box .btn { justify-content: center; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: #008c5e; }
.error-msg { background: #fee; color: #c00; padding: 10px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }

/* Layout */
.admin-layout { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: #1a1a2e; color: #fff; padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo { font-weight: 700; font-size: 16px; }
.shop-badge { background: #008c5e; padding: 4px 12px; border-radius: 4px; font-size: 13px; }
.shop-badge--impersonating {
    background: #008c5e;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    border: 2px solid #ffd666;
    color: #fff;
    cursor: pointer;
    transition: filter 0.15s, transform 0.15s;
}
.shop-badge--impersonating:hover { filter: brightness(1.12); transform: translateY(-1px); }
.welcome-impersonating { color: #ffd666; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.welcome { font-size: 13px; color: #ccc; }
.main-wrapper { display: flex; margin-top: 56px; min-height: calc(100vh - 56px); }
.sidebar { width: 180px; background: #fff; border-right: 1px solid #e8e8e8; position: fixed; top: 56px; bottom: 0; overflow-y: auto; z-index: 30; }
.sidebar-nav { padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 4px; padding: 12px 24px; color: #555; font-size: 14px; border-left: 3px solid transparent; transition: color .2s, background .2s; }
.nav-item-label { flex: 1; min-width: 0; }
.nav-badge {
    flex-shrink: 0;
    color: #e53935;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    min-width: 0;
    height: auto;
    border-radius: 0;
    animation: none;
}
.nav-badge[hidden] { display: none !important; }
.nav-item[data-has-badge="1"] .nav-item-label {
    color: #e53935;
    font-weight: 600;
}
.nav-item[data-has-badge="1"]:hover .nav-item-label,
.nav-item[data-has-badge="1"]:hover .nav-badge {
    color: #e53935;
}
.nav-item:hover { background: #f5f5f5; color: #008c5e; }
.nav-item.active { background: #f0faf5; color: #008c5e; border-left-color: #008c5e; font-weight: 600; }
.content { flex: 1; margin-left: 180px; padding: 24px; min-width: 0; position: relative; z-index: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; transition: all .2s; }
.btn-primary { background: #008c5e; color: #fff; }
.btn-primary:hover { background: #007a52; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-outline { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,.1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-blue { background: #3498db; color: #fff; }
.btn-yellow { background: #f39c12; color: #fff; }
.btn-orange { background: #e67e22; color: #fff; }
.btn-purple { background: #9b59b6; color: #fff; }
.btn-gray { background: #95a5a6; color: #fff; }
.btn-white { background: #fff; color: #333; border: 1px solid #ddd; }

/* Cards */
.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.card-desc { color: #888; font-size: 13px; margin-bottom: 16px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 20px; font-weight: 600; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); border-left: 4px solid #008c5e; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #333; }
.stat-card .stat-label { color: #888; font-size: 12px; margin-top: 4px; }
.stat-card.highlight-green .stat-value { color: #008c5e; }
.stat-card.highlight-orange .stat-value { color: #e67e22; }
.stat-card.highlight-red .stat-value { color: #e74c3c; }

/* Settings row */
.settings-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.settings-row select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; min-width: 180px; }

.locale-settings-card .card-title,
.locale-settings-card .card-desc { margin-bottom: 0; }
.locale-settings-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.locale-settings-head-text { flex: 1; min-width: 0; }
.locale-settings-head-text .card-desc { margin-top: 4px; }
.locale-settings-head-text .card-desc-sub { margin-top: 6px; margin-bottom: 0; color: #666; font-size: 12px; }
.search-bar .filter-client,
.overview-filters .filter-client {
    min-width: 140px;
}
.col-owner-client,
.col-assign-client {
    white-space: nowrap;
    font-size: 13px;
    color: #444;
    min-width: 120px;
}
.product-assign-select,
.domain-assign-select {
    min-width: 120px;
    max-width: 160px;
}
.product-lock-badge {
    margin-left: 4px;
    font-size: 11px;
    vertical-align: middle;
}
.product-row-locked .product-cell-readonly {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: default;
}
.product-row-locked:hover { background: #fafafa; }
.admin-sound-toggle { flex-shrink: 0; white-space: nowrap; }
.admin-sound-toggle.is-on { border-color: #008c5e; color: #008c5e; background: #f0faf6; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
th { background: #fafafa; font-weight: 600; font-size: 13px; color: #555; white-space: nowrap; }
tr:hover { background: #fafafa; }
.product-table tbody tr.product-row { transition: background .15s ease; cursor: default; }
.product-table tbody tr.product-row:hover { background: #e8f8f0; }
.product-table .product-id-cell {
    width: 88px;
    font-weight: 600;
    font-size: 13px;
    color: #008c5e;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.product-cell-link { display: block; color: inherit; text-decoration: none; }
.product-cell-link:hover .product-title { color: #008c5e; }
.product-cell-link .product-thumb { transition: opacity .15s; }
.product-cell-link:hover .product-thumb { opacity: .85; }
.product-thumb { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; background: #eee; }
.product-cell { display: flex; align-items: center; gap: 10px; max-width: 320px; }
.product-title { font-size: 13px; line-height: 1.4; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.badge-green { background: #e8f8f0; color: #008c5e; }
.badge-orange { background: #fef3e2; color: #e67e22; }
.badge-red { background: #fde8e8; color: #e74c3c; }
.badge-gray { background: #f0f0f0; color: #888; }
.badge-purple { background: #f3e8fd; color: #9b59b6; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e8e8e8; margin-bottom: 16px; }
.tab { padding: 10px 20px; cursor: pointer; color: #666; font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: #008c5e; border-bottom-color: #008c5e; font-weight: 600; }
.tab .count { color: #999; margin-left: 4px; }

/* Search bar */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input[type="text"], .search-bar input[type="date"] { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; }
.search-bar select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; }

/* Toggle switch */
.toggle { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 24px; transition: .3s; }
.toggle-slider:before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.toggle input:checked + .toggle-slider { background: #008c5e; }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

/* Action buttons group */
.action-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.action-btns-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

/* Info banner */
.info-banner { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.info-banner h3 { margin-bottom: 12px; }
.info-banner ol { padding-left: 20px; line-height: 1.8; font-size: 13px; }
.info-banner .server-ip { float: right; font-size: 13px; opacity: .9; }

/* Chart */
.chart-container { position: relative; height: 300px; }

/* Pixel form */
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-group { flex: 1; min-width: 200px; margin-bottom: 0; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 8px; padding: 24px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Account modal */
.account-modal { width: 520px; padding: 0; overflow: hidden; }
.account-modal .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.account-modal .modal-header h2 { margin: 0; font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; color: #999; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-close:hover { color: #333; }
.modal-tabs { display: flex; border-bottom: 1px solid #e8e8e8; padding: 0 24px; margin-top: 16px; }
.modal-tab { padding: 10px 16px; background: none; border: none; cursor: pointer; font-size: 14px; color: #666; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.modal-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.modal-tab-panel { display: none; padding: 20px 24px 0; }
.modal-tab-panel.active { display: block; }
.account-modal .form-group { margin-bottom: 16px; }
.account-modal .form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
.account-modal .form-group .required { color: #e74c3c; margin-left: 2px; }
.account-modal .form-group input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.account-modal .form-group input:disabled { background: #f5f5f5; color: #666; cursor: not-allowed; }
.field-hint { display: block; margin-top: 4px; font-size: 12px; color: #e74c3c; }
.account-modal .modal-actions { padding: 16px 24px 20px; border-top: 1px solid #f0f0f0; margin-top: 0; }
.reauth-modal { width: 420px; max-width: 92vw; }
.reauth-modal-body { padding: 12px 24px 4px; }
.reauth-modal-desc { margin: 0 0 16px; font-size: 13px; color: #666; line-height: 1.5; }

/* Online indicator */
.online-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.online-dot.on { background: #008c5e; box-shadow: 0 0 6px #008c5e; }
.online-dot.off { background: #ccc; }

/* Toast */
.toast { position: fixed; top: 70px; right: 24px; background: #008c5e; color: #fff; padding: 12px 20px; border-radius: 6px; z-index: 300; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }

/* Checkbox */
input[type="checkbox"] { width: 16px; height: 16px; accent-color: #008c5e; }

.order-link { color: #008c5e; font-weight: 500; text-decoration: none; }
.order-link:hover { text-decoration: underline; }

/* Orders list */
.orders-page .card {
    overflow: hidden;
}
.orders-page .orders-table-wrap {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
    z-index: 0;
    isolation: isolate;
    max-width: 100%;
}
.orders-page .orders-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}
.orders-page .orders-table th,
.orders-page .orders-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    font-size: 13px;
    width: auto;
}
.orders-page .orders-table th {
    background: #fafafa;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    white-space: nowrap;
}
.orders-page .orders-table tbody tr:last-child td {
    border-bottom: none;
}
.orders-page .orders-table tbody tr:hover {
    background: #fafafa;
}
.orders-page .orders-table .col-check {
    width: 40px;
    text-align: center;
}
.orders-page .orders-table .col-actions {
    width: max-content;
    min-width: 72px;
    white-space: nowrap;
    text-align: center;
}
.orders-page .orders-table .col-actions .btn {
    white-space: nowrap;
}
.orders-page .orders-table .col-customer {
    vertical-align: top;
    min-width: 140px;
}
.orders-page .customer-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.4;
}
.orders-page .cell-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
    line-height: 1.35;
}
.orders-page .cell-line.customer-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
}
.orders-page .cell-line.customer-email {
    font-size: 12px;
    color: #999;
    font-weight: 400;
    white-space: nowrap;
}
.orders-page .order-amount {
    font-weight: 700;
    color: #222;
    font-size: 13px;
    white-space: nowrap;
}
.orders-page .order-status-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    background: #f0f0f0;
    color: #666;
}
.orders-page .order-time {
    color: #444;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.orders-page .orders-table td.col-order-no {
    line-height: 1.35;
    white-space: nowrap;
}
.orders-page .orders-table .order-no-value {
    color: #008c5e;
    font-weight: 500;
    display: inline;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 9px;
    line-height: 1.35;
}
.orders-page .orders-table .col-product {
    min-width: 220px;
    max-width: 420px;
}
.orders-page .product-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    min-width: 0;
}
.orders-page .product-title {
    flex: 1;
    min-width: 0;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    font-size: 13px;
}

.header-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { margin-left: 0; }
    .stats-row { grid-template-columns: 1fr 1fr; }
}
