*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-border: #dde3ea;
  --color-text: #1f2933;
  --color-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-error: #dc2626;
  --color-info: #0369a1;
  --color-warning: #b45309;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --radius: 10px;
  --content-max-width: 1200px;
  --page-padding: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding-left: var(--page-padding);
  padding-right: var(--page-padding);
}

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--color-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-badge {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.main-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.main-nav__list {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 10px 0;
  overflow-x: auto;
}

.main-nav__link {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9375rem;
  color: var(--color-muted);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.main-nav__link:hover {
  background: #eef2ff;
  color: var(--color-primary);
}

.main-nav__link.is-active {
  background: #dbeafe;
  color: var(--color-primary);
  font-weight: 600;
}

.page-content {
  flex: 1;
  padding-top: 32px;
  padding-bottom: 48px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}

.card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.card p {
  margin: 0;
  color: var(--color-muted);
}

.stub-badge {
  display: inline-block;
  margin-top: 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-lg {
  padding: 12px 22px;
  font-size: 1rem;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background: #f8fafc;
  color: var(--color-text);
}

input[type="text"],
input[type="password"] {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: 2px solid #bfdbfe;
  border-color: var(--color-primary);
}

.flash-list {
  list-style: none;
  margin: 0;
  padding: 12px 0 0;
}

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.9375rem;
}

.flash-error {
  background: #fee2e2;
  color: var(--color-error);
}

.flash-info {
  background: #e0f2fe;
  color: var(--color-info);
}

.flash-warning {
  background: #fef3c7;
  color: var(--color-warning);
}

.login-page {
  display: flex;
  justify-content: center;
  padding-top: 24px;
}

.guest-layout {
  background:
    radial-gradient(circle at 12% 18%, rgba(59, 130, 246, 0.14), transparent 42%),
    radial-gradient(circle at 88% 12%, rgba(34, 197, 94, 0.12), transparent 38%),
    radial-gradient(circle at 72% 82%, rgba(251, 191, 36, 0.14), transparent 40%),
    linear-gradient(160deg, #eef6ff 0%, #f8fafc 45%, #fff7ed 100%);
}

.guest-layout .page-content {
  padding-top: 16px;
  padding-bottom: 32px;
}

.guest-layout .site-header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
}

.login-card {
  width: 100%;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
}

.login-card input {
  width: 100%;
}

.settings-menu {
  position: relative;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-muted);
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--color-primary);
  border-color: #bfdbfe;
  background: #f8fafc;
}

.icon-gear {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 30;
}

.settings-dropdown__item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.settings-dropdown__item:hover {
  background: #f1f5f9;
}

.settings-dropdown__item:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.sync-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
}

.sync-overlay[hidden] {
  display: none !important;
}

.sync-modal {
  width: 100%;
  max-width: 440px;
}

.sync-modal h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.sync-modal__status {
  margin: 0 0 16px;
  color: var(--color-muted);
  font-size: 0.9375rem;
}

.sync-modal__meta {
  margin: 10px 0 0;
  color: var(--color-muted);
  font-size: 0.875rem;
}

.sync-progress {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.sync-progress__bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  transition: width 0.25s ease;
}

.sync-modal__close {
  margin-top: 16px;
  width: 100%;
}

.users-modal {
  max-width: 560px;
}

.users-modal__hint {
  margin: 0 0 16px;
  color: var(--color-muted);
  font-size: 0.875rem;
}

.users-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.users-form__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
}

.users-form__field span {
  color: var(--color-muted);
}

.users-form__field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font: inherit;
}

.users-form__error {
  margin: 0 0 12px;
  color: #b91c1c;
  font-size: 0.875rem;
}

.users-form__error[hidden] {
  display: none !important;
}

.users-table-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.users-table th,
.users-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.users-table th {
  background: #f8fafc;
  font-weight: 600;
}

.users-table__actions {
  width: 48px;
  text-align: right;
}

.users-table__empty {
  text-align: center;
  color: var(--color-muted);
}

.users-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.users-delete-btn:hover:not(:disabled) {
  background: #fee2e2;
  color: #b91c1c;
}

.users-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.users-modal__close {
  margin-top: 16px;
}

@media (max-width: 640px) {
  .users-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --page-padding: 12px;
  }

  .site-header__inner {
    flex-direction: column;
    align-items: stretch;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .header-actions {
    justify-content: flex-end;
  }
}
