:root {
  font-family: "Be Vietnam Pro", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

.dark {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

h1,
h2,
h3,
p,
a,
label,
button,
input,
select,
textarea,
td,
th {
  overflow-wrap: anywhere;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.eyebrow {
  margin-bottom: .5rem;
  color: #075fb0;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.dark .eyebrow {
  color: #7dd3fc;
}

.subtitle {
  margin: .35rem 0 0;
  color: #64748b;
}

.dark .subtitle {
  color: #94a3b8;
}

.menu-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-content: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 16px;
  background: rgba(255, 255, 255, .1);
}

.menu-button span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform .2s ease, opacity .2s ease;
}

.menu-button[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.menu-button[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.menu-button[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.sidebar.menu-open nav {
  display: grid;
  animation: reveal .18s ease-out;
}

.nav-item {
  display: flex;
  min-height: 48px;
  width: 100%;
  align-items: center;
  gap: .75rem;
  border: 0;
  border-radius: 16px;
  padding: .75rem .85rem;
  color: #d9f3ff;
  background: transparent;
  text-align: left;
  font-weight: 700;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-item span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 11px;
  background: rgba(255, 255, 255, .1);
  font-size: .7rem;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, .14);
}

@media (min-width: 1024px) {
  .nav-item:hover,
  .nav-item.active {
    transform: translateX(3px);
  }
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
  animation: reveal .2s ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.page-header {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 768px) {
  .page-header,
  .section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
  }
}

.page-header h1,
.section-heading h2,
.panel h2,
.data-card h2 {
  margin: 0;
  color: #020617;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -.035em;
}

.dark .page-header h1,
.dark .section-heading h2,
.dark .panel h2,
.dark .data-card h2 {
  color: #fff;
}

.page-header h1 {
  font-size: clamp(1.85rem, 4vw, 3rem);
}

.section-heading h2,
.panel h2,
.data-card h2 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
}

.metric-card,
.panel,
.data-card,
.feature-card {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(8, 42, 88, .08);
}

.dark .metric-card,
.dark .panel,
.dark .data-card,
.dark .feature-card {
  border-color: #334155;
  background: #0f172a;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
}

.metric-card {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: .9rem;
  border-radius: 24px;
  padding: 1rem;
}

.metric-card span {
  display: block;
  color: #64748b;
  font-size: .78rem;
  font-weight: 700;
}

.dark .metric-card span {
  color: #94a3b8;
}

.metric-card strong {
  display: block;
  margin-top: .15rem;
  overflow-wrap: anywhere;
  color: #0f172a;
  font-size: .98rem;
  font-weight: 800;
  line-height: 1.35;
}

.dark .metric-card strong {
  color: #f8fafc;
}

.metric-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #07559c, #20b8e6);
  color: #fff;
  font-size: .78rem;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(8, 124, 207, .24);
}

.panel,
.data-card {
  border-radius: 28px;
  padding: 1rem;
}

@media (min-width: 768px) {
  .panel,
  .data-card {
    padding: 1.5rem;
  }

  .panel {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1.25rem;
  }

  .panel .result {
    grid-column: 1 / -1;
  }
}

.panel p,
.section-heading p,
.feature-card p {
  color: #475569;
}

.dark .panel p,
.dark .section-heading p,
.dark .feature-card p {
  color: #94a3b8;
}

.feature-card {
  border-radius: 22px;
  padding: 1rem;
}

.feature-card strong {
  color: #0f172a;
}

.dark .feature-card strong {
  color: #fff;
}

.feature-card p {
  margin: .45rem 0 0;
  font-size: .9rem;
}

.btn-primary,
.btn-secondary,
.table-action,
.icon-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  border-radius: 16px;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

.btn-primary {
  border: 0;
  padding: .75rem 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, #075fb0, #20b8e6);
  box-shadow: 0 16px 34px rgba(8, 124, 207, .24);
}

.btn-secondary,
.table-action {
  border: 1px solid #bae6fd;
  padding: .7rem 1rem;
  color: #07559c;
  background: #edf9ff;
}

.dark .btn-secondary,
.dark .table-action {
  border-color: #164e63;
  color: #bae6fd;
  background: rgba(8, 47, 73, .68);
}

.btn-primary:hover,
.btn-secondary:hover,
.table-action:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.btn-primary:disabled,
.table-action:disabled {
  cursor: wait;
  opacity: .72;
}

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .55);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.loading .button-label {
  display: none;
}

