/* TopShop Admin Base Styles — Theme, Topbar, Sidebar, Gate, Core Tables & KPIs */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand-blue: #00d2ff;
  --brand-dark: #0a1128;
  --brand-mid: #0e1a3a;
  --brand-border: #1e3a5f;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
}
body { font-family: var(--font-sans); background: var(--brand-dark); color: var(--text); min-height: 100vh; }

/* Accessible Focus Rings */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

/* Lock Gate */
body.locked { overflow: hidden; }
body.locked > *:not(#adminGate) { display: none !important; }
#adminGate { display: none; position: fixed; inset: 0; z-index: 9999; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at 50% 32%, #13254f 0%, var(--brand-dark) 62%); }
body.locked #adminGate { display: flex; }
.gate-card { width: 100%; max-width: 380px; text-align: center; background: var(--brand-mid); border: 1px solid var(--brand-border); border-radius: 16px; padding: 32px 28px; box-shadow: 0 24px 60px rgba(0,0,0,0.55); }
.gate-seal { font-size: 2.4rem; line-height: 1; color: var(--brand-blue); text-shadow: 0 0 26px rgba(0,210,255,0.45); font-weight: 800; }
.gate-title { font-size: 1.05rem; font-weight: 700; color: #fff; margin-top: 12px; }
.gate-sub { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.gate-input { width: 100%; padding: 12px 14px; text-align: center; letter-spacing: 0.18em; background: var(--brand-dark); border: 1px solid var(--brand-border); border-radius: 9px; color: var(--text); font-family: inherit; font-size: 1rem; }
.gate-input:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(0,210,255,0.15); }
.gate-btn { padding: 12px 14px; border: 0; border-radius: 9px; background: var(--brand-blue); color: #04121f; font-family: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: filter 0.15s; }
.gate-btn:hover { filter: brightness(1.08); }
.gate-btn:disabled { opacity: 0.55; cursor: default; }
.gate-error { min-height: 18px; font-size: 0.8rem; color: var(--red); }
.gate-back { display: inline-block; margin-top: 18px; font-size: 0.8rem; color: var(--muted); text-decoration: none; }
.gate-back:hover { color: var(--brand-blue); }
.gate-card.shake { animation: gateShake 0.4s; }
@keyframes gateShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
@media (prefers-reduced-motion: reduce) { .gate-card.shake { animation: none; } }

/* Topbar */
.topbar { background: var(--brand-mid); border-bottom: 1px solid var(--brand-border); padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 100; }
.topbar-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.topbar-seal { font-size: 1.55rem; font-weight: 800; color: var(--brand-blue); text-shadow: 0 0 18px rgba(0,210,255,0.5); flex-shrink: 0; }
.topbar-title { font-size: 1rem; font-weight: 700; color: #fff; white-space: nowrap; }
.topbar-sub { font-size: 0.72rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-store-info { font-size: 0.78rem; color: var(--muted); text-align: right; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; cursor: pointer; font-family: inherit; transition: border-color 0.2s, background 0.2s; }
.topbar-store-info:hover { border-color: var(--brand-border); background: rgba(255,255,255,0.04); }
.topbar-store-info.is-paused { color: #fbbf24; border-color: rgba(245,158,11,0.45); background: rgba(245,158,11,0.1); }
.btn-back { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; background: rgba(0,210,255,0.1); border: 1px solid var(--brand-blue); border-radius: 8px; color: var(--brand-blue); font-size: 0.82rem; font-weight: 600; text-decoration: none; cursor: pointer; transition: background 0.2s; white-space: nowrap; }
.btn-back:hover { background: rgba(0,210,255,0.2); }
.btn-lock { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; background: rgba(148,163,184,0.1); border: 1px solid var(--brand-border); border-radius: 8px; color: var(--muted); font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: color 0.2s, border-color 0.2s, background 0.2s; }
.btn-lock:hover { color: var(--orange); border-color: var(--orange); background: rgba(245,158,11,0.1); }
.btn-lang-adm { display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px; background: rgba(255,255,255,0.06); border: 1px solid var(--brand-border); border-radius: 8px; color: var(--text); font-family: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.btn-lang-adm:hover { border-color: var(--brand-blue); background: rgba(0,210,255,0.12); color: #fff; }
.cloud-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; border: 1px solid rgba(148,163,184,0.3); color: var(--muted); background: rgba(148,163,184,0.08); white-space: nowrap; }
.cloud-badge.online { border-color: rgba(34,197,94,0.45); color: #4ade80; background: rgba(34,197,94,0.12); }

/* Sidebar & Layout */
.admin-layout { display: flex; min-height: calc(100vh - 61px); }
.sidebar { width: 204px; background: var(--brand-mid); border-right: 1px solid var(--brand-border); padding: 16px 0; flex-shrink: 0; }
.nav-group-title { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; padding: 10px 18px 4px; }
.nav-item { display: flex; align-items: center; gap: 8px; width: 100%; background: transparent; border: 0; border-left: 3px solid transparent; padding: 9px 16px; color: var(--muted); cursor: pointer; font-family: inherit; font-size: 0.85rem; text-align: left; transition: all 0.15s; user-select: none; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-item.active { color: var(--brand-blue); border-left-color: var(--brand-blue); background: rgba(0,210,255,0.07); font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.nav-badge.green { background: var(--green); color: #04121f; }
.nav-badge.amber { background: var(--orange); color: #04121f; }
.nav-badge:empty { display: none; }
.main { flex: 1; min-width: 0; padding: 20px; overflow-y: auto; }

/* KPIs & Core Components */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 24px; }
@media (max-width: 1500px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-card { background: var(--brand-mid); border: 1px solid var(--brand-border); border-radius: 12px; padding: 18px; min-width: 0; }
.kpi-label { font-size: 0.77rem; color: var(--muted); margin-bottom: 8px; }
.kpi-value { font-size: 1.75rem; font-weight: 800; color: #fff; line-height: 1.15; }
.kpi-value.green { color: var(--green); }
.kpi-value.blue  { color: var(--brand-blue); }
.kpi-value.orange{ color: var(--orange); }
.kpi-delta { font-size: 0.76rem; margin-top: 6px; color: var(--green); }
.kpi-delta.neg { color: var(--red); }
.kpi-alt { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.kpi-value.flash { animation: kpi-flash 1.2s ease-out; }
@keyframes kpi-flash { 0% { color: #4ade80; transform: scale(1.12); } 100% { transform: scale(1); } }

.section-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title { font-size: 1rem; font-weight: 700; color: #fff; }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-input { background: var(--brand-dark); border: 1px solid var(--brand-border); border-radius: 8px; color: var(--text); font-family: inherit; font-size: 0.82rem; padding: 7px 11px; min-width: 150px; }
.admin-input:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(0,210,255,0.12); }
.admin-input[readonly] { color: var(--muted); cursor: default; }

.btn-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; background: var(--brand-blue); color: var(--brand-dark); border: none; border-radius: 8px; font-family: inherit; font-size: 0.81rem; font-weight: 700; cursor: pointer; transition: opacity 0.15s; white-space: nowrap; }
.btn-action:hover { opacity: 0.86; }
.btn-action.outline { background: transparent; color: var(--brand-blue); border: 1px solid var(--brand-blue); }
.btn-action.outline.on { background: var(--brand-blue); color: var(--brand-dark); }
.btn-action.danger { border-color: var(--red); color: var(--red); }
.btn-action.wa { border-color: #22c55e; color: #4ade80; }
.btn-action.vb { border-color: #a855f7; color: #c084fc; }
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-waybill { padding: 5px 9px; background: var(--green); color: #04121f; border: none; border-radius: 7px; font-family: inherit; font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: opacity 0.15s; white-space: nowrap; }
.btn-waybill:hover { opacity: 0.88; }
.btn-waybill:disabled { background: var(--brand-border); color: var(--muted); cursor: default; opacity: 1; }
.mini-btn { background: rgba(255,255,255,0.08); border: 1px solid var(--brand-border); border-radius: 7px; color: var(--text); padding: 5px 8px; cursor: pointer; font-size: 0.84rem; line-height: 1; }
.mini-btn:hover { background: rgba(255,255,255,0.16); }
.mini-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.mini-btn.danger:hover { background: rgba(239,68,68,0.25); border-color: var(--red); color: #fca5a5; }
.wb-edit-btn { margin-left: 6px; padding: 2px 6px; font-size: 0.72rem; border-radius: 5px; border: 1px solid var(--brand-border); background: rgba(255,255,255,0.06); color: var(--muted); cursor: pointer; }
.wb-edit-btn:hover { color: #fff; border-color: var(--brand-blue); }

/* Tables & Badges */
.table-wrap { background: var(--brand-mid); border: 1px solid var(--brand-border); border-radius: 12px; overflow-x: auto; overflow-y: hidden; margin-bottom: 24px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.69rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); background: rgba(255,255,255,0.03); padding: 9px 8px; border-bottom: 1px solid var(--brand-border); white-space: normal; line-height: 1.25; }
td { padding: 9px 8px; font-size: 0.82rem; border-bottom: 1px solid rgba(30,58,95,0.5); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.nowrap, .cell-amount, .cell-id { white-space: nowrap; }
tr:hover td { background: rgba(255,255,255,0.02); }
tr.is-new td { background: rgba(0,210,255,0.04); }
tr.is-live td { background: rgba(34,197,94,0.07); }
tr.row-low td { background: rgba(245,158,11,0.05); }
tr.row-out td { background: rgba(239,68,68,0.06); }
.empty-row { text-align: center; color: var(--muted); padding: 28px !important; }

.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 0.74rem; font-weight: 700; white-space: nowrap; }
.status-badge.new      { background: rgba(0,210,255,0.15); color: var(--brand-blue); }
.status-badge.shipped  { background: rgba(34,197,94,0.15);  color: var(--green); }
.status-badge.pending  { background: rgba(245,158,11,0.15); color: var(--orange); }
.status-badge.returned { background: rgba(239,68,68,0.15);  color: var(--red); }

.courier-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; font-size: 0.74rem; font-weight: 600; }
.courier-tag.speedy { background: rgba(234,179,8,0.15); color: #facc15; }
.courier-tag.econt  { background: rgba(59,130,246,0.15); color: #60a5fa; }
.courier-tag.store  { background: rgba(34,197,94,0.15); color: var(--green); }
.courier-tag.local  { background: rgba(168,85,247,0.16); color: #c084fc; }
.channel-pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 12px; font-size: 0.66rem; font-weight: 700; margin-top: 4px; background: rgba(168,85,247,0.16); color: #d8b4fe; border: 1px solid rgba(168,85,247,0.3); }
.flag-warn-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; font-size: 0.68rem; font-weight: 700; margin-top: 4px; background: rgba(239,68,68,0.18); color: #f87171; border: 1px solid var(--red); white-space: nowrap; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 0.66rem; font-weight: 800; background: rgba(34,197,94,0.16); color: var(--green); letter-spacing: 0.05em; text-transform: uppercase; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: live-blink 1.6s ease-in-out infinite; }
@keyframes live-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.2; } }
.art-chip { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-size: 0.72rem; font-weight: 700; color: var(--brand-blue); background: rgba(0,210,255,0.1); border: 1px solid rgba(0,210,255,0.25); border-radius: 5px; padding: 0 5px; margin-right: 5px; }
.test-flag { display: inline-block; margin-top: 3px; font-size: 0.68rem; font-weight: 700; color: var(--orange); }
.order-id-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--brand-blue); cursor: pointer; text-align: left; }
.order-id-link:hover { text-decoration: underline; }
.order-note-tag { display: inline-block; margin-left: 5px; font-size: 0.72rem; color: var(--orange); vertical-align: middle; }
.row-actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.note-line { font-size: 0.78rem; color: var(--muted); line-height: 1.55; margin: -12px 0 22px; }
.note-line code { font-family: ui-monospace, Consolas, monospace; color: var(--brand-blue); }

.toast { position: fixed; bottom: 24px; right: 24px; background: #0f2a1a; border: 1px solid var(--green); border-radius: 12px; padding: 13px 18px; color: var(--green); font-size: 0.88rem; font-weight: 600; display: flex; align-items: center; gap: 10px; z-index: 1200; transform: translateY(calc(100% + 40px)); visibility: hidden; pointer-events: none; transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s; max-width: 390px; }
.toast.show { transform: translateY(0); visibility: visible; pointer-events: auto; }

@media (max-width: 1100px) {
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .topbar-title { white-space: normal; }
  .admin-layout { flex-direction: column; min-height: 0; }
  .sidebar { display: flex; flex-direction: row; width: auto; padding: 0 6px; overflow-x: auto; overflow-y: hidden; border-right: none; border-bottom: 1px solid var(--brand-border); scrollbar-width: thin; -webkit-overflow-scrolling: touch; scroll-padding-inline: 14px; }
  .sidebar::-webkit-scrollbar { height: 4px; }
  .sidebar::-webkit-scrollbar-thumb { background: var(--brand-border); border-radius: 4px; }
  .nav-group-title { display: none; }
  .nav-item { width: auto; white-space: nowrap; flex: 0 0 auto; padding: 12px 14px; font-size: 0.84rem; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-item.active { border-left-color: transparent; border-bottom-color: var(--brand-blue); }
  .nav-badge { margin-left: 6px; }
}
@media (max-width: 720px) {
  .kpi-grid-4, .kpi-grid-3 { grid-template-columns: 1fr; }
  .filter-row { width: 100%; }
  .filter-row > .admin-input, .section-header > .admin-input { flex: 1 1 100%; width: 100%; max-width: 100%; min-width: 0; }
  .filter-row > .pe-check, .filter-row > .settings-toggle-check { flex: 1 1 100%; padding: 4px 0; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .topbar-brand { min-width: 0; flex: 1 1 auto; }
  .topbar-title { font-size: 0.96rem; white-space: normal; }
  .topbar-sub { display: none; }
  .topbar-actions { gap: 6px; flex: 1 1 100%; justify-content: space-between; }
  .topbar-store-info { text-align: left; font-size: 0.74rem; padding: 3px 6px; }
  .btn-lock { padding: 8px 10px; }
  .btn-lock .btn-lock-text { display: none; }
  .main { padding: 14px 12px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 13px; }
  .kpi-value { font-size: 1.4rem; }
  .hide-mobile { display: none; }
  .filter-row .btn-action { white-space: normal; text-align: center; flex: 1 1 auto; min-height: 38px; }
}
