:root {
  color-scheme: dark;
  --background: #0a0d14;
  --surface: rgba(20, 25, 38, 0.92);
  --surface-soft: rgba(31, 38, 55, 0.72);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(129, 140, 248, 0.48);
  --text: #f5f7fb;
  --muted: #9aa6bd;
  --accent: #7c83ff;
  --accent-strong: #6269f4;
  --success: #50d7a1;
  --danger: #ff718a;
  --warning: #f6c86f;
  --radius-lg: 24px;
  --radius-md: 14px;
  --shadow: 0 32px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 15%, rgba(82, 90, 255, 0.2), transparent 32rem),
    radial-gradient(circle at 88% 85%, rgba(47, 196, 154, 0.12), transparent 30rem),
    var(--background);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.auth-card {
  width: min(460px, 100%);
  padding: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card h1 {
  font-size: clamp(2rem, 7vw, 3.3rem);
}

.auth-card .page-description {
  margin-bottom: 28px;
}

.page-shell {
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  padding: 72px 0;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 30px;
}

.session-panel {
  display: grid;
  flex: 0 0 230px;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.compact-field {
  margin-bottom: 4px !important;
}

.session-user {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.page-description {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.75;
}

.workspace {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 11, 18, 0.5);
}

.tab {
  padding: 13px 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
  transition: 160ms ease;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tab:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible,
.text-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.file-picker:focus-within {
  outline: 3px solid rgba(124, 131, 255, 0.24);
  outline-offset: 2px;
}

.tab.is-active {
  color: var(--text);
  border-color: rgba(124, 131, 255, 0.28);
  background: rgba(124, 131, 255, 0.14);
}

.panel {
  padding: 34px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.panel-heading h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.method-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: #c8cbff;
  background: rgba(124, 131, 255, 0.1);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

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

.field-grid.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-field {
  margin-bottom: 20px;
}

.form-field label,
.label-row {
  display: block;
  margin-bottom: 8px;
  color: #dce3f1;
  font-size: 0.88rem;
  font-weight: 700;
}

.label-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.label-row label {
  margin: 0;
}

.label-row span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  background: rgba(7, 10, 17, 0.72);
  transition: border-color 160ms ease, background 160ms ease;
}

input {
  min-height: 50px;
  padding: 0 15px;
}

select {
  width: 100%;
  min-height: 50px;
  padding: 0 40px 0 15px;
}

textarea {
  min-height: 112px;
  padding: 14px 15px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #667086;
}

input:hover,
select:hover,
textarea:hover,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-strong);
  background: rgba(10, 14, 23, 0.92);
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: var(--radius-md);
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(83, 89, 238, 0.26);
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

.secondary-button,
.danger-button,
.text-button {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: #dfe2ff;
  background: rgba(124, 131, 255, 0.1);
  font-weight: 750;
  cursor: pointer;
}

.secondary-button:hover:not(:disabled),
.danger-button:hover:not(:disabled),
.text-button:hover:not(:disabled) {
  background: rgba(124, 131, 255, 0.18);
}

.secondary-button:disabled,
.danger-button:disabled,
.text-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.text-button {
  min-height: 38px;
  padding: 0 12px;
}

.danger-button {
  min-height: 44px;
  padding: 0 16px;
  border-color: rgba(255, 113, 138, 0.42);
  color: #ff9caf;
  background: rgba(255, 113, 138, 0.08);
}

.danger-button:hover:not(:disabled) {
  background: rgba(255, 113, 138, 0.16);
}

.compact-button {
  min-height: 40px;
  padding: 0 14px;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.code-button {
  min-width: 116px;
  padding: 0 12px;
}

.primary-button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.primary-button:active:not(:disabled) {
  transform: translateY(1px);
}

.primary-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.message {
  margin-top: 18px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  line-height: 1.55;
}

.message.is-success {
  color: var(--success);
  border-color: rgba(80, 215, 161, 0.3);
  background: rgba(80, 215, 161, 0.08);
}

.message.is-error {
  color: #ff9caf;
  border-color: rgba(255, 113, 138, 0.3);
  background: rgba(255, 113, 138, 0.08);
}

.requirements {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.requirements div {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.requirements strong,
.requirements span {
  display: block;
}

.requirements strong {
  margin-bottom: 6px;
  color: #dfe5f2;
  font-size: 0.8rem;
}

.requirements span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.file-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 96px;
  margin-bottom: 18px;
  padding: 20px;
  border: 1px dashed rgba(148, 163, 184, 0.34);
  border-radius: var(--radius-md);
  background: rgba(8, 11, 18, 0.46);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.file-picker:hover {
  border-color: var(--border-strong);
  background: rgba(124, 131, 255, 0.06);
}

.file-picker-title {
  font-weight: 800;
}

.file-picker-name {
  overflow: hidden;
  max-width: 55%;
  color: var(--muted);
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.error-list {
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(246, 200, 111, 0.26);
  border-radius: 12px;
  color: #ffe1a6;
  background: rgba(246, 200, 111, 0.07);
}

.error-list ul {
  margin: 0;
  padding-left: 20px;
}

.error-list li + li {
  margin-top: 6px;
}

.summary {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.summary h3 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.summary-grid div {
  padding: 16px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  background: var(--surface-soft);
}

.summary-grid span,
.summary-grid small {
  display: block;
}

.list-workspace {
  margin-top: 28px;
  padding: 28px;
  overflow: visible;
}

.list-header,
.selection-bar,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.list-header {
  margin-bottom: 22px;
}

.list-header h2 {
  margin-bottom: 0;
}

.list-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px 140px auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}

.filter-button {
  min-height: 50px;
  padding: 0 20px;
}

.selection-bar {
  min-height: 56px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.device-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: rgba(7, 10, 17, 0.46);
}

.device-table th,
.device-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.device-table th {
  color: var(--muted);
  background: rgba(8, 11, 18, 0.8);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.device-table td {
  color: #dce3f1;
  font-size: 0.84rem;
}

.device-table tbody tr:last-child td {
  border-bottom: 0;
}

.device-table tbody tr:hover {
  background: rgba(124, 131, 255, 0.05);
}

.device-table input[type="checkbox"] {
  width: 18px;
  min-height: auto;
  height: 18px;
  accent-color: var(--accent);
}

.checkbox-cell {
  width: 46px;
  text-align: center !important;
}

.phone-cell,
.time-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.remark-cell {
  overflow: hidden;
  max-width: 220px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.permission-on,
.permission-off {
  font-weight: 800;
}

.permission-on {
  color: var(--success) !important;
}

.permission-off {
  color: var(--muted) !important;
}

.list-state {
  padding: 30px 16px;
  color: var(--muted);
  text-align: center;
}

.pagination {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.84rem;
}

.summary-grid span {
  margin-bottom: 4px;
  color: var(--success);
  font-size: 1.5rem;
  font-weight: 850;
}

.summary-grid small {
  color: var(--muted);
  font-size: 0.72rem;
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 24px, 920px);
    padding: 40px 0;
  }

  .panel {
    padding: 24px 18px;
  }

  .auth-card {
    padding: 30px 22px;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .session-panel {
    flex-basis: auto;
  }

  .field-grid,
  .field-grid.three-columns,
  .requirements {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: center;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .file-picker {
    align-items: flex-start;
    flex-direction: column;
  }

  .file-picker-name {
    max-width: 100%;
  }

  .inline-field {
    grid-template-columns: 1fr;
  }

  .code-button {
    min-height: 46px;
  }

  .list-workspace {
    padding: 22px 16px;
  }

  .list-header {
    align-items: stretch;
    flex-direction: column;
  }

  .list-filters {
    grid-template-columns: 1fr;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }
}
