@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Merriweather:wght@700&family=Source+Sans+3:wght@400;600;700&display=swap");

:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --text: #1e2530;
  --text-dim: #687489;
  --line: #d8dde7;
  --line-strong: #c6cedc;
  --primary: #d21f26;
  --primary-strong: #b5121b;
  --primary-soft: #fff1f2;
  --secondary: #0e4f9e;
  --secondary-soft: #edf3ff;
  --success: #159764;
  --warning: #c4862f;
  --danger: #bd2f38;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Sans 3", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff 0, #f6f8fb 280px, var(--bg) 100%);
}

h1,
h2,
h3 {
  margin: 0;
}

p {
  margin: 0;
}

.site-shell {
  min-height: 100vh;
}

.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.masthead-main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 70px;
  height: 70px;
  min-width: 70px;
  min-height: 70px;
  max-width: 70px;
  max-height: 70px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e5e9f2;
  background: #fff;
}

.brand-mark {
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  color: white;
  background: linear-gradient(135deg, var(--primary), #f36b1f);
  border-radius: 10px;
  padding: 6px 12px;
  box-shadow: 0 8px 18px rgba(210, 31, 38, 0.24);
}

.brand-copy {
  display: grid;
}

.brand-copy strong {
  font-family: "Merriweather", serif;
  font-size: 1rem;
  color: #202734;
}

.brand-copy small {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: #697589;
}

.nav {
  background: var(--primary);
  border-top: 1px solid #eb4850;
  border-bottom: 1px solid #ad1118;
  width: 100%;
}

.nav-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}

.nav-side {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-item {
  color: #ffeef0;
  text-decoration: none;
  padding: 13px 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
  font-weight: 700;
}

.nav-item:hover {
  background: #fdfdfd;
  color: var(--primary-strong);
}

.nav-item.is-active {
  background: #ffffff;
  color: var(--primary-strong);
}

.nav-utility {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-item.nav-item-utility {
  color: #ffd8db;
  opacity: 0.82;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 11px 10px;
}

.nav-item.nav-item-utility:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.nav-item.nav-item-utility.is-active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown > summary {
  list-style: none;
  cursor: pointer;
}

.nav-dropdown > summary::-webkit-details-marker {
  display: none;
}

.nav-dropdown > summary::after {
  content: " ▾";
  font-size: 0.75em;
}

.nav-dropdown.is-current > summary,
.nav-dropdown[open] > summary {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.nav-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 170px;
  border: 1px solid #d7deea;
  border-radius: 10px;
  background: white;
  padding: 4px;
  box-shadow: 0 14px 30px rgba(26, 34, 49, 0.14);
  display: grid;
  gap: 2px;
  z-index: 10;
}

.nav-dropdown-link {
  text-decoration: none;
  color: #364156;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.nav-dropdown-link:hover {
  background: #f3f6fb;
}

.nav-dropdown-link.is-active {
  background: #ffeef0;
  color: var(--primary-strong);
}

.logout-form {
  margin-left: 6px;
}

.workspace {
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px 22px 46px;
  display: grid;
  gap: 18px;
}

.topbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--primary);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  box-shadow: 0 10px 22px rgba(30, 37, 48, 0.06);
}

.topbar h1 {
  font-family: "Merriweather", serif;
  font-size: clamp(1.45rem, 3.1vw, 2rem);
}

.topbar p {
  margin-top: 4px;
  color: var(--text-dim);
}

.user-pill {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 9px 12px;
  display: grid;
  justify-items: end;
}

