:root {
  --ink: #12242b;
  --muted: #5b717a;
  --paper: #f3efe6;
  --panel: #fffdf8;
  --line: #d7cebf;
  --teal: #0f6b63;
  --teal-deep: #0a4a45;
  --teal-soft: #d8efe9;
  --sand: #e7c27d;
  --danger: #b42318;
  --ok: #1f7a4d;
  --shadow: 0 18px 50px rgba(18, 36, 43, 0.08);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 107, 99, 0.12), transparent 34%),
    linear-gradient(160deg, #efe8d8 0%, var(--paper) 45%, #e7f1ee 100%);
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; }
p { margin: 0; }

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--teal-deep), #083833 70%, #062f2b);
  color: #f7f3ea;
  padding: 1.5rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--sand);
  color: var(--teal-deep);
  font-family: var(--font-display);
  font-weight: 700;
  animation: rise 0.6s ease both;
}

.brand-text {
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.side-nav { display: grid; gap: 0.4rem; }
.nav-link {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  color: rgba(247, 243, 234, 0.78);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; transform: translateX(3px); }
.nav-link.active { background: rgba(231, 194, 125, 0.18); color: #fff; }

.sidebar-foot { margin-top: auto; }

.main-wrap { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  padding: 1.6rem 2rem 0.6rem;
  animation: fade-up 0.45s ease both;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.topbar h1 { font-size: clamp(1.7rem, 2vw, 2.2rem); }
.topbar-meta { display: flex; gap: 0.5rem; align-items: center; }
.content { padding: 1rem 2rem 2.5rem; }

.pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--teal-soft);
  color: var(--teal-deep);
}
.badge.ok { background: #dff3e7; color: var(--ok); }
.badge.off { background: #f4e3e1; color: var(--danger); }
.badge.pending { background: #fff0d6; color: #8a5a00; }
.row-latest td { background: rgba(15, 107, 99, 0.08); font-weight: 600; }

.grid { display: grid; gap: 1rem; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: 1.2fr 0.8fr; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.panel {
  background: var(--panel);
  border: 1px solid rgba(215, 206, 191, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  animation: fade-up 0.5s ease both;
}
.panel h2 { font-size: 1.25rem; margin-bottom: 0.35rem; }
.panel .sub { color: var(--muted); margin-bottom: 1rem; }

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-top: 0.55rem;
}
.stat-label { color: var(--muted); font-size: 0.9rem; }

.account-card {
  display: grid;
  gap: 0.85rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.account-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 40px rgba(18, 36, 43, 0.12);
}
.account-card .row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}
.balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.balance-box {
  background: linear-gradient(180deg, #f7f3ea, #eef7f4);
  border-radius: 14px;
  padding: 0.8rem;
}
.balance-box strong { display: block; font-family: var(--font-display); font-size: 1.2rem; }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
th { color: var(--muted); font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.btn {
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  padding: 0.75rem 1.1rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.92rem;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.full { width: 100%; }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 10px 24px rgba(15, 107, 99, 0.25); }
.btn-primary:hover { background: var(--teal-deep); }
.btn-secondary { background: #efe7d6; color: var(--ink); }
.btn-danger { background: #f4e3e1; color: var(--danger); }
.btn-ghost { background: transparent; color: #f7f3ea; border: 1px solid rgba(255,255,255,0.18); }

.form-grid { display: grid; gap: 0.9rem; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  font: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(15, 107, 99, 0.25);
  border-color: var(--teal);
}
.hint { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.validation { color: var(--danger); font-size: 0.85rem; }

.flash {
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
  animation: fade-up 0.35s ease both;
}
.flash.ok { background: #dff3e7; color: var(--ok); }
.flash.bad { background: #f4e3e1; color: var(--danger); }

/* Login */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-stage {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  overflow: hidden;
  border-radius: 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(215, 206, 191, 0.8);
  background: var(--panel);
  animation: fade-up 0.55s ease both;
}
.login-visual {
  position: relative;
  padding: 2.5rem;
  background:
    linear-gradient(160deg, rgba(10, 74, 69, 0.92), rgba(15, 107, 99, 0.85)),
    url("data:image/svg+xml,%3Csvg width='160' height='160' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 80h160M80 0v160' stroke='rgba(255,255,255,0.08)' stroke-width='1'/%3E%3C/svg%3E");
  color: #f7f3ea;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 520px;
}
.login-visual .brand-text { font-size: 3rem; animation: rise 0.7s ease both; }
.login-visual p {
  max-width: 22rem;
  margin-top: 0.8rem;
  line-height: 1.55;
  color: rgba(247, 243, 234, 0.84);
  animation: fade-up 0.7s 0.1s ease both;
}
.login-form {
  padding: 2.4rem;
  display: grid;
  align-content: center;
  gap: 1rem;
}
.login-form h1 { font-size: 2rem; }
.login-form .sub { color: var(--muted); margin-bottom: 0.5rem; }

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

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 32, 30, 0.55);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.35rem 1.2rem;
  animation: fade-up 0.25s ease both;
}
.modal-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.55rem;
}
.modal-message {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}
.modal-busy {
  color: var(--teal-deep);
  font-weight: 600;
  margin: 0;
  padding-top: 0.25rem;
}

.activity-feed {
  max-height: 520px;
  overflow: auto;
}
.activity-feed tbody tr:nth-child(odd) {
  background: rgba(15, 107, 99, 0.04);
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .grid.stats, .grid.two, .form-grid.two, .login-stage { grid-template-columns: 1fr; }
  .login-visual { min-height: 240px; }
  .content, .topbar { padding-left: 1.1rem; padding-right: 1.1rem; }
}