.loading .spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.form-control {
  width: 100%;
  min-height: 48px;
  border: 1px solid #94a3b8;
  border-radius: 16px;
  background: #fff;
  padding: .75rem .9rem;
  color: #0f172a;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.dark .form-control {
  border-color: #334155;
  background: #0f172a;
  color: #f8fafc;
}

.form-control:focus {
  border-color: #087ccf;
  box-shadow: 0 0 0 4px rgba(8, 124, 207, .22);
}

.login-light-control {
  border-color: rgba(56, 189, 248, .45);
  background: rgba(2, 6, 23, .62);
  color: #f8fafc;
}

.login-light-control::placeholder {
  color: #94a3b8;
}

.login-submit {
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  box-shadow: 0 16px 34px rgba(14, 165, 233, .28);
}

.login-submit:hover {
  background: linear-gradient(135deg, #0369a1, #0ea5e9);
}

.remember-row {
  display: flex;
  min-height: 28px;
  align-items: center;
  gap: .55rem;
  color: #dff5ff;
  font-size: .86rem;
  font-weight: 800;
}

.remember-row input {
  width: 18px;
  height: 18px;
  accent-color: #38bdf8;
}

#login-form,
#login-form * {
  min-width: 0;
}

.app-dark .metric-card,
.app-dark .panel,
.app-dark .data-card,
.app-dark .feature-card {
  border-color: rgba(14, 165, 233, .28);
  background: #061d38;
  box-shadow: 0 18px 46px rgba(0, 0, 0, .28);
}

.app-dark .page-header h1,
.app-dark .section-heading h2,
.app-dark .panel h2,
.app-dark .data-card h2,
.app-dark .feature-card strong,
.app-dark .metric-card strong {
  color: #ffffff;
}

.app-dark .subtitle,
.app-dark .panel p,
.app-dark .section-heading p,
.app-dark .feature-card p,
.app-dark .metric-card span {
  color: #bae6fd;
}

.app-dark .eyebrow {
  color: #7dd3fc;
}

.app-dark .table-scroll {
  border-color: rgba(14, 165, 233, .28);
}

.app-dark table {
  color: #e0f2fe;
}

.app-dark th {
  color: #bae6fd;
  background: #082f49;
}

.app-dark td {
  border-color: rgba(14, 165, 233, .2);
}

.app-dark tbody tr:hover {
  background: rgba(14, 165, 233, .08);
}

.app-dark .btn-secondary,
.app-dark .table-action {
  border-color: rgba(125, 211, 252, .45);
  color: #e0f2fe;
  background: rgba(14, 165, 233, .14);
}

.app-dark .form-control,
.app-dark textarea {
  border-color: rgba(125, 211, 252, .35);
  background: #020617;
  color: #f8fafc;
}

.app-dark .dialog-form {
  border-color: rgba(14, 165, 233, .28);
  background: #061d38;
  color: #e0f2fe;
}

.app-dark label,
.app-dark legend {
  color: #e0f2fe;
}

.chart-placeholder {
  display: grid;
  min-height: 170px;
  place-items: center;
  border: 1px dashed rgba(125, 211, 252, .5);
  border-radius: 22px;
  background: rgba(14, 165, 233, .08);
  color: #bae6fd;
  font-weight: 900;
  text-align: center;
}

