:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dfe5ee;
  --text: #1d2433;
  --muted: #687385;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --soft: #eef4ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px;
  background: linear-gradient(135deg, #eff6ff 0%, #f7fafc 44%, #eefdf5 100%);
}

.login-panel {
  width: 420px;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(30, 41, 59, .10);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: var(--primary);
}

.brand-mark.small {
  width: 40px;
  height: 40px;
}

.login-panel h1,
.topbar h1,
.panel-title h2 {
  margin: 0;
}

.login-panel p,
.topbar p,
.panel-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-form,
.account-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: white;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 260px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid var(--line);
  background: #101827;
  color: white;
}

.side-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.side-head span {
  display: block;
  margin-top: 4px;
  color: #aab6ca;
  font-size: 13px;
}

.side-nav {
  display: grid;
  gap: 10px;
}

.side-nav button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #dbe7ff;
  background: transparent;
  font-size: 15px;
}

.side-nav button.active {
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.10);
}

.region-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.region-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: white;
}

.region-pill.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--soft);
}

.region-pill em {
  font-style: normal;
  color: var(--success);
  font-size: 12px;
}

.region-pill em.paused {
  color: var(--danger);
}

.workspace {
  flex: 1;
  padding: 28px;
}

.topbar,
.panel-title,
.metrics,
.call-actions,
.inline-form,
.top-actions,
.bind-list > div,
.simple-list li {
  display: flex;
  align-items: center;
}

.topbar,
.panel-title,
.metrics,
.top-actions,
.bind-list > div,
.simple-list li {
  justify-content: space-between;
}

.top-actions {
  gap: 10px;
}

.notice {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #fde68a;
  border-radius: 6px;
  color: #92400e;
  background: #fffbeb;
}

.notice.danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

.metrics {
  gap: 16px;
  margin: 22px 0;
}

.metrics article,
.call-panel,
.queue-panel,
.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metrics article {
  flex: 1;
  min-height: 92px;
  padding: 18px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.main-grid {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
}

.call-panel,
.queue-panel,
.settings-card {
  padding: 20px;
}

.history-panel {
  grid-column: 1 / -1;
}

.history-groups {
  display: grid;
  gap: 14px;
}

.history-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin: 14px 0 4px;
}

.history-filter {
  margin: 0;
}

.history-date-filter {
  width: 164px;
}

.history-plate-filter {
  width: 200px;
}

.history-date {
  margin: 14px 0 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.history-head,
.history-row {
  grid-template-columns: .7fr 1fr .8fr 1.4fr 1.4fr;
}

.panel-title.compact h2 {
  font-size: 18px;
}

.panel-title.compact span {
  color: var(--muted);
  font-size: 14px;
}

.current-number {
  margin: 26px 0;
  padding: 34px 20px;
  border-radius: 8px;
  text-align: center;
  background: var(--soft);
}

.current-number span {
  display: block;
  font-size: 46px;
  font-weight: 800;
  color: var(--primary);
}

.current-number small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.call-actions {
  gap: 10px;
}

.primary-btn,
.plain-btn,
.ghost-btn,
.toggle-btn,
.save-btn,
.danger-btn {
  height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-size: 14px;
}

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

.primary-btn:hover {
  background: var(--primary-dark);
}

.save-btn {
  min-width: 104px;
  color: white;
  font-weight: 700;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .18);
}

.save-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .24);
}

.save-btn.compact {
  min-width: 72px;
  height: 36px;
  padding: 0 14px;
  box-shadow: none;
  white-space: nowrap;
}

.primary-btn.large {
  flex: 1;
  height: 52px;
  font-size: 17px;
  font-weight: 700;
}

.plain-btn,
.toggle-btn {
  border-color: var(--line);
  color: var(--text);
  background: white;
}

.danger-btn {
  height: 36px;
  padding: 0 14px;
  border-color: #fecaca;
  color: var(--danger);
  background: #fff;
}

