:root {
  --brand: #b13033;
  --brand-deep: #8e1f22;
  --brand-soft: #f8e8e8;
  --steel: #1b6ca8;
  --steel-soft: #e4f0fa;
  --ink: #172033;
  --muted: #5b667a;
  --line: #d5dde8;
  --panel: #ffffff;
  --ok: #1f7a3f;
  --ok-soft: #e6f5eb;
  --warn: #b35a00;
  --warn-soft: #fff1e0;
  --danger: #9f1d28;
  --danger-soft: #fde8ea;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
  --radius: 16px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-ui: "Manrope", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(177, 48, 51, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(27, 108, 168, 0.14), transparent 50%),
    linear-gradient(180deg, #f5f7fb 0%, #eef2f7 45%, #f7f4f5 100%);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.brand-mark {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}
.brand-mark--sm { font-size: 0.65rem; letter-spacing: 0.12em; }

/* ---------- LOGIN ---------- */
.login-shell {
  position: relative;
  min-height: 100dvh;
  display: grid;
  align-items: end;
  overflow: hidden;
}

.login-hero {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(145deg, #6f1619 0%, #b13033 42%, #1b6ca8 100%);
}
.login-hero__wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.18), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(0,0,0,0.18), transparent 45%),
    linear-gradient(180deg, transparent 35%, rgba(10, 16, 28, 0.55) 100%);
  animation: wash-drift 12s ease-in-out infinite alternate;
}
.login-hero__grid {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255,255,255,0.25) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.25) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.7), transparent 85%);
}

.login-content {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 28px 20px calc(28px + var(--safe-b));
  color: #fff;
}

.login-logo {
  width: min(220px, 70vw);
  height: auto;
  margin-bottom: 18px;
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
}

.login-title {
  margin: 8px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 2.6rem);
  line-height: 1.05;
  font-weight: 700;
}
.login-lede {
  margin: 0 0 22px;
  color: rgba(255,255,255,0.86);
  line-height: 1.45;
  max-width: 34ch;
}
.login-hint {
  margin: 16px 0 0;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.72);
}
.login-hint strong { color: #fff; }

.login-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.96);
  color: var(--ink);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.field { display: grid; gap: 6px; font-size: 0.9rem; font-weight: 600; }
.field span { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.02em; }
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: #fbfcfe;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(27, 108, 168, 0.15);
}

.password-wrap { position: relative; }
.password-wrap input { padding-right: 68px; }
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--steel);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px;
}

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-secondary { background: var(--steel); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line);
}
.btn-approve { background: var(--ok); color: #fff; }
.btn-reject { background: var(--steel); color: #fff; }

.form-alert {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
}
.form-alert--error,
.form-alert.error { background: var(--danger-soft); color: var(--danger); }
.form-alert.ok,
.form-alert--ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- APP SHELL ---------- */
.app-shell {
  min-height: 100dvh;
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 12px 14px calc(var(--nav-h) + var(--safe-b) + 18px);
  animation: fade-in 0.35s ease;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.app-header__brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.app-header__logo {
  width: 64px;
  height: auto;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  border: 1px solid var(--line);
}
.app-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.1;
}
.app-header__user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 800;
  font-size: 0.78rem;
  flex: 0 0 auto;
}
.user-copy {
  display: grid;
  min-width: 0;
}
.user-copy strong {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.user-copy span {
  color: var(--muted);
  font-size: 0.75rem;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.summary-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.summary-item strong {
  font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  font-weight: 800;
}

.section-head { margin-bottom: 14px; }
.section-head--row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}
.section-head--row > div:first-child { flex: 1 1 200px; }
.export-duty {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.export-duty input[type="month"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
}
.feed-actions--wrap { flex-wrap: wrap; }
.status.BLOCKED { background: var(--danger-soft); color: var(--danger); }
.section-head h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.45rem;
}
.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
}
.chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.feed {
  display: grid;
  gap: 10px;
}
.feed-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow);
  animation: rise-soft 0.35s ease both;
}
.feed-item:nth-child(2) { animation-delay: 0.04s; }
.feed-item:nth-child(3) { animation-delay: 0.08s; }
.feed-item:nth-child(4) { animation-delay: 0.12s; }

.feed-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 6px;
}
.feed-top h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}
.feed-amount {
  font-weight: 800;
  white-space: nowrap;
}
.feed-desc {
  margin: 0 0 8px;
  color: var(--ink);
  line-height: 1.4;
}
.feed-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.feed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.feed-actions .btn { flex: 1 1 120px; }

.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.status.PENDING { background: var(--warn-soft); color: var(--warn); }
.status.APPROVED { background: var(--ok-soft); color: var(--ok); }
.status.REJECTED { background: var(--danger-soft); color: var(--danger); }
.status.IN { background: var(--ok-soft); color: var(--ok); }
.status.OUT { background: var(--steel-soft); color: var(--steel); }

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  background: rgba(255,255,255,0.7);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.duty-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.duty-actions .btn { min-height: 48px; }

.stack-form {
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ---------- BOTTOM NAV ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(255,255,255,0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: 20;
}
.bottom-nav.has-admin {
  grid-template-columns: repeat(5, 1fr);
}
.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 12px;
}
.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.nav-item.is-active {
  color: var(--brand);
  background: var(--brand-soft);
}

.tab-panel { animation: fade-in 0.28s ease; }

/* ---------- MOTION ---------- */
@keyframes wash-drift {
  from { transform: scale(1) translateY(0); }
  to { transform: scale(1.05) translateY(-12px); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes rise-soft {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-rise { animation: rise-soft 0.55s ease both; }

@media (min-width: 768px) {
  .login-shell {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: stretch;
  }
  .login-hero { position: relative; min-height: 100dvh; }
  .login-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0;
    width: 100%;
    max-width: none;
    padding: 48px;
    background: #f7f9fc;
    color: var(--ink);
  }
  .login-lede { color: var(--muted); }
  .login-hint { color: var(--muted); }
  .login-hint strong { color: var(--ink); }
  .login-form {
    background: #fff;
    border: 1px solid var(--line);
  }
  .app-shell { padding-top: 24px; padding-bottom: 100px; }
  .user-copy strong { max-width: 220px; }
  .duty-actions { max-width: 420px; }
}

@media (max-width: 420px) {
  .app-header__user .btn-ghost { padding-inline: 10px; }
  .user-copy { display: none; }
}
