:root {
  color-scheme: light;
  --background: #f7f8fa;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --primary: #111827;
  --primary-foreground: #f8fafc;
  --secondary: #f8fafc;
  --secondary-foreground: #1f2937;
  --destructive: #dc2626;
  --destructive-foreground: #ffffff;
  --ring: #94a3b8;
  --success: #16a34a;
  --radius: 0.625rem;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #ffffff;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.brand {
  text-decoration: none;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sidebar-subtitle {
  margin: -0.4rem 0 0.3rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.35rem;
}

.nav-link {
  display: block;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.5rem 0.7rem;
  text-decoration: none;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-link:hover {
  background: var(--muted);
  color: #0f172a;
}

.nav-link-active {
  border-color: var(--border);
  background: var(--muted);
  color: #0f172a;
}

.sidebar-logout {
  margin-top: auto;
}

.app-main {
  min-width: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--border);
  background: rgba(247, 248, 250, 0.92);
  backdrop-filter: blur(8px);
}

.header-inner {
  min-height: 3.7rem;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
}

.page-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
}

.main-content {
  padding: 1.5rem;
}

body.guest .site-header {
  position: static;
  background: #ffffff;
}

body.guest .header-inner {
  justify-content: center;
  border-bottom: 1px solid var(--border);
}

body.guest .main-content {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.25rem 0 3.5rem;
}

.auth-card,
.stat-card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 33rem);
  margin: 9vh auto;
  padding: 1.6rem;
}

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

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.4rem, 3vw, 1.95rem);
  letter-spacing: -0.015em;
}

h2 {
  margin-bottom: 0.1rem;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted,
small,
.optional {
  color: var(--muted-foreground);
}

.optional {
  font-size: 0.82rem;
  font-weight: 400;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-heading p {
  margin-bottom: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  min-height: 7.35rem;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-card span {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.stat-card strong {
  margin-top: auto;
  font-size: 1.22rem;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.stat-card small {
  font-size: 0.75rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  gap: 0.95rem;
  margin-bottom: 1rem;
}

.panel {
  padding: 1.1rem;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.95rem;
}

.panel-heading .eyebrow {
  margin-bottom: 0.2rem;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.stack {
  display: grid;
  gap: 0.85rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 3px);
  padding: 0.62rem 0.72rem;
  background: #ffffff;
  color: var(--foreground);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(148, 163, 184, 0.45);
  outline-offset: 1px;
  border-color: #cbd5e1;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--muted-foreground);
  font-size: 0.83rem;
  font-weight: 500;
}

.check input {
  width: 1rem;
  height: 1rem;
  margin-top: 0.16rem;
  accent-color: #1e293b;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.52rem 0.92rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.button.primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.button.primary:hover {
  background: #1f2937;
}

.button.secondary {
  border-color: var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.button.secondary:hover {
  background: var(--muted);
}

.button.danger {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.button.danger:hover {
  background: #b91c1c;
}

.button.full {
  width: 100%;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.divider::before,
.divider::after {
  height: 1px;
  flex: 1;
  background: var(--border);
  content: "";
}

.notice {
  margin: 0 0 1rem;
  border: 1px solid;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.7rem 0.8rem;
  font-size: 0.9rem;
}

.notice.success {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.notice.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.audit {
  padding-bottom: 0.45rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

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

th {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td {
  overflow-wrap: anywhere;
}

.search-form {
  margin-bottom: 1.15rem;
}

.search-form > div {
  display: flex;
  gap: 0.65rem;
}

.search-form .button {
  flex: 0 0 auto;
}

@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }

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

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    gap: 0.7rem;
  }

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

  .sidebar-logout {
    margin-top: 0.3rem;
  }

  .main-content {
    padding: 1rem;
  }

  .page-heading {
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  body.guest .main-content {
    width: min(1120px, calc(100% - 1.2rem));
    padding-top: 1.2rem;
  }

  .header-inner {
    padding: 0 1rem;
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
  }

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

  .panel,
  .auth-card {
    padding: 1rem;
  }

  .search-form > div {
    flex-direction: column;
  }
}

@media (max-width: 430px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}