.danger-btn:hover {
  border-color: var(--danger);
  background: #fef2f2;
}

.toggle-btn.danger {
  color: white;
  border-color: var(--danger);
  background: var(--danger);
}

.ghost-btn {
  border-color: var(--line);
  color: var(--text);
  background: transparent;
}

.ghost-btn.full {
  margin-top: auto;
  width: 100%;
  color: #dbe7ff;
  border-color: rgba(255,255,255,.18);
}

.table {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.thead,
.row {
  display: grid;
  grid-template-columns: .8fr 1fr .9fr 1.5fr 1.2fr 1.5fr;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
}

.thead {
  color: var(--muted);
  font-size: 13px;
  background: #f8fafc;
}

.row + .row {
  border-top: 1px solid var(--line);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
}

.status {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.status.waiting {
  background: var(--warning);
}

.status.called {
  background: var(--primary);
}

.status.skipped {
  background: var(--danger);
}

.status.completed {
  background: var(--success);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.empty {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.settings-card.wide {
  grid-column: 1 / -1;
}

.settings-tabs {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  border-bottom: 1px solid var(--line);
}

.settings-tabs button {
  min-width: 96px;
  height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
}

.settings-tabs button.active {
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 700;
}

.settings-stack {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.inline-form {
  gap: 10px;
  margin-top: 16px;
}

.region-form {
  display: grid;
  grid-template-columns: 110px 1fr 1.4fr auto auto;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.printer-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.printer-form button {
  width: fit-content;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
  padding-top: 2px;
}

.business-switch {
  grid-column: 1 / -1;
}

.business-hours-form {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  align-items: end;
}

.business-hours-form .business-switch,
.business-hours-form .business-message-field,
.business-hours-form .form-actions {
  grid-column: 1 / -1;
}

.business-hours-form input[type="time"] {
  width: 100%;
}

.edit-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.edit-row {
  display: grid;
  grid-template-columns: 64px 150px minmax(240px, 1fr) 82px 82px 78px;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 6px;
  background: #f8fafc;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.switch-line input {
  width: 16px;
  height: 16px;
}

.switch-line span {
  margin: 0;
  color: var(--text);
  white-space: nowrap;
}

.compact-switch {
  justify-content: center;
}

.account-form.split {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

.account-form.split .checks {
  grid-column: 1 / -1;
}

.account-form.split button {
  width: fit-content;
}

.account-edit-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.account-edit-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.account-edit-main {
  display: grid;
  grid-template-columns: 1fr 1fr 150px 180px;
  gap: 10px;
}

.account-region-checks {
  padding: 0;
}

.account-edit-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-edit-footer > span {
  color: var(--muted);
  font-size: 13px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-actions .save-btn,
.account-actions .danger-btn {
  min-width: 76px;
  height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 700;
}

.account-actions .save-btn {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 6px 14px rgba(37, 99, 235, .16);
}

.account-actions .save-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
}

.account-actions .danger-btn {
  border-color: #fecaca;
  color: var(--danger);
  background: #fff5f5;
}

.account-actions .danger-btn:hover {
  border-color: var(--danger);
  background: #fee2e2;
}

.account-actions .danger-btn:disabled {
  color: #b6bfcc;
  border-color: var(--line);
  background: #f1f5f9;
  opacity: 1;
}

.bind-list,
.simple-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.bind-list > div,
.simple-list li {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #f8fafc;
}

.bind-list select {
  width: 180px;
}

.simple-list em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.simple-list strong {
  margin-right: 8px;
}

.danger-text {
  color: var(--danger) !important;
}

.badge {
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--success);
  background: #ecfdf5;
  font-size: 13px;
}

.transfer-select {
  height: 32px;
  padding: 0 8px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.checks input {
  width: 16px;
  height: 16px;
}

.checks span {
  margin: 0;
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  min-width: 220px;
  padding: 12px 18px;
  border-radius: 8px;
  color: white;
  text-align: center;
  background: rgba(15, 23, 42, .92);
  box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
}
