:root {
  --ink: #202020;
  --muted: #6f6f73;
  --paper: #f3f3f3;
  --card: #ffffff;
  --line: #ececef;
  --green: #2f8126;
  --green-dark: #24681d;
  --purple: #9a57ff;
  --purple-dark: #7130d0;
  --lime: #d6ff75;
  --amber: #d89013;
  --red: #ec3f35;
  --shadow: 0 10px 30px rgba(28, 28, 31, .035);
  font-family: Inter, Arial, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input { font: inherit; }
button { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.75rem, 3.2vw, 2.6rem); letter-spacing: -.04em; line-height: 1; }
h2 { margin-bottom: 0; font-size: 1.08rem; letter-spacing: -.02em; }

.topbar { height: 76px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .96); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(16px); }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 11px; font-weight: 750; }
.brand-mark { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: linear-gradient(145deg, #d130ef 0%, #9b35e5 45%, #42106f 100%); color: white; font-weight: 900; letter-spacing: -.05em; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 12px; font-size: .82rem; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.refresh-state { font-size: .76rem; color: var(--muted); }

.app-shell { min-height: calc(100vh - 76px); display: grid; grid-template-columns: 150px minmax(0, 1fr); max-width: none; margin: 0; }
.tabs { display: flex; flex-direction: column; overflow-y: auto; border-right: 1px solid var(--line); gap: 6px; padding: 20px 10px; background: white; scrollbar-width: none; }
.tab { border: 0; border-radius: 26px; background: transparent; padding: 13px 12px; white-space: nowrap; cursor: pointer; font-weight: 650; text-align: left; color: var(--muted); }
.tab:hover { color: var(--ink); background: #f5f5f5; }
.tab.active { color: white; background: var(--ink); }
.content { min-width: 0; padding: 24px clamp(16px, 2.5vw, 36px) 44px; }
.panel { display: none; padding-top: 0; }
.panel.active { display: block; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 22px; margin-bottom: 20px; }
.eyebrow { margin-bottom: 8px; color: var(--purple); text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; font-weight: 850; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .88rem; margin: -14px 0 20px; }

.button, .chip { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 8px 12px; cursor: pointer; font-weight: 700; transition: .15s ease; }
.button:hover, .chip:hover { border-color: var(--purple); transform: translateY(-1px); }
.button.primary { background: var(--purple); border-color: var(--purple); color: white; }
.button.primary:hover { background: var(--purple-dark); }
.button.ghost { background: transparent; }
.button.compact { padding: 8px 12px; }
.button.danger { color: var(--red); }
.chip { padding: 7px 11px; border-radius: 26px; font-size: .8rem; }
.chip.active { color: white; border-color: var(--purple); background: var(--purple); }
.report-view-switch { display: flex; gap: 7px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.period-controls { display: flex; flex-direction: column; align-items: end; gap: 8px; }
.preset-group, .date-range, .action-row { display: flex; align-items: center; gap: 8px; }
input { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 7px 9px; color: var(--ink); min-width: 0; }
input:focus { outline: 3px solid rgba(154, 87, 255, .14); border-color: var(--purple); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; margin-bottom: 11px; }
.employee-metrics { grid-template-columns: repeat(5, 1fr); }
.metric { min-height: 118px; border: 1px solid var(--line); background: var(--card); padding: 17px; display: flex; flex-direction: column; border-radius: 22px; }
.metric.featured { color: white; background: var(--ink); border-color: var(--ink); }
.metric span { color: var(--muted); font-size: .82rem; font-weight: 700; }
.metric.featured span, .metric.featured small { color: #d9d9dc; }
.metric strong { font-size: clamp(1.65rem, 2.5vw, 2.45rem); letter-spacing: -.05em; margin: auto 0 2px; }
.metric small { color: var(--muted); }
.payout-metric { min-height: 142px; }
.payout-lines { display: grid; gap: 5px; margin: auto 0 4px; }
.payout-lines div { display: grid; grid-template-columns: 72px 1fr; align-items: baseline; gap: 7px; }
.payout-lines div small { color: #d9d9dc; font-weight: 700; }
.payout-lines strong { margin: 0; font-size: clamp(1.2rem, 1.8vw, 1.75rem); text-align: right; }

.report-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 11px; margin-bottom: 11px; }
.card { border: 1px solid var(--line); background: var(--card); border-radius: 26px; box-shadow: var(--shadow); overflow: hidden; }
.card-head { min-height: 52px; padding: 14px 17px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.card-head .muted { font-size: .75rem; }
.breakdown { display: grid; grid-template-columns: 1fr 1fr; }
.breakdown-row { padding: 12px 17px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; }
.breakdown-row:nth-child(odd) { border-right: 1px solid var(--line); }
.breakdown-row:nth-last-child(-n+2) { border-bottom: 0; }
.breakdown-row strong { font-size: .9rem; }
.breakdown-row span { color: var(--muted); font-size: .77rem; }
.breakdown-row b { grid-row: span 2; align-self: center; font-size: 1.05rem; }
.rank-list { min-height: 180px; }
.rank-row { padding: 11px 17px; display: grid; grid-template-columns: 24px 1fr auto; gap: 9px; align-items: center; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-number { color: var(--muted); font-size: .75rem; }
.rank-row small { display: block; color: var(--muted); margin-top: 3px; }
.empty-state { color: var(--muted); display: grid; place-items: center; }

.table-card { margin-top: 11px; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--line); font-size: .8rem; vertical-align: top; }
th { color: var(--muted); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; background: #fafafa; }
tbody tr:last-child td { border-bottom: 0; }
td.number, th.number { text-align: right; }
.table-actions { display: flex; justify-content: end; gap: 6px; }
.table-actions .button { padding: 6px 9px; font-size: .76rem; }
.status { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; padding: 5px 9px; background: #e8f3e6; color: var(--green); font-size: .72rem; font-weight: 750; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.offline, .status.rejected, .status.blocked { color: var(--red); background: #f8e8e4; }
.status.unknown { color: #806316; background: #f7edcf; }
.status.closed { color: var(--purple-dark); background: #f0e7ff; }
.box-row, .task-row, .performance-row { cursor: pointer; transition: background .15s ease; }
.box-row:hover, .box-row:focus, .task-row:hover, .task-row:focus, .performance-row:hover, .performance-row:focus { background: #f7f1ff; outline: none; }
.employee-report-controls { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 14px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 20px; background: white; }
.employee-report-controls .eyebrow { margin-bottom: 4px; }
.employee-report-controls .muted { font-size: .78rem; }
.employee-chart-card { margin-bottom: 11px; }
.employee-chart-legend { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px 16px; color: var(--muted); font-size: .74rem; }
.employee-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.employee-chart-legend span::before { content: ""; width: 16px; height: 3px; border-radius: 3px; background: var(--chart-color); box-shadow: 0 0 0 2px white, 0 0 0 3px var(--chart-color); }
.employee-operations-chart { min-height: 300px; padding: 4px 14px 10px; overflow-x: auto; }
.employee-operations-chart svg { display: block; width: 100%; min-width: 720px; height: auto; }
.chart-grid { stroke: #ececef; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis-label { fill: var(--muted); font-size: 11px; }
.chart-axis-title { fill: var(--muted); font-size: 12px; font-weight: 700; }
.employee-chart-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-point { cursor: help; stroke: white; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.employee-chart-empty { min-height: 300px; }

.enrollment-card { background: var(--green); color: white; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px; margin-bottom: 13px; border-radius: 24px; }
.enrollment-card .eyebrow { color: var(--lime); }
.enrollment-card p { color: #d4e9df; }
.enrollment-card code { display: block; max-width: 650px; overflow-wrap: anywhere; font-size: .75rem; }
.enrollment-card img { background: white; padding: 10px; border-radius: 6px; }
.hidden { display: none !important; }
.application-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 26px; padding: 22px; margin-bottom: 13px; color: white; background: linear-gradient(135deg, var(--purple), var(--purple-dark)); border-radius: 26px; box-shadow: var(--shadow); }
.application-copy { max-width: 760px; }
.application-copy .eyebrow { color: white; }
.application-copy h2 { font-size: clamp(1.3rem, 2.5vw, 1.95rem); margin-bottom: 9px; }
.application-copy p:not(.eyebrow) { color: #d4e9df; line-height: 1.55; }
.application-copy .button { text-decoration: none; background: var(--lime); border-color: var(--lime); color: var(--green-dark); }
.application-copy code { max-width: min(520px, 100%); overflow-wrap: anywhere; color: #d4e9df; font-size: .72rem; }
.application-qr { display: grid; justify-items: center; gap: 8px; color: #d4e9df; font-size: .72rem; }
.application-qr img { padding: 9px; background: white; border-radius: 6px; }
.device-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.device-card { padding: 17px; border: 1px solid var(--line); background: var(--card); border-radius: 23px; }
.device-card-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.device-card dl { display: grid; grid-template-columns: 1fr auto; margin: 0; gap: 11px; font-size: .82rem; }
.device-card dt { color: var(--muted); }
.device-card dd { margin: 0; text-align: right; }

.notice { border-left: 4px solid var(--amber); background: #fff7df; padding: 11px 13px; margin: -6px 0 16px; font-size: .84rem; }
.tariff-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tariff-item { border: 1px solid var(--line); background: var(--card); padding: 14px; border-radius: 18px; display: grid; grid-template-columns: 1fr 125px; gap: 10px; align-items: center; }
.tariff-item label { font-weight: 700; }
.tariff-section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 19px 2px 10px; }
.tariff-section-head h2 { margin: 2px 0 0; }
.employee-tariffs-card { margin-top: 18px; padding-bottom: 2px; }
.employee-tariff-head select { min-width: 230px; }
.employee-tariff-notice { margin: 0 17px 12px; }
.employee-tariffs-card .tariff-grid { padding: 0 17px; }
.tariff-source { display: block; margin-top: 3px; color: var(--muted); font-size: .68rem; font-weight: 500; }
.tariff-source.custom { color: var(--purple-dark); font-weight: 750; }
.tariff-actions { padding-right: 17px; }
.employee-tariff-empty { min-height: 100px; grid-column: 1 / -1; }
.money-input { display: flex; align-items: center; gap: 7px; }
.money-input input { width: 100%; text-align: right; }
.form-footer { margin-top: 16px; display: flex; justify-content: end; }

.instruction-lead { display: grid; grid-template-columns: minmax(220px, .7fr) 1.3fr; align-items: center; gap: 22px; padding: 20px 22px; margin-bottom: 12px; color: white; background: var(--ink); border-radius: 26px; }
.instruction-lead .eyebrow { color: var(--lime); }
.instruction-checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.instruction-checks span { min-height: 62px; display: flex; align-items: center; padding: 13px 15px 13px 34px; position: relative; background: rgba(255, 255, 255, .08); border-radius: 17px; font-size: .8rem; font-weight: 750; }
.instruction-checks span::before { content: ""; width: 9px; height: 9px; position: absolute; left: 15px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(214, 255, 117, .12); }
.instruction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.instruction-card { display: grid; grid-template-columns: 48px 1fr; gap: 15px; padding: 20px; border: 1px solid var(--line); background: var(--card); border-radius: 26px; box-shadow: var(--shadow); }
.instruction-number { width: 48px; height: 48px; display: grid; place-items: center; color: white; background: var(--purple); border-radius: 15px; font-weight: 850; }
.instruction-card h2 { margin-bottom: 13px; font-size: 1.2rem; }
.instruction-card code { padding: 2px 5px; color: var(--purple-dark); background: #f3ebff; border-radius: 5px; font-size: .82em; }
.instruction-list { margin: 0; padding-left: 20px; color: #404044; line-height: 1.55; }
.instruction-list li { padding-left: 4px; margin-bottom: 8px; }
.instruction-list li:last-child { margin-bottom: 0; }
.instruction-list li::marker { color: var(--purple); font-weight: 850; }
.instruction-copy { color: var(--muted); line-height: 1.55; }
.instruction-warning { margin-top: 14px; padding: 11px 13px; color: #76540c; background: #fff7df; border-left: 4px solid var(--amber); border-radius: 0 12px 12px 0; font-size: .82rem; line-height: 1.5; }
.instruction-footer { display: grid; grid-template-columns: .75fr 1.25fr; gap: 24px; padding: 21px 23px; margin-top: 12px; border: 1px solid #ddd0ef; background: #f8f2ff; border-radius: 26px; }
.compact-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 25px; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 30px)); background: var(--ink); color: white; border-radius: 9px; padding: 13px 17px; box-shadow: var(--shadow); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s ease; z-index: 30; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--red); }

.box-dialog { width: min(1020px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); padding: 0; overflow-y: auto; color: var(--ink); background: white; border: 0; border-radius: 26px; box-shadow: 0 30px 100px rgba(27, 20, 38, .22); }
.box-dialog::backdrop { background: rgba(24, 22, 28, .48); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.box-dialog-meta { display: flex; flex-wrap: wrap; gap: 9px 22px; padding: 13px 21px; background: #faf8fd; color: var(--muted); font-size: .8rem; }
.box-dialog .table-scroll { max-height: 520px; }
.box-dialog .box-detail-head { padding-top: 17px; padding-bottom: 9px; }
.box-dialog .box-history-scroll { max-height: 235px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #b55cff, #4a147c); }
.login-card { width: min(390px, 100%); background: var(--card); padding: clamp(24px, 6vw, 38px); border-radius: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .22); }
.login-card .brand-mark { margin-bottom: 22px; }
.login-card h1 { font-size: 2.15rem; margin-bottom: 10px; }
.login-card .site-label { color: var(--purple); font-size: 1.15rem; font-weight: 800; margin: -2px 0 10px; }
.stack-form { display: grid; gap: 13px; margin-top: 21px; }
.stack-form label { display: grid; gap: 7px; font-size: .78rem; font-weight: 750; }
.stack-form input { padding: 12px; }
.alert { background: #f8e8e4; color: #8c3026; padding: 11px 13px; border-radius: 7px; margin-top: 18px; font-size: .84rem; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 120px minmax(0, 1fr); }
  .tab { padding: 12px 9px; font-size: .78rem; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .device-grid { grid-template-columns: 1fr 1fr; }
  .instruction-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar { height: 62px; padding: 0 13px; }
  .brand > span:last-child, .refresh-state { display: none; }
  .brand-mark.small { width: 38px; height: 38px; }
  .app-shell { min-height: calc(100vh - 62px); display: block; }
  .tabs { position: sticky; top: 62px; z-index: 9; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px 8px; }
  .tab { padding: 9px 12px; font-size: .78rem; text-align: center; }
  .content { padding: 18px 8px 30px; }
  .panel { padding-top: 0; }
  .section-head { align-items: stretch; flex-direction: column; gap: 16px; }
  .employee-report-controls { align-items: stretch; flex-direction: column; }
  .period-controls { align-items: stretch; }
  .preset-group { overflow-x: auto; }
  .date-range { flex-wrap: wrap; }
  .date-range input { flex: 1; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { min-height: 104px; padding: 14px; }
  .metric strong { font-size: 1.7rem; }
  .breakdown { grid-template-columns: 1fr; }
  .breakdown-row:nth-child(odd) { border-right: 0; }
  .breakdown-row:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .device-grid, .tariff-grid { grid-template-columns: 1fr; }
  .enrollment-card { flex-direction: column; align-items: start; }
  .enrollment-card img { align-self: center; width: min(220px, 100%); height: auto; }
  .application-card { grid-template-columns: 1fr; }
  .application-card .action-row { align-items: start; flex-direction: column; }
  .application-qr { justify-self: center; }
  .application-qr img { width: min(190px, 100%); height: auto; }
  .action-row { flex-wrap: wrap; }
  .tariff-item { grid-template-columns: 1fr 120px; }
  .box-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); border-radius: 22px; }
  .instruction-lead, .instruction-footer { grid-template-columns: 1fr; }
  .instruction-checks { grid-template-columns: 1fr; }
  .instruction-card { grid-template-columns: 40px 1fr; padding: 16px; }
  .instruction-number { width: 40px; height: 40px; border-radius: 12px; }
  .compact-list { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 112px; }
}