.result {
  border-radius: 16px;
  padding: .85rem 1rem;
  font-size: .9rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.result.success {
  border: 1px solid #bbf7d0;
  color: #166534;
  background: #f0fdf4;
}

.result.error {
  border: 1px solid #fecaca;
  color: #991b1b;
  background: #fef2f2;
}

.dark .result.success {
  border-color: #166534;
  color: #bbf7d0;
  background: rgba(20, 83, 45, .35);
}

.dark .result.error {
  border-color: #7f1d1d;
  color: #fecaca;
  background: rgba(127, 29, 29, .35);
}

.hidden {
  display: none !important;
}

.notice {
  margin-bottom: 1rem;
  border-radius: 22px;
  padding: 1rem;
  line-height: 1.7;
}

.notice.warning {
  border: 1px solid #fde68a;
  color: #854d0e;
  background: #fffbeb;
}

.dark .notice.warning {
  border-color: #713f12;
  color: #fde68a;
  background: rgba(113, 63, 18, .25);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid #cbd5e1;
  border-radius: 22px;
  scrollbar-color: #087ccf #d6f1ff;
  -webkit-overflow-scrolling: touch;
}

.dark .table-scroll {
  border-color: #1e293b;
  scrollbar-color: #38bdf8 #0f172a;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: .88rem;
  line-height: 1.5;
}

th,
td {
  border-bottom: 1px solid #e2e8f0;
  padding: .95rem 1rem;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.dark th,
.dark td {
  border-color: #1e293b;
}

th {
  color: #07559c;
  background: #eff8ff;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.dark th {
  color: #bae6fd;
  background: rgba(15, 23, 42, .9);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #eff8ff;
}

.dark tbody tr:hover {
  background: rgba(30, 41, 59, .5);
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .25rem .65rem;
  font-size: .74rem;
  font-weight: 800;
}

.status.active {
  color: #166534;
  background: #dcfce7;
}

.status.inactive {
  color: #991b1b;
  background: #fee2e2;
}

.status.pending {
  color: #92400e;
  background: #fef3c7;
}

.status.admin {
  color: #07559c;
  background: #d6f1ff;
}

.status.viewer {
  color: #475569;
  background: #f1f5f9;
}

.dark .status.viewer {
  color: #cbd5e1;
  background: #1e293b;
}

.table-action {
  min-height: 38px;
  border-radius: 13px;
  padding: .48rem .75rem;
  font-size: .8rem;
}

.table-action.danger {
  border-color: #fecaca;
  color: #991b1b;
  background: #fef2f2;
}

.cell-note {
  display: block;
  margin-top: .28rem;
  color: #64748b;
  font-size: .72rem;
  white-space: normal;
}

.dark .cell-note {
  color: #94a3b8;
}

.empty-state {
  display: grid;
  place-items: center;
  padding: 2.2rem 1rem;
  color: #64748b;
  text-align: center;
}

.dark .empty-state {
  color: #94a3b8;
}

.loading-row {
  padding: 1.25rem;
  color: #64748b;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.check-item {
  margin: 0;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: .9rem 1rem;
  color: #475569;
}

.check-item::before {
  content: "";
  display: inline-block;
  width: .55rem;
  height: .55rem;
  margin-right: .55rem;
  border-radius: 999px;
  background: #22c55e;
}

.dark .check-item {
  border-color: #1e293b;
  background: #0f172a;
  color: #cbd5e1;
}

dialog {
  width: min(560px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
  box-shadow: 0 24px 90px rgba(8, 42, 88, .32);
}

dialog::backdrop {
  background: rgba(8, 42, 88, .62);
  backdrop-filter: blur(4px);
}

.dialog-form {
  display: grid;
  gap: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 28px;
  background: #fff;
  padding: 1.25rem;
}

.dark .dialog-form {
  border-color: #1e293b;
  background: #0f172a;
}

@media (min-width: 640px) {
  .dialog-form {
    padding: 1.5rem;
  }
}

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

.dialog-heading h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.03em;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  font-size: 1.35rem;
}

.dark .icon-button {
  border-color: #334155;
  background: #1e293b;
  color: #f8fafc;
}

label {
  display: grid;
  gap: .45rem;
  color: #334155;
  font-size: .86rem;
  font-weight: 800;
}

.dark label {
  color: #e2e8f0;
}

label small {
  color: #64748b;
  font-weight: 500;
}

.checkbox-label {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: .6rem;
}

.checkbox-label input,
.permission-item input {
  width: 18px;
  min-height: 18px;
  accent-color: #087ccf;
}

fieldset {
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 1rem;
}

.dark fieldset {
  border-color: #334155;
}

legend {
  padding: 0 .5rem;
  font-size: .86rem;
  font-weight: 800;
}

.permission-tree {
  display: grid;
  max-height: 280px;
  gap: .35rem;
  overflow-y: auto;
  padding-right: .25rem;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 36px;
  font-weight: 600;
}

.permission-item.parent {
  margin-top: .25rem;
  color: #07559c;
  font-weight: 900;
}

.dark .permission-item.parent {
  color: #7dd3fc;
}

.permission-item.child {
  margin-left: 1.35rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
