:root {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-hover: #f0f3f6;
  --header: #1d8ce0;
  --header-deep: #1878c2;
  --border: #e4e7eb;
  --border-strong: #cfd6de;
  --text: #2c333a;
  --text-muted: #6b7380;
  --text-faint: #9aa3ad;
  --accent: #1d8ce0;
  --accent-dim: rgba(29, 140, 224, 0.12);
  --red: #e55353;
  --green: #2fbf71;
  --radius: 4px;
  --radius-sm: 3px;
  --font: 'Roboto', 'Open Sans', Arial, sans-serif;
  --mono: 'Roboto Mono', ui-monospace, monospace;
  --shadow: 0 1px 2px rgba(32, 41, 54, 0.06);
  --header-h: 48px;
  --toolbar-h: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

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

button, input, select {
  font: inherit;
}

.app {
  min-height: 100vh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  background: var(--header);
  color: #fff;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.brand-sub {
  font-size: 13px;
  opacity: 0.8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.owner-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
}

.btn-header {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.12);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--toolbar-h);
  padding: 10px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
}

.content {
  padding: 20px 24px 32px;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-gate {
  min-height: 100vh;
  background: var(--bg);
}

.auth-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--header);
  color: #fff;
}

.auth-card-wrap {
  display: flex;
  justify-content: center;
  padding: 48px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 28px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-brand h1 {
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 8px;
}

.auth-hint {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-error {
  color: var(--red);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

input[type='text'],
input[type='password'],
select {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-note {
  font-size: 13px;
  margin: 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--header-deep);
}

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

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-outline {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-outline:hover {
  background: var(--accent-dim);
}

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

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger {
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(229, 83, 83, 0.08);
  border-color: rgba(229, 83, 83, 0.35);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.badge-table {
  width: 100%;
  border-collapse: collapse;
}

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

.badge-table th {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #fafbfc;
}

.badge-table tr:last-child td {
  border-bottom: none;
}

.badge-table tbody tr:hover {
  background: var(--bg-hover);
}

.badge-table td.actions {
  white-space: nowrap;
}

.badge-table .actions .btn {
  margin-right: 6px;
}

.serial {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
}

.muted {
  color: var(--text-faint);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  vertical-align: middle;
}

.status-dot.is-online {
  background: var(--green);
}

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

.page-error {
  margin: 0 24px 12px;
  color: var(--red);
  background: rgba(229, 83, 83, 0.08);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 41, 54, 0.45);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(24rem, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(32, 41, 54, 0.18);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-title {
  font-size: 18px;
  font-weight: 400;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
