:root {
  --bg: #f3efe6;
  --ink: #1b2340;
  --muted: #5c6478;
  --accent: #2f6f7e;
  --card: #fffdf8;
  --line: rgba(27, 35, 64, 0.12);
  --sidebar: #1b2340;
  --sidebar-text: #f7f4ec;
  --sidebar-muted: rgba(247, 244, 236, 0.55);
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
  --sidebar-w: 15.5rem;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
}

h1,
h2 {
  font-family: var(--font);
  letter-spacing: -0.03em;
  margin: 0 0 0.6rem;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.2rem;
}

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

.error {
  color: #a33;
  min-height: 1.25rem;
}

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

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

#gift-days-custom,
#gift-campaign-days-custom {
  min-width: 7rem;
  width: 8rem;
}

.row.between {
  align-items: center;
  justify-content: space-between;
}

input,
select,
button {
  font: inherit;
  padding: 0.65rem 0.9rem;
  border-radius: 0.65rem;
  border: 1px solid var(--line);
}

input,
select {
  background: #fff;
  min-width: 8rem;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
}

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

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.1rem 1.15rem;
  margin: 0 0 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

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

.stat strong {
  display: block;
  font-size: 1.4rem;
  font-family: var(--font);
}

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

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

tr.needs-pix {
  background: #fdecec;
}

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

td a:hover {
  text-decoration: underline;
}

code {
  font-size: 0.88em;
}

.batch-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.batch-codes code {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  background: var(--bg);
  border-radius: 0.5rem;
  letter-spacing: 0.06em;
  font-size: 1rem;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(1200px 600px at 10% -10%, #fff8e8 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #d9ebe7 0%, transparent 50%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 28rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1.75rem 1.5rem 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.login-form .field {
  width: 100%;
}

.login-form input {
  width: 100%;
  min-width: 0;
  min-height: 3rem;
}

.login-form #btn-login,
#btn-google {
  min-height: 3rem;
  font-weight: 700;
  width: 100%;
}

#btn-google {
  margin-top: 0.65rem;
}

.error:not(:empty) {
  color: #8b1e1e;
  background: #fdecec;
  border: 1px solid #f0c4c4;
  border-radius: 0.65rem;
  padding: 0.75rem 0.9rem;
  min-height: 0;
  margin-top: 0.85rem;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 3rem;
}

.password-toggle {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.4rem;
  min-height: 2.5rem;
  min-width: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
}

.password-toggle:hover,
.password-toggle.is-on {
  color: var(--ink);
  background: rgba(27, 35, 64, 0.06);
}

/* App shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.35rem 1rem 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0 0.55rem 1.4rem;
  border-bottom: 1px solid rgba(247, 244, 236, 0.12);
  margin-bottom: 1rem;
}

.sidebar-brand a {
  font-family: var(--font);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--sidebar-text);
  text-decoration: none;
}

.sidebar-brand span {
  font-size: 0.8rem;
  color: var(--sidebar-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--sidebar-text);
  border: none;
  border-radius: 0.7rem;
  padding: 0.7rem 0.8rem;
  font-weight: 600;
}

.sidebar-nav button:hover {
  background: rgba(247, 244, 236, 0.08);
}

.sidebar-nav button.is-active {
  background: rgba(47, 111, 126, 0.95);
}

.sidebar-nav .soon {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.sidebar-foot {
  padding-top: 1rem;
  border-top: 1px solid rgba(247, 244, 236, 0.12);
}

.sidebar-foot .muted {
  color: var(--sidebar-muted);
  font-size: 0.82rem;
  word-break: break-all;
  margin: 0 0 0.7rem;
}

.sidebar-foot .secondary {
  color: var(--sidebar-text);
  border-color: rgba(247, 244, 236, 0.22);
  width: 100%;
}

.workspace {
  padding: 1.5rem 1.6rem 3rem;
  max-width: 72rem;
}

.table-wrap {
  overflow-x: auto;
}

.subscriber-search {
  max-width: 22rem;
  margin: 0.35rem 0 0.85rem;
}

.subscriber-search input {
  min-width: 0;
  width: 100%;
}

.workspace-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.menu-btn {
  display: none;
}

body.nav-open .sidebar {
  transform: translateX(0);
}

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

  .sidebar {
    position: fixed;
    z-index: 20;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .menu-btn {
    display: inline-flex;
  }
}
