:root {
  --blue-deep: #0000be;
  --red-vivid: #ff0000;
  --sky-bright: #0097ff;
  --yellow-soft: #ffee00;
  --green-strong: #00b600;
  --ink: #14213d;
  --muted: #5f6b85;
  --paper: #eef3f8;
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --card: #ffffff;
  --line: #d8dfeb;
  --line-strong: #c4cede;
  --shadow: 0 18px 38px rgba(20, 33, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Google Sans Flex', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f4f7fb 0%, #edf2f8 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
}

.app-shell {
  display: block;
}

.auth-shell {
  display: block;
}

.brand-card,
.user-badge,
.panel,
.stat-card,
.flash,
.hero-card {
  backdrop-filter: blur(10px);
}

.brand-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-card h1,
.topbar h2,
.hero-card h2,
.section-heading h3,
.centered-panel h2 {
  margin: 0;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: inset 0 0 0 1px rgba(16, 37, 79, 0.08);
}

.eyebrow {
  margin: 0 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 700;
  opacity: 0.8;
}

.main-content {
  padding: 1.5rem 1.75rem 2rem;
}

.main-content.centered {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.content-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 1rem 1.75rem;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(244, 247, 251, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.app-header h2 {
  margin: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-brand .eyebrow {
  margin-bottom: 0.1rem;
  color: var(--muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.header-link {
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 620;
}

.header-link:hover,
.header-link.active {
  color: var(--blue-deep);
  background: rgba(0, 0, 190, 0.06);
  border-color: rgba(0, 0, 190, 0.1);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green-strong);
  box-shadow: 0 0 0 4px rgba(0, 182, 0, 0.12);
}

.header-user {
  display: grid;
  justify-items: end;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  border: 1px solid transparent;
}

.header-user:hover,
.header-user.active {
  border-color: rgba(0, 0, 190, 0.1);
  background: rgba(0, 0, 190, 0.06);
}

.header-user strong,
.header-user small {
  display: block;
}

.flash {
  margin-bottom: 1rem;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  font-weight: 600;
  box-shadow: none;
  border: 1px solid transparent;
}

.flash-success {
  background: rgba(0, 182, 0, 0.08);
  color: #086e08;
  border-color: rgba(0, 182, 0, 0.16);
}

.flash-error {
  background: rgba(255, 0, 0, 0.08);
  color: #9f0f0f;
  border-color: rgba(255, 0, 0, 0.14);
}

.topbar,
.login-panel,
.two-column,
.dashboard-grid,
.field-grid,
.stats-grid,
.action-row,
.meta-row {
  display: grid;
  gap: 1rem;
}

.topbar,
.action-row,
.meta-row {
  grid-auto-flow: column;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 1rem;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 1.25rem 0 1.5rem;
}

.stat-card,
.panel,
.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 1.25rem;
}

.stat-card span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.stat-card strong {
  font-size: 2.2rem;
}

.stat-card small {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
}

.accent-blue { border-top: 4px solid var(--blue-deep); }
.accent-red { border-top: 4px solid var(--red-vivid); }
.accent-sky { border-top: 4px solid var(--sky-bright); }
.accent-yellow { border-top: 4px solid #c4a800; }

.dashboard-grid,
.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel,
.hero-card {
  padding: 1.35rem;
}

.section-heading p,
.hero-card p,
.list-card p,
td small,
.empty-state {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.section-copy {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid.compact {
  gap: 0.85rem;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 0.45rem;
}

label span {
  font-weight: 650;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.check-inline input {
  width: auto;
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

textarea {
  resize: vertical;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  padding: 0.8rem 1.1rem;
  border: 0;
  border-radius: 12px;
  background: var(--blue-deep);
  color: white;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 190, 0.14);
}

.button-secondary {
  background: var(--surface);
  color: var(--blue-deep);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.button-danger {
  background: #c62828;
}

.button-danger-soft {
  background: #fff3f3;
  color: #b71c1c;
  border: 1px solid rgba(183, 28, 28, 0.24);
  box-shadow: none;
}

.button-danger-soft:hover {
  background: #ffe8e8;
}

.button-exit {
  background: #b71c1c;
  color: #fff;
  border: 1px solid #8f1313;
  box-shadow: 0 8px 18px rgba(183, 28, 28, 0.22);
}

.button-exit::before {
  content: '';
  width: 16px;
  height: 16px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 17l5-5-5-5'/%3E%3Cpath d='M15 12H3'/%3E%3Cpath d='M21 19V5a2 2 0 0 0-2-2h-8'/%3E%3C/svg%3E");
}

.button-exit:hover {
  background: #a91818;
}

.icon-button {
  min-width: 42px;
  width: 42px;
  min-height: 42px;
  padding: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.icon-button::before {
  content: '';
  width: 18px;
  height: 18px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.icon-edit::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230000BE' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z'/%3E%3C/svg%3E");
}

.icon-file::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230000BE' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='8' y1='13' x2='16' y2='13'/%3E%3Cline x1='8' y1='17' x2='13' y2='17'/%3E%3C/svg%3E");
}

.button-danger.icon-delete::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6l-1 14H6L5 6'/%3E%3Cpath d='M10 11v6'/%3E%3Cpath d='M14 11v6'/%3E%3Cpath d='M9 6V4h6v2'/%3E%3C/svg%3E");
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

.modal {
  width: min(960px, calc(100vw - 2rem));
  padding: 0;
  border: 0;
  background: transparent;
}

.confirm-modal {
  width: min(460px, calc(100vw - 2rem));
}

.modal::backdrop {
  background: rgba(20, 33, 61, 0.42);
  backdrop-filter: blur(2px);
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: 1.2rem;
  max-height: 72vh;
  overflow: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.65rem;
}

.modal-close {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--blue-deep);
  font-weight: 800;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(0, 0, 190, 0.06);
}

.confirm-copy {
  margin: 0;
  color: var(--muted);
}

.full-width {
  width: 100%;
}

.chip-row,
.list-stack {
  display: grid;
  gap: 0.85rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(0, 151, 255, 0.08);
  color: var(--blue-deep);
  font-weight: 650;
  border: 1px solid rgba(0, 151, 255, 0.1);
}

.chip-disabled {
  background: rgba(198, 40, 40, 0.08);
  color: #b71c1c;
  border-color: rgba(198, 40, 40, 0.2);
}

.list-card {
  display: grid;
  gap: 0.8rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-alt);
}

.dashboard-hero {
  margin-bottom: 1.5rem;
}

.hero-summary {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.feature-tile {
  display: grid;
  gap: 0.3rem;
  padding: 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 160ms ease, transform 160ms ease;
}

.feature-tile:hover {
  border-color: rgba(0, 0, 190, 0.22);
  transform: translateY(-1px);
}

.feature-tile span {
  color: var(--muted);
}

.feature-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  display: grid;
  gap: 0.8rem;
}

.module-panel {
  margin-bottom: 1.2rem;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.module-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-alt);
}

.module-card p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.module-switch {
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 1;
}

.module-switch-body {
  transform: scale(1);
  display: block;
  width: 88px;
  height: 44px;
  border-radius: 22px;
  background: linear-gradient(to bottom, #9e9e9e 30%, #f4f4f4);
  box-shadow:
    0 1px 0 0 #fff,
    0 -1px 0 0 #969494;
  position: relative;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}

.module-switch-body::after {
  content: "";
  position: absolute;
  display: block;
  width: 90px;
  height: 46px;
  border-radius: 23px;
  top: -1px;
  left: -1px;
  z-index: -1;
  background: linear-gradient(to bottom, #969494, #fff);
}

.module-switch-track {
  display: block;
  width: 70px;
  height: 26px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(to bottom, #8b8c8e 20%, #f4f4f4);
  border-radius: 13px;
  transition: 0.2s;
}

.module-switch-track::after {
  content: "";
  position: absolute;
  display: block;
  height: 24px;
  width: 68px;
  left: 1px;
  top: 1px;
  border-radius: 12px;
  background: #828080;
  box-shadow: inset 0 0 15px 0 rgba(0, 0, 0, 0.8);
  transition: 0.2s;
}

.module-switch-thumb {
  position: absolute;
  display: block;
  width: 34px;
  height: 34px;
  background: linear-gradient(to top, #9e9e9e 20%, #f4f4f4);
  border-radius: 50%;
  box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.7);
  top: 5px;
  left: 5px;
  transition: 0.25s;
}

.module-switch-thumb::after {
  content: "";
  position: absolute;
  display: block;
  width: 28px;
  height: 28px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #d5d4d4;
  z-index: 1;
}

.module-switch .on,
.module-switch .off {
  text-transform: uppercase;
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72em;
  font-weight: 600;
  z-index: 2;
  letter-spacing: 1px;
  transition: 0.25s;
}

.module-switch .on {
  color: transparent;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0);
}

.module-switch .off {
  left: initial;
  right: 10px;
  color: hsl(24, 2%, 49%);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.module-switch.is-on .module-switch-thumb {
  top: 5px;
  left: 49px;
}

.module-switch.is-on .module-switch-track::after {
  background: #0f0;
  box-shadow: inset 0 0 15px 0 rgba(0, 0, 0, 0.6);
  animation: switchOn 0.5s ease-in-out forwards;
}

.module-switch.is-on .module-switch-track > .off {
  color: transparent;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0);
}

.module-switch.is-on .module-switch-track > .on {
  color: hsl(24, 2%, 49%);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.module-switch.is-off .module-switch-track::after {
  background: #f00;
  box-shadow: inset 0 0 15px 0 rgba(0, 0, 0, 0.6);
  animation: switchOff 0.5s ease-in-out forwards;
}

.module-switch.is-off .module-switch-track > .on {
  color: transparent;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0);
}

.module-switch.is-off .module-switch-track > .off {
  color: #444;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.module-switch:hover {
  cursor: pointer;
}

.module-switch:focus,
.module-switch:active {
  outline: 0;
}

.module-switch:focus-visible .module-switch-body {
  box-shadow:
    0 0 0 3px rgba(56, 113, 224, 0.35),
    0 1px 0 0 #fff,
    0 -1px 0 0 #969494;
}

@keyframes switchOn {
  0% {
    background-color: #f00;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
  }

  100% {
    background-color: #0f0;
    box-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
  }
}

@keyframes switchOff {
  0% {
    background-color: #0f0;
    box-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
  }

  100% {
    background-color: #f00;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
  }
}

.list-card.tall,
.action-column {
  grid-auto-flow: column;
  justify-content: space-between;
}

.action-column {
  display: grid;
  gap: 0.65rem;
  justify-items: end;
}

.card-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.card-actions form {
  margin: 0;
}

td .action-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
}

td .action-row form {
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 1rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

td strong,
td small {
  display: block;
}

.centered-panel {
  max-width: 520px;
  margin: 3rem auto;
  text-align: center;
}

.login-panel {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 420px);
  align-items: center;
  width: min(1100px, 100%);
}

.hero-card {
  min-height: 440px;
  align-content: center;
  background: linear-gradient(135deg, #10254f 0%, #173d7a 100%);
  color: white;
}

.hero-card .eyebrow,
.hero-card p {
  color: rgba(255, 255, 255, 0.82);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.5rem;
}

.hero-metrics div {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-metrics span {
  color: rgba(255, 255, 255, 0.72);
}

@media (max-width: 980px) {
  .dashboard-grid,
  .hero-grid,
  .module-grid,
  .two-column,
  .stats-grid,
  .login-panel,
  .hero-metrics,
  .field-grid.two,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .topbar,
  .action-row,
  .meta-row,
  .list-card.tall,
  .action-column {
    grid-auto-flow: row;
    justify-content: start;
    justify-items: start;
  }

  .main-content {
    padding: 1.2rem;
  }

  .app-header,
  .header-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-nav {
    width: 100%;
  }

  .modal {
    width: calc(100vw - 1rem);
  }

  .modal-header {
    flex-direction: column;
    align-items: flex-start;
  }
}