:root {
  --ink: #152028;
  --ink-soft: #3d4a55;
  --muted: #6b7782;
  --line: #e4e8ec;
  --surface: #f7f5f1;
  --panel: #ffffff;
  --accent: #0f5c57;
  --accent-hover: #0a4743;
  --accent-soft: #e5f1f0;
  --danger: #9b2c2c;
  --danger-soft: #f8e8e8;
  --warn: #8a5a12;
  --warn-soft: #f7efdf;
  --ok: #1f6b3a;
  --ok-soft: #e6f4ea;
  --shadow: 0 18px 50px rgba(21, 32, 40, 0.08);
  --radius: 14px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Newsreader", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 550;
  letter-spacing: -0.02em;
  margin: 0;
}

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

.brand-mark {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

/* Auth */
.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 18%, rgba(15, 92, 87, 0.12), transparent 36%),
    linear-gradient(145deg, #eef2f1 0%, #f7f5f1 48%, #ebe6de 100%);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}

.auth-aside {
  padding: clamp(2rem, 5vw, 4.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  max-width: 34rem;
}

.auth-aside h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.12;
}

.auth-lede {
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 28rem;
}

.auth-main {
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-form {
  width: min(100%, 24rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.95rem;
}

.auth-form h2 {
  font-size: 1.7rem;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
}

.auth-form label span,
.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  background: #fbfbfa;
  color: var(--ink);
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(15, 92, 87, 0.25);
  border-color: var(--accent);
  background: #fff;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

.alert {
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-size: 0.92rem;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.alert-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

/* App shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 15.5rem 1fr;
}

.sidebar {
  background: #132028;
  color: #edf2f4;
  padding: 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar .brand-mark {
  color: #fff;
  padding: 0 0.55rem;
}

.side-nav {
  display: grid;
  gap: 0.25rem;
}

.side-nav a {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 500;
}

.side-nav a:hover,
.side-nav a.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 0.55rem;
}

.side-user {
  margin: 0;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.6);
}

.main {
  padding: clamp(1.25rem, 3vw, 2.25rem);
}

.view {
  max-width: 1120px;
}

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

.page-head h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.page-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: inherit;
  border: 1px solid transparent;
}

.sidebar .btn-ghost {
  color: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.14);
}

.btn-secondary {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.86rem;
}

.btn-block {
  width: 100%;
}

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

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.stat .label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.stat .value {
  font-family: var(--display);
  font-size: 2rem;
  margin-top: 0.25rem;
  letter-spacing: -0.03em;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel + .panel {
  margin-top: 1rem;
}

.panel-head {
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-head h2 {
  font-size: 1.15rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

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

.row-link {
  font-weight: 600;
  color: var(--accent);
}

.row-link:hover {
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-off {
  background: #eef1f4;
  color: var(--muted);
}

.empty {
  padding: 2rem 1.1rem;
  color: var(--muted);
  text-align: center;
}

.loading-state {
  color: var(--muted);
  padding: 2rem 0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.key-reveal {
  background: #132028;
  color: #e8f2f1;
  border-radius: 12px;
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.key-reveal code {
  word-break: break-all;
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.check input {
  width: auto;
}

.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 40;
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: min(24rem, calc(100vw - 2rem));
}

.modal {
  border: 0;
  border-radius: calc(var(--radius) + 2px);
  padding: 0;
  width: min(34rem, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(17, 24, 28, 0.45);
}

.modal-form {
  display: grid;
}

.modal-head,
.modal-foot,
.modal-body {
  padding: 1rem 1.15rem;
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-head {
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #eef1f4;
  border: 1px solid var(--line);
}

.stack-meta {
  display: grid;
  gap: 0.15rem;
}

.stack-meta small {
  color: var(--muted);
}

.bar-list {
  display: grid;
  gap: 0.75rem;
  padding: 1.1rem;
}

.bar-item {
  display: grid;
  gap: 0.35rem;
}

.bar-item-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.92rem;
}

.bar-track {
  height: 8px;
  background: #eef1f4;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f5c57, #2a8f87);
  border-radius: inherit;
}

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

  .sidebar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .side-nav {
    display: flex;
    flex-wrap: wrap;
  }

  .sidebar-foot {
    margin-top: 0;
    border-top: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0;
  }

  .stat-grid,
  .grid-2,
  .field-row,
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-aside {
    max-width: none;
    padding-bottom: 0;
  }
}
