:root {
  --color-primary: #347CCB;
  --color-primary-dark: #2A63A3;
  --color-dark: #292D32;
  --color-navy: #0E2638;
  --color-gray: #777777;
  --color-white: #FFFFFF;

  --color-bg: #F4F6F8;
  --color-surface: #FFFFFF;
  --color-border: #E2E5E9;
  --color-text: #1B1E22;
  --color-text-muted: #6B7280;
  --color-success: #1E8E5A;
  --color-success-bg: #E6F4EC;
  --color-error: #C0362C;
  --color-error-bg: #FBE9E7;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(14, 38, 56, 0.08), 0 1px 2px rgba(14, 38, 56, 0.06);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #14171A;
    --color-surface: #1D2126;
    --color-border: #2A2F35;
    --color-text: #E7E9EC;
    --color-text-muted: #9AA1A9;
    --color-success-bg: #113322;
    --color-error-bg: #3A1917;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: 240px;
  background: var(--color-navy);
  color: var(--color-white);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
}
.sidebar-brand { padding: 0 20px 24px; }
.brand-logo { max-width: 100%; height: auto; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  color: rgba(255, 255, 255, 0.78);
  padding: 10px 20px;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; color: #fff; }
.sidebar-nav a.active {
  color: #fff;
  background: rgba(52, 124, 203, 0.18);
  border-left-color: var(--color-primary);
}
.sidebar-section {
  margin-top: 20px;
  padding: 0 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: rgba(255, 255, 255, 0.4);
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 16px; font-size: 14px; color: var(--color-text-muted); }

.content { padding: 32px; max-width: 1100px; width: 100%; margin: 0 auto; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 22px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-block { width: 100%; }
.link-button {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  font-family: inherit;
}
.link-button:hover { color: var(--color-primary); }
.inline-form { display: inline-block; margin: 0; }

.stack-form { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.stack-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.stack-form input[type=text],
.stack-form input[type=password],
.stack-form input[type=email],
.stack-form select {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
}
.stack-form input:focus, .stack-form select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
fieldset { border: 1px solid var(--color-border); border-radius: 8px; padding: 12px 16px; }
legend { font-size: 13px; font-weight: 600; padding: 0 4px; }

.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
  transition: border-color .15s, background .15s;
}
.dropzone p { margin: 0; }
.dropzone.dragover { border-color: var(--color-primary); background: rgba(52, 124, 203, 0.06); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); }
.table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-error { background: var(--color-error-bg); color: var(--color-error); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
.alert-error { background: var(--color-error-bg); color: var(--color-error); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }

.muted { color: var(--color-text-muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.profile-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.guest-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-navy);
  font-family: var(--font-sans);
  padding: 16px;
}
.guest-card {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.guest-logo { max-width: 220px; height: auto; display: block; margin: 0 auto 28px; }
.guest-card h1 { font-size: 20px; margin: 0 0 16px; text-align: center; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; padding: 12px 0; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; padding: 0 12px; }
  .sidebar-nav a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .sidebar-nav a.active { border-left-color: transparent; border-bottom-color: var(--color-primary); }
  .sidebar-section { display: none; }
  .content { padding: 20px; }
}
