:root {
  color-scheme: light;
  --ink: #172521;
  --muted: #687772;
  --line: #dfe8e5;
  --canvas: #f4f7f6;
  --surface: #ffffff;
  --surface-alt: #edf4f1;
  --brand: #087f8d;
  --brand-dark: #05616c;
  --brand-soft: #dff3f5;
  --blue: #2f69c8;
  --blue-soft: #e8f0fc;
  --amber: #a76408;
  --amber-soft: #fff0d6;
  --red: #b13c3c;
  --red-soft: #fce8e8;
  --violet: #7450b7;
  --violet-soft: #eee8fa;
  --shadow: 0 20px 55px rgba(27, 63, 54, .09);
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

.auth-gate { min-height: 100svh; display: grid; place-items: center; padding: 34px 18px; color: var(--ink); background: radial-gradient(circle at 50% 0, #e2f5f7 0, #f4f7f7 42%, #edf2f2 100%); }
.auth-wrap { width: min(440px, 100%); }
.auth-brand { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; margin-bottom: 20px; }
.hkhtax-logo { display: block; background: #fff url("assets/hkhtax-logo-original.jpg") center center / 100% auto no-repeat; }
.auth-brand-logo { width: 220px; height: 70px; border-radius: 12px; }
.auth-logo { width: 48px; height: 48px; display: grid; place-items: center; color: #fff; border-radius: 15px; background: linear-gradient(145deg, #12846f, #063d34); box-shadow: 0 12px 28px rgba(7, 88, 73, .2); }
.auth-logo svg { width: 27px; height: 27px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand strong { font-size: 18px; letter-spacing: -.025em; }
.auth-brand small { margin-top: 1px; color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: .16em; }
.auth-card { overflow: hidden; padding: 24px; border: 1px solid #d8e5e1; border-radius: 22px; background: rgba(255, 255, 255, .96); box-shadow: 0 28px 75px rgba(21, 65, 54, .12); }
.auth-card-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.auth-security-icon { width: 43px; height: 43px; display: grid; place-items: center; flex: 0 0 auto; color: var(--brand); border-radius: 13px; background: var(--brand-soft); }
.auth-security-icon svg { width: 22px; height: 22px; }
.auth-card h1 { margin: 0; font-size: 23px; }
.auth-card h2 { font-size: 18px; }
.auth-card-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 18px; padding: 4px; border-radius: 12px; background: var(--surface-alt); }
.auth-tabs button { min-height: 39px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 750; }
.auth-tabs button.is-active { color: var(--brand-dark); background: #fff; box-shadow: 0 4px 14px rgba(22, 70, 58, .08); }
.auth-form, .account-form { display: grid; gap: 13px; }
.auth-form label, .account-form label, .delete-confirm label { display: grid; gap: 6px; }
.auth-form label > span, .account-form label > span, .delete-confirm label > span { color: #53635e; font-size: 10px; font-weight: 700; }
.auth-form input, .account-form input, .delete-confirm input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid #d9e4e1; border-radius: 11px; outline: none; color: var(--ink); background: #fbfdfc; font-size: 13px; transition: border-color .15s ease, box-shadow .15s ease; }
.auth-form input:focus, .account-form input:focus, .delete-confirm input:focus { border-color: #69b9a7; box-shadow: 0 0 0 3px rgba(8, 113, 95, .1); }
.auth-submit { width: 100%; min-height: 47px; margin-top: 3px; }
.form-message { margin: 0; padding: 9px 11px; border-radius: 9px; color: var(--red); background: var(--red-soft); font-size: 10px; }
.form-message.success { color: var(--brand-dark); background: var(--brand-soft); }
.setup-note { display: flex; align-items: flex-start; gap: 9px; padding: 11px; border-radius: 11px; color: var(--brand-dark); background: var(--brand-soft); }
.setup-note svg { flex: 0 0 auto; }
.setup-note p { margin: 0; font-size: 10px; }
.auth-pending { padding: 8px 2px 2px; text-align: center; }
.auth-pending > span { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 13px; color: var(--amber); border-radius: 18px; background: var(--amber-soft); }
.auth-pending > span svg { width: 26px; height: 26px; }
.auth-pending h2 { margin-bottom: 7px; }
.auth-pending p { margin: 0 0 18px; color: var(--muted); font-size: 11px; }
.secondary-auth-button { min-height: 41px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font-size: 11px; font-weight: 700; }
.auth-footer { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 15px; color: var(--muted); font-size: 9px; }
.auth-footer button, .privacy-account-link, .privacy-back { padding: 0; border: 0; color: var(--brand); background: transparent; font-size: inherit; }
.privacy-card h1 { margin: 10px 0 15px; }
.privacy-card p { color: var(--muted); font-size: 11px; }
.privacy-back { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.privacy-back svg { width: 14px; transform: rotate(180deg); }
.privacy-delete-login { width: 100%; min-height: 45px; margin-top: 8px; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar); display: flex; flex-direction: column; padding: 22px 14px; color: #dce9ea; background: #073943; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 0 8px 22px; }
.sidebar-brand-logo { width: 174px; height: 55px; border-radius: 10px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; color: #0b342c; background: #67d0b8; border-radius: 12px; }
.brand-mark svg { width: 23px; height: 23px; stroke-width: 1.7; }
.brand-copy strong, .brand-copy small, .company-card strong, .company-card small, .sidebar-foot strong, .sidebar-foot small { display: block; }
.brand-copy strong { color: #fff; font-size: 17px; letter-spacing: -.02em; }
.brand-copy small { margin-top: -1px; color: #8db9c0; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.company-card { display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 24px; padding: 12px; border: 1px solid #23616d; border-radius: 12px; background: #0b4a55; }
.company-avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; color: #e1fbff; background: #0b7180; border-radius: 10px; font-size: 10px; font-weight: 750; }
.company-card div { min-width: 0; }
.company-card strong { overflow: hidden; color: #f5fbf9; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.company-card small { color: #8fb0a9; font-size: 10px; }
.nav-list { display: grid; gap: 5px; }
.nav-item { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border: 0; border-radius: 10px; color: #93b0aa; background: transparent; text-align: left; transition: background .18s ease, color .18s ease; }
.nav-item:hover { color: #f4fcfd; background: #0c4d58; }
.nav-item.is-active { color: #fff; background: #087f8d; box-shadow: inset 3px 0 0 #8ce5ec; }
.nav-item svg { width: 19px; height: 19px; }
.nav-item b { min-width: 28px; margin-left: auto; padding: 2px 6px; border-radius: 999px; color: #bfeadd; background: #28564c; font-size: 10px; font-weight: 650; text-align: center; }
.nav-item.is-active b { color: #0f4b3e; background: #a6e7d7; }
.nav-dot { width: 7px; height: 7px; margin-left: auto; border-radius: 50%; background: #f4bd66; box-shadow: 0 0 0 4px rgba(244, 189, 102, .11); }
.sidebar-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 15px 10px 2px; border-top: 1px solid #25473f; }
.connection-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #59d0ad; box-shadow: 0 0 0 4px rgba(89, 208, 173, .12); }
.sidebar-foot strong { color: #dbeae6; font-size: 11px; }
.sidebar-foot small { color: #7e9f98; font-size: 9px; }

.content-shell { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .9); backdrop-filter: blur(12px); }
.topbar-context span, .topbar-context strong { display: block; }
.topbar-context span { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.topbar-context strong { max-width: 520px; overflow: hidden; margin-top: 2px; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.data-date { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.data-date svg { width: 15px; height: 15px; }
.primary-button, .secondary-button, .icon-button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; }
.primary-button { padding: 0 14px; color: #fff; background: var(--brand); font-size: 12px; font-weight: 700; box-shadow: 0 8px 22px rgba(8, 113, 95, .2); }
.primary-button:hover { background: var(--brand-dark); }
.primary-button.is-loading svg { animation: spin .8s linear infinite; }
.install-button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 12px; border: 1px solid #b9ddd4; border-radius: 10px; color: var(--brand-dark); background: #eff9f6; font-size: 11px; font-weight: 750; }
.install-button:hover { border-color: #8ccabb; background: #e5f6f1; }
.install-button svg { width: 16px; height: 16px; }
.account-chip { min-height: 39px; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px 0 5px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fff; }
.account-chip span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--brand); font-size: 9px; font-weight: 800; }
.account-chip strong { max-width: 100px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { width: 39px; padding: 0; color: var(--ink); background: var(--surface-alt); }
.mobile-menu { display: none; }
.mobile-tabbar { display: none; }

.main-content { width: min(1440px, 100%); margin: 0 auto; padding: 28px; }
.page { animation: page-in .22s ease; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 5px; color: var(--brand); font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(24px, 2.5vw, 31px); line-height: 1.2; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 16px; line-height: 1.3; letter-spacing: -.015em; }
.page-heading p:last-child { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.verified-badge, .status-badge, .count-badge { min-height: 31px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 999px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.verified-badge, .status-badge.success { color: var(--brand-dark); background: var(--brand-soft); }
.verified-badge svg { width: 14px; height: 14px; stroke-width: 2.3; }
.status-badge.warning { color: var(--amber); background: var(--amber-soft); }
.count-badge { color: var(--blue); background: var(--blue-soft); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card { position: relative; min-width: 0; min-height: 145px; padding: 19px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 8px 25px rgba(28, 64, 55, .035); }
.metric-card.featured { border-color: #bfe1d8; background: linear-gradient(145deg, #eef9f6, #fff 70%); }
.metric-card p { margin: 0 46px 10px 0; color: var(--muted); font-size: 11px; }
.metric-card strong { display: block; overflow: hidden; font-size: clamp(20px, 2vw, 27px); letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.metric-card small { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; }
.metric-icon { position: absolute; top: 15px; right: 15px; width: 34px; height: 34px; display: grid; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 10px; }
.metric-icon.blue { color: var(--blue); background: var(--blue-soft); }
.metric-icon.amber { color: var(--amber); background: var(--amber-soft); }
.metric-icon.violet { color: var(--violet); background: var(--violet-soft); }

.panel { min-width: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 9px 26px rgba(28, 64, 55, .035); }
.panel-heading { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.panel-kicker { display: block; margin-bottom: 2px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(265px, .8fr); gap: 16px; margin-bottom: 16px; }
.chart-panel, .channel-panel { min-height: 310px; }
.chart-legend { display: flex; align-items: center; gap: 13px; color: var(--muted); font-size: 9px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 3px; background: var(--brand); }
.chart-legend i.return { background: var(--amber); }
.revenue-chart { min-height: 238px; padding: 13px 14px 8px; }
.revenue-chart svg { width: 100%; height: 225px; overflow: visible; }
.chart-grid-line { stroke: #e7eeec; stroke-width: 1; }
.chart-area { fill: url(#chart-gradient); stroke: none; }
.chart-line { fill: none; stroke: var(--brand); stroke-width: 2.4; }
.chart-return { fill: var(--amber); opacity: .72; }
.chart-dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.chart-label { fill: var(--muted); font-size: 9px; stroke: none; }
.chart-value { fill: var(--ink); font-size: 9px; font-weight: 700; stroke: none; }
.channel-list { display: grid; gap: 17px; padding: 20px 18px; }
.channel-row { display: grid; gap: 7px; }
.channel-top { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; }
.channel-top span { color: var(--muted); }
.channel-top strong { font-variant-numeric: tabular-nums; }
.channel-track { height: 7px; overflow: hidden; border-radius: 999px; background: var(--surface-alt); }
.channel-track i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.channel-row:nth-child(2) .channel-track i { background: var(--blue); }
.channel-row:nth-child(3) .channel-track i { background: var(--violet); }
.channel-row:nth-child(4) .channel-track i { background: var(--amber); }

.inventory-alert { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid #f2d8a9; border-radius: 13px; background: #fff8ea; }
.alert-icon { width: 37px; height: 37px; display: grid; place-items: center; color: var(--amber); background: var(--amber-soft); border-radius: 10px; }
.inventory-alert strong, .inventory-alert p { display: block; margin: 0; }
.inventory-alert strong { font-size: 12px; }
.inventory-alert p { margin-top: 3px; color: #846a3f; font-size: 10px; }
.inventory-alert.is-ready { border-color: #b9dfd5; background: #eef9f6; }
.inventory-alert.is-ready .alert-icon { color: var(--brand); background: var(--brand-soft); }
.inventory-alert.is-ready p { color: var(--muted); }
.text-button { display: inline-flex; align-items: center; gap: 3px; padding: 6px 0; border: 0; color: var(--brand); background: transparent; font-size: 11px; font-weight: 700; white-space: nowrap; }
.text-button svg { width: 14px; height: 14px; }

.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #f8faf9; font-size: 9px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdfc; }
td strong { display: block; font-size: 11px; }
td small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 999px; color: var(--brand-dark); background: var(--brand-soft); font-size: 9px; font-weight: 750; white-space: nowrap; }
.table-status.adjustment { color: var(--red); background: var(--red-soft); }
.table-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.filter-bar { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.search-field { min-width: 280px; height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.search-field.wide { width: min(480px, 100%); }
.search-field svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted); }
.search-field input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.filter-bar select { min-height: 42px; padding: 0 32px 0 11px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--surface); font-size: 11px; }
.no-top-radius { border-top-left-radius: 8px; border-top-right-radius: 8px; }
.inventory-table-panel { margin-bottom: 16px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 24px 2px 10px; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading h2 { margin-top: 4px; font-size: 18px; }
.section-heading p { margin-top: 5px; color: var(--muted); font-size: 11px; }
.service-table-panel { margin-bottom: 16px; border-color: #d9d9ef; }
.service-partner-admin { margin-bottom: 16px; padding: 18px; }
.service-partner-admin .panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.partner-rule-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 14px; }
.partner-rule-form select { min-width: 0; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.partner-rule-list { display: grid; gap: 8px; margin-top: 12px; }
.partner-rule { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-alt); }
.partner-rule strong, .partner-rule small { display: block; }
.partner-rule small { margin-top: 3px; color: var(--muted); }
.danger-text { color: var(--red); }
.empty-state.compact { padding: 12px; }
.stock-value-positive { color: var(--brand-dark); }
.stock-value-negative { color: var(--red); }
.stock-value-zero { color: var(--muted); }
.table-status.zero { color: var(--muted); background: var(--surface-alt); }
.table-status.negative { color: var(--red); background: var(--red-soft); }
.empty-state { padding: 34px; color: var(--muted); text-align: center; }

.readiness-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.readiness-card { position: relative; min-height: 116px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.readiness-card > span { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); background: var(--surface-alt); font-size: 11px; font-weight: 800; }
.readiness-card strong, .readiness-card p { display: block; margin: 0; }
.readiness-card strong { font-size: 12px; }
.readiness-card p { margin-top: 4px; color: var(--muted); font-size: 10px; }
.readiness-card > svg { color: var(--brand); }
.readiness-card > b { align-self: start; padding: 4px 7px; border-radius: 999px; color: var(--amber); background: var(--amber-soft); font-size: 8px; text-transform: uppercase; white-space: nowrap; }
.readiness-card.done { border-color: #bfe2d8; background: linear-gradient(145deg, #eff9f6, #fff); }
.readiness-card.done > span { color: var(--brand-dark); background: var(--brand-soft); }
.readiness-card.blocked > span { color: var(--red); background: var(--red-soft); }
.formula-panel { display: grid; grid-template-columns: 230px minmax(0, 1fr); align-items: center; gap: 18px; margin-bottom: 16px; padding: 22px; }
.formula-panel p { margin: 6px 0 0; color: var(--muted); font-size: 10px; }
.formula { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.formula span, .formula b { padding: 9px 10px; border-radius: 9px; background: var(--surface-alt); font-size: 10px; white-space: nowrap; }
.formula i { color: var(--muted); font-style: normal; font-weight: 800; }
.formula b { color: #fff; background: var(--brand); }
.checklist-panel ul { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.checklist-panel li { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.checklist-panel li:last-child { border-bottom: 0; }
.checklist-panel li::before { content: ""; width: 8px; height: 8px; flex: 0 0 auto; border: 2px solid #dfaa53; border-radius: 3px; }

.quality-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.quality-card { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.quality-card span { display: block; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.quality-card strong { display: block; margin-top: 7px; font-size: 22px; letter-spacing: -.03em; }
.quality-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.api-panel { margin-bottom: 16px; overflow: hidden; }
.endpoint-list { display: grid; }
.endpoint-list > div { display: grid; grid-template-columns: minmax(210px, .7fr) 1fr; gap: 20px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.endpoint-list > div:last-child { border-bottom: 0; }
.endpoint-list code { color: var(--brand-dark); font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; font-weight: 700; }
.endpoint-list span { color: var(--muted); font-size: 10px; }
.privacy-note { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid #bfdfd7; border-radius: 13px; background: #eef8f5; }
.privacy-note > svg { flex: 0 0 auto; color: var(--brand); }
.privacy-note strong, .privacy-note p { display: block; margin: 0; }
.privacy-note strong { font-size: 11px; }
.privacy-note p { margin-top: 3px; color: var(--muted); font-size: 10px; }

.logout-button { min-height: 37px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid #efc4c4; border-radius: 10px; color: var(--red); background: var(--red-soft); font-size: 10px; font-weight: 750; }
.logout-button svg { width: 16px; height: 16px; }
.account-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr); gap: 16px; margin-bottom: 16px; }
.profile-panel { min-height: 164px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: center; align-items: center; gap: 14px; padding: 20px; }
.profile-panel .status-badge { grid-column: 2; justify-self: start; }
.profile-avatar { width: 54px; height: 54px; display: grid; place-items: center; grid-row: 1 / span 2; color: #fff; border-radius: 17px; background: linear-gradient(145deg, #12846f, #063d34); font-size: 14px; font-weight: 800; }
.profile-panel h2 { margin: 2px 0 0; }
.profile-panel p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.password-panel { overflow: hidden; }
.account-form { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; padding: 16px 18px 18px; }
.account-form .form-message { grid-column: 1 / -1; }
.account-form .primary-button { justify-self: start; }
.admin-panel { margin-bottom: 16px; overflow: hidden; }
.portal-mode .tenant-only, .tenant-mode .portal-only { display: none !important; }
.portal-mode .company-card, .portal-mode #refresh-button, .portal-mode #data-date { display: none !important; }
.portal-mode .sidebar-foot strong::after { content: " HKHTAX"; }
.company-portal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.portal-company-card { display: grid; gap: 13px; min-height: 150px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; transition: transform .18s ease, border-color .18s ease; }
.portal-company-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.portal-company-card > span { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; border-radius: 12px; background: var(--company-color, var(--brand)); }
.portal-company-card > span svg { width: 21px; height: 21px; }
.portal-company-card strong, .portal-company-card small { display: block; }
.portal-company-card strong { font-size: 15px; letter-spacing: .02em; }
.portal-company-card small { color: var(--muted); font-size: 10px; }
.portal-company-card b { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); font-size: 10px; }
.company-portal-empty { margin-top: 14px; }
.company-admin-panel { margin-bottom: 16px; overflow: hidden; }
.company-admin-panel .panel-heading p { max-width: 720px; margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.company-form { display: grid; grid-template-columns: 1fr 1.5fr .55fr .55fr; gap: 12px; padding: 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #f8fbfb; }
.company-form label { display: grid; gap: 6px; }
.company-form label > span { color: #53635e; font-size: 10px; font-weight: 700; }
.company-form input, .company-form select, .membership-form select { width: 100%; min-height: 43px; padding: 0 12px; border: 1px solid #d9e4e3; border-radius: 10px; outline: 0; color: var(--ink); background: #fff; font-size: 11px; }
.company-form input:focus, .company-form select:focus, .membership-form select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.company-form input[type="color"] { padding: 5px; }
.company-form .wide-field { grid-column: span 2; }
.company-form .form-message { grid-column: 1 / -1; }
.company-form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.company-admin-list { display: grid; }
.company-admin-item { padding: 18px; border-bottom: 1px solid var(--line); }
.company-admin-item:last-child { border-bottom: 0; }
.company-admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.company-admin-head strong, .company-admin-head small { display: block; }
.company-admin-head strong { font-size: 12px; }
.company-admin-head small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.company-admin-actions { display: flex; gap: 7px; }
.company-admin-actions a, .company-admin-actions button { min-height: 32px; display: inline-flex; align-items: center; padding: 0 10px; border: 0; border-radius: 8px; color: var(--brand-dark); background: var(--brand-soft); font-size: 9px; font-weight: 750; text-decoration: none; }
.company-db-path { overflow: hidden; margin: 11px 0; padding: 9px 10px; border-radius: 9px; color: #48605f; background: #eef5f5; font: 9px/1.4 "SFMono-Regular", Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.membership-section { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, .8fr); gap: 12px; align-items: start; }
.membership-list { display: flex; flex-wrap: wrap; gap: 7px; }
.membership-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 999px; background: var(--surface-alt); font-size: 9px; }
.membership-chip button { width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; color: var(--red); background: #fff; }
.membership-form { display: grid; grid-template-columns: 1fr .7fr auto; gap: 7px; }
.membership-form button { min-height: 43px; }
.user-list { display: grid; }
.user-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(140px, .65fr) auto; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row strong, .user-row small { display: block; }
.user-row strong { font-size: 11px; }
.user-row small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.user-meta { color: var(--muted); font-size: 10px; }
.user-actions { display: flex; gap: 7px; }
.user-actions button { min-height: 32px; padding: 0 10px; border: 0; border-radius: 8px; font-size: 9px; font-weight: 750; }
.approve-user { color: #fff; background: var(--brand); }
.reject-user { color: var(--red); background: var(--red-soft); }
.user-status { display: inline-flex; justify-self: end; padding: 5px 8px; border-radius: 999px; color: var(--brand-dark); background: var(--brand-soft); font-size: 9px; font-weight: 750; }
.user-status.pending { color: var(--amber); background: var(--amber-soft); }
.user-status.rejected { color: var(--red); background: var(--red-soft); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 18px; border: 1px solid #efc6c6; border-radius: 14px; background: #fff7f7; }
.danger-zone strong, .danger-zone p { display: block; margin: 0; }
.danger-zone strong { color: var(--red); font-size: 12px; }
.danger-zone p { margin-top: 3px; color: var(--muted); font-size: 10px; }
.danger-zone button, .danger-button { min-height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 11px; border: 0; border-radius: 9px; color: #fff; background: var(--red); font-size: 10px; font-weight: 750; white-space: nowrap; }
.danger-zone button svg { width: 15px; height: 15px; }
.delete-confirm { max-width: 430px; display: grid; gap: 11px; margin-top: 10px; padding: 16px; border: 1px solid #efc6c6; border-radius: 14px; background: #fff; }
.delete-confirm > div { display: flex; justify-content: flex-end; gap: 8px; }
.privacy-account-link { margin-top: 14px; font-size: 10px; font-weight: 700; }

.loading-panel, .error-panel { min-height: 240px; display: flex; align-items: center; justify-content: center; gap: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.loading-panel strong { font-size: 12px; }
.spinner { width: 21px; height: 21px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.error-panel { justify-content: flex-start; padding: 24px; color: var(--red); }
.error-panel p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; display: flex; align-items: center; gap: 9px; padding: 12px 15px; border: 1px solid #b9dfd5; border-radius: 11px; color: var(--brand-dark); background: #f0faf7; box-shadow: var(--shadow); font-size: 11px; font-weight: 650; }
.toast svg { width: 16px; height: 16px; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(4, 20, 16, .42); backdrop-filter: blur(2px); }
.install-sheet-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(4, 20, 16, .52); backdrop-filter: blur(3px); }
.install-sheet { position: fixed; left: 50%; bottom: 18px; z-index: 60; width: min(430px, calc(100% - 28px)); padding: 10px 18px 18px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 30px 80px rgba(3, 26, 20, .28); transform: translateX(-50%); animation: sheet-in .22s ease; }
.install-sheet-handle { width: 38px; height: 4px; margin: 0 auto 14px; border-radius: 999px; background: #d5dfdc; }
.install-sheet-heading { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.install-sheet-heading strong, .install-sheet-heading small { display: block; }
.install-sheet-heading strong { font-size: 15px; }
.install-sheet-heading small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.install-app-icon { width: 48px; height: 48px; display: grid; place-items: center; color: #fff; border-radius: 14px; background: linear-gradient(145deg, #12846f, #063d34); }
.install-app-icon svg { width: 27px; height: 27px; }
.install-sheet ol { display: grid; gap: 11px; margin: 18px 0; padding: 0; list-style: none; }
.install-sheet li { display: flex; align-items: center; gap: 10px; }
.install-sheet li > span { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: var(--brand-dark); background: var(--brand-soft); font-size: 10px; font-weight: 800; }
.install-sheet li p { margin: 0; color: var(--muted); font-size: 11px; }
.install-sheet li strong { color: var(--ink); }
.inline-icon { width: 14px; height: 14px; vertical-align: -2px; }
.install-confirm { width: 100%; min-height: 45px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { opacity: 0; transform: translate(-50%, 18px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quality-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .channel-panel { min-height: 0; }
  .channel-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .company-portal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .company-form { grid-template-columns: 1fr 1fr; }
  .membership-section { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  :root { --sidebar: 232px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 18px 0 45px rgba(3, 22, 17, .24); }
  .sidebar.is-open { transform: translateX(0); }
  .content-shell { margin-left: 0; }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 0 18px; }
  .topbar-context { margin-right: auto; }
  .data-date { display: none; }
  .main-content { padding: 22px 18px; }
  .formula-panel { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .account-form { grid-template-columns: 1fr; }
  .company-form { grid-template-columns: 1fr; }
  .company-form .wide-field { grid-column: auto; }
}

@media (max-width: 620px) {
  body { padding-bottom: calc(69px + env(safe-area-inset-bottom)); }
  .topbar { height: calc(64px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0; gap: 10px; }
  .mobile-menu { display: none; }
  .topbar-context span { display: none; }
  .topbar-context strong { max-width: min(43vw, 170px); font-size: 10px; }
  .topbar-actions { gap: 7px; }
  .account-chip { width: 39px; padding: 0 5px; }
  .account-chip strong { display: none; }
  .install-button { width: 39px; padding: 0; }
  .install-button span { display: none; }
  .topbar .primary-button { width: 39px; padding: 0; }
  .topbar .primary-button span { display: none; }
  .main-content { padding: 18px 12px; }
  .page-heading { display: block; }
  .page-heading > :last-child { margin-top: 12px; }
  h1 { font-size: 25px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-grid .metric-card:first-child { grid-column: 1 / -1; }
  .quality-grid, .readiness-grid { grid-template-columns: 1fr; }
  .company-portal-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 120px; padding: 15px; }
  .metric-card p { margin-right: 34px; font-size: 10px; }
  .metric-card strong { font-size: 20px; }
  .metric-card small { font-size: 9px; }
  .metric-icon { top: 12px; right: 12px; width: 30px; height: 30px; }
  .metric-icon svg { width: 16px; height: 16px; }
  .channel-list { grid-template-columns: 1fr; }
  .inventory-alert { grid-template-columns: auto minmax(0, 1fr); }
  .inventory-alert .text-button { grid-column: 2; justify-self: start; }
  .partner-rule-form { grid-template-columns: 1fr; }
  .partner-rule { align-items: flex-start; flex-direction: column; }
  .filter-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; min-width: 0; width: 100%; }
  .filter-bar select { min-width: 0; width: 100%; }
  .endpoint-list > div { grid-template-columns: 1fr; gap: 4px; }
  .formula { justify-content: flex-start; }
  .chart-legend { display: none; }
  th, td { padding: 11px 12px; }
  .mobile-tabbar { position: fixed; inset: auto 0 0; z-index: 45; min-height: calc(64px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start; padding: 6px 5px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .96); box-shadow: 0 -10px 32px rgba(12, 53, 43, .08); backdrop-filter: blur(14px); }
  .portal-mode .mobile-tabbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-tab { min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 3px 1px; border: 0; border-radius: 10px; color: #778680; background: transparent; font-size: 8px; font-weight: 700; }
  .mobile-tab svg { width: 20px; height: 20px; }
  .mobile-tab.is-active { color: var(--brand); background: var(--brand-soft); }
  .toast { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); left: 12px; justify-content: center; }
  .install-sheet { bottom: calc(10px + env(safe-area-inset-bottom)); width: calc(100% - 20px); border-radius: 22px; }
  .auth-gate { padding: max(20px, env(safe-area-inset-top)) 12px max(20px, env(safe-area-inset-bottom)); }
  .auth-card { padding: 20px 17px; border-radius: 19px; }
  .auth-form input, .account-form input, .delete-confirm input { font-size: 16px; }
  .user-row { grid-template-columns: minmax(0, 1fr) auto; gap: 9px; padding: 13px 14px; }
  .user-meta { grid-column: 1; }
  .user-actions, .user-status { grid-column: 2; grid-row: 1 / span 2; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
  .danger-zone button { width: 100%; justify-content: center; }
  .profile-panel { min-height: 145px; }
  .company-admin-head { align-items: stretch; flex-direction: column; }
  .company-admin-actions { flex-wrap: wrap; }
  .membership-form { grid-template-columns: 1fr; }
  .mobile-tab { position: relative; }
  .mobile-tab > i { position: absolute; top: 5px; right: calc(50% - 17px); width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px #fff; }
}

@media (display-mode: standalone) and (max-width: 620px) {
  .topbar { background: rgba(255, 255, 255, .96); }
}
