:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fafc;
  --border: #dce2ea;
  --text: #111827;
  --muted: #607086;
  --accent: #1267e0;
  --accent-strong: #0b4fad;
  --danger: #c73636;
  --success: #15803d;
  --shadow: 0 12px 34px rgba(22, 35, 54, 0.08);
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #b9c4d4;
}

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

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  background: transparent;
}

.icon {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: #314155;
  font-weight: 650;
}

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

.login-panel {
  width: min(100%, 390px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h1,
.dialog-form h2 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.app-view {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

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

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stats-grid article,
.stats-detail article {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.stats-grid span,
.stats-detail span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.stats-grid strong,
.stats-detail strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  line-height: 1;
}

.toolbar,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  margin-bottom: 16px;
}

.tabs,
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tab.active {
  border-color: #cad5e3;
  background: #edf4ff;
  color: var(--accent-strong);
}

.actions input[type="search"] {
  width: 220px;
}

.panel {
  padding: 14px;
}

.card-list {
  display: grid;
  gap: 12px;
}

.card-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.card-item h3 {
  margin: 0;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

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

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e8f7ed;
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.status.inactive {
  background: #f2f4f7;
  color: #6b7280;
}

.danger {
  border-color: #f0c5c5;
  color: var(--danger);
}

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

dialog {
  width: min(720px, calc(100% - 24px));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-form {
  padding: 20px;
}

.dialog-form header,
.dialog-form footer,
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.dialog-form footer {
  margin-top: 18px;
  justify-content: flex-end;
}

.account-form {
  max-width: 720px;
}

.account-form footer {
  display: flex;
  justify-content: flex-end;
}

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

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

.section-title h3 {
  margin: 0;
}

.social-fields {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.social-row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 8px;
  align-items: center;
}

.switch-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 18px;
}

.switch-row input {
  width: auto;
}

.message {
  margin: 12px 0 0;
}

.error {
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 340px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.log-list {
  display: grid;
  gap: 8px;
}

.log-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .topbar,
  .toolbar,
  .card-item {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .actions input[type="search"] {
    width: 100%;
  }

  .actions,
  .tabs {
    width: 100%;
  }

  .actions button,
  .tabs button {
    flex: 1 1 auto;
  }

  .form-grid,
  .stats-detail,
  .social-row {
    grid-template-columns: 1fr;
  }
}
