:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --accent-ok: #4caf50;
  --accent-bad: #ef5350;
  --border: #2a2a2a;
  --focus: #81c784;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent-ok);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.75rem;
}

h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  letter-spacing: 0.02em;
}

label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #141414;
  color: var(--text);
  font-size: 1rem;
}

input:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.field {
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent-ok);
  color: #0b0b0b;
}

.btn:hover {
  filter: brightness(1.08);
}

.flash {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.flash li {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
}

.flash li.error {
  border-color: rgba(239, 83, 80, 0.45);
  color: #ffcdd2;
}

.flash li.info {
  border-color: rgba(129, 199, 132, 0.35);
  color: #c8e6c9;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ——— App shell (post-login) ——— */
.wrap--app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.app-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-nav__brand {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.03em;
}

.app-nav__brand:hover {
  text-decoration: none;
  color: var(--accent-ok);
}

.app-nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  font-size: 0.95rem;
}

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

.app-nav__logout:hover {
  color: #ffcdd2;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-block {
  margin-top: 2rem;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.text-bad {
  color: var(--accent-bad);
}

/* Metrics & funnel */
.grid-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.metric__label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric__value {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0.35rem 0;
}

.metric__value--ok {
  color: var(--accent-ok);
}

.metric__value--neutral {
  color: var(--text);
}

.metric__hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.funnel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.funnel__step {
  min-width: 120px;
  text-align: center;
  padding: 1rem 1.25rem;
}

.funnel__step--ok .funnel__n {
  color: var(--accent-ok);
}

.funnel__n {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
}

.funnel__lbl {
  font-size: 0.85rem;
  color: var(--muted);
}

.funnel__arrow {
  color: var(--muted);
  font-size: 1.25rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #141414;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  background: #181818;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(76, 175, 80, 0.04);
}

.data-table__actions {
  white-space: nowrap;
}

.data-table__actions--stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.cell-password {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.password-mask {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Forms */
.card--form {
  max-width: 520px;
}

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

@media (max-width: 520px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.field--check {
  margin-bottom: 1rem;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text);
}

.input-textarea,
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #141414;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.input-textarea {
  resize: vertical;
  min-height: 72px;
}

select {
  cursor: pointer;
}

.field-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 0.5rem;
}

.form-inline {
  display: inline;
  margin: 0;
}

/* Buttons */
.btn--inline {
  width: auto;
  display: inline-flex;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
}

.btn--tiny {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  width: auto;
  font-weight: 600;
}

.btn--secondary {
  background: #2e7d32;
  color: #fff;
}

.btn--secondary:hover {
  filter: brightness(1.1);
}

.btn--danger {
  background: #c62828;
  color: #fff;
}

.btn--danger:hover {
  filter: brightness(1.08);
}

.btn-copy {
  background: #2a2a2a;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-copy:hover:not(:disabled) {
  border-color: var(--accent-ok);
  color: var(--accent-ok);
}

.btn-copy:disabled {
  opacity: 0.85;
  cursor: default;
}

.link-action {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent-ok);
  cursor: pointer;
  text-decoration: underline;
}

.link-action--danger {
  color: var(--accent-bad);
}

.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: #2a2a2a;
  border: 1px solid var(--border);
}

.pill--ok {
  border-color: rgba(76, 175, 80, 0.45);
  color: #c8e6c9;
}

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

.pill--bad {
  border-color: rgba(239, 83, 80, 0.45);
  color: #ffcdd2;
}

.tamano-block {
  scroll-margin-top: 1rem;
}

.tamano-count {
  margin: -0.35rem 0 0.65rem;
}

.data-table--actions-wide .data-table__actions {
  min-width: 14rem;
}

@media (min-width: 900px) {
  .data-table--actions-wide .data-table__actions {
    min-width: 15.5rem;
  }
}

.form-stack--advance {
  min-width: 12.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 0.5rem;
}

.form-stack--advance:last-of-type {
  border-bottom: none;
}

.input-text-tiny::placeholder {
  color: var(--muted);
  font-size: 0.75rem;
}

.select-tiny {
  max-width: 100%;
  font-size: 0.8rem;
}

.form-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.form-stack:last-child {
  margin-bottom: 0;
}

.label-tiny {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-datetime-tiny {
  width: 100%;
  max-width: 11.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #141414;
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
}

.input-datetime-tiny:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}