.user-pill span {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.user-pill strong {
  color: var(--secondary);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.page-content {
  display: grid;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 26px rgba(30, 37, 48, 0.04);
}

.metric-card {
  padding: 18px;
  display: grid;
  gap: 6px;
}

.metric-card p {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.07em;
  color: #7d879a;
}

.metric-card h2 {
  font-family: "Merriweather", serif;
  font-size: 1.9rem;
  color: #101827;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.panel {
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-head h3 {
  font-family: "Merriweather", serif;
  font-size: 1.2rem;
}

.timeline {
  margin: 0;
  padding: 0 0 0 18px;
  display: grid;
  gap: 8px;
  color: var(--text-dim);
}

.timeline li.done {
  color: var(--success);
}

.timeline li.current {
  color: var(--secondary);
  font-weight: 700;
}

.action-list {
  display: grid;
  gap: 9px;
}

.quick-action {
  text-decoration: none;
  color: #1f2734;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-soft);
}

.quick-action:hover {
  border-color: #d3a3a6;
  background: var(--primary-soft);
}

.button {
  border: none;
  border-radius: 10px;
  height: 40px;
  padding: 0 15px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: white;
  background: linear-gradient(180deg, #ea333b, var(--primary-strong));
}

.button.button-muted {
  background: var(--secondary-soft);
  color: var(--secondary);
  border: 1px solid #c8d7f3;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid transparent;
  color: #52617a;
  background: #eef2f8;
}

.badge-live {
  color: #0a7e52;
  border-color: #9ed8bf;
  background: #e9fbf4;
}

.badge-success {
  color: #0a7e52;
  border-color: #9ed8bf;
  background: #e9fbf4;
}

.badge-danger {
  color: var(--danger);
  border-color: #f4b7bc;
  background: #fff1f3;
}

.trend {
  font-size: 0.79rem;
  letter-spacing: 0.03em;
}

.trend.positive {
  color: var(--success);
}

.trend.warning {
  color: var(--warning);
}

.form {
  display: grid;
  gap: 12px;
}

.form.two-columns {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.settings-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface-soft);
  display: grid;
  gap: 10px;
}

.settings-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-group-head h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.settings-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.settings-save-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  max-width: min(380px, calc(100vw - 32px));
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid transparent;
  box-shadow: 0 14px 32px rgba(19, 28, 45, 0.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.settings-save-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.settings-save-toast.is-success {
  color: #0a7e52;
  border-color: #9ed8bf;
  background: #e9fbf4;
}

.settings-save-toast.is-error {
  color: var(--danger);
  border-color: #f4b7bc;
  background: #fff1f3;
}

.form label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.84rem;
  color: var(--text-dim);
}

.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: white;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
}

input,
select {
  height: 40px;
}

textarea {
  padding-top: 10px;
  min-height: 84px;
}

input::placeholder,
textarea::placeholder {
  color: #92a0b4;
}

.inline-actions {
  display: flex;
  gap: 10px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar > * {
  width: auto;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: white;
  table-layout: auto;
}

.table thead th {
  text-align: left;
  background: #f4f6fa;
  color: #58657b;
  padding: 10px 12px;
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tbody td {
  padding: 11px 12px;
  border-top: 1px solid #edf0f5;
}

.table.table-editable tbody td {
  vertical-align: top;
}

.table.table-editable input,
.table.table-editable select {
  height: 36px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.token-field {
  border: 1px solid #d3daea;
  border-radius: 10px;
  background: #f9fbff;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
}

.token-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #cbd6ec;
  border-radius: 999px;
  background: #eef3ff;
  color: #1d3f72;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.token-chip-remove {
  border: none;
  background: transparent;
  color: #44689f;
  cursor: pointer;
  font-size: 0.92rem;
  line-height: 1;
  padding: 0;
}

.token-chip-remove:hover {
  color: #1f3f72;
}

.token-entry {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
}

.token-entry .token-input {
  height: 34px;
}

.token-entry .token-add {
  height: 34px;
}

.row-remove {
  border-color: #e7ccd0;
  color: #9f2f38;
  background: #fff4f5;
}

.row-remove:hover {
  border-color: #dbb1b8;
  background: #ffe9eb;
}

.button.button-inline {
  height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.text-link {
  text-decoration: none;
  color: var(--secondary);
  font-weight: 600;
}

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.status-list li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed #d6dce7;
  padding-bottom: 8px;
}

.log-console {
  border-radius: 10px;
  border: 1px solid #d7dce8;
  background: #f8fafc;
  color: #253045;
  padding: 12px;
  max-height: 280px;
  overflow: auto;
  display: grid;
  gap: 6px;
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
}

.log-console-expanded {
  max-height: 460px;
}

.log-console span {
  color: #4f6485;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(210, 31, 38, 0.9), rgba(179, 20, 30, 0.82)),
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.12), transparent 44%);
}

.auth-card {
  width: min(540px, 100%);
  background: white;
  border-radius: 16px;
  border: 1px solid #e8dadd;
  padding: 30px;
  display: grid;
  gap: 16px;
  box-shadow: 0 30px 60px rgba(80, 15, 21, 0.2);
}

.auth-brand {
  display: flex;
  justify-content: center;
}

.auth-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid #e5e9f2;
  background: #fff;
}

.auth-card h1 {
  font-family: "Merriweather", serif;
  font-size: clamp(1.65rem, 4vw, 2.1rem);
}

.kicker {
  color: var(--primary-strong);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
}

.muted {
  color: var(--text-dim);
}

.error {
  color: var(--danger);
  border: 1px solid #efc0c4;
  background: #fff2f3;
  border-radius: 10px;
  padding: 9px 10px;
}

.footnote {
  color: var(--text-dim);
  font-size: 0.82rem;
}

@media (max-width: 980px) {
  .stats-grid,
  .panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .masthead-main {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-inner {
    gap: 8px;
    padding: 4px 10px;
  }

  .nav-primary {
    width: 100%;
  }

  .nav-side {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .nav-utility {
    margin-left: 0;
  }

  .nav-dropdown-menu {
    right: auto;
    left: 0;
  }

  .nav-item {
    padding: 10px 9px;
    font-size: 0.72rem;
  }

  .logout-form {
    margin-left: 0;
  }

  .topbar {
    padding: 16px;
    flex-direction: column;
  }

  .form.two-columns {
    grid-template-columns: 1fr;
  }

  .settings-group-grid {
    grid-template-columns: 1fr;
  }

  .inline-actions {
    flex-direction: column;
  }
}
