:root {
  --ink: #142033;
  --muted: #5b6b80;
  --paper: #eef3f9;
  --card: #f8fbff;
  --line: #c9d6e8;
  --forest: #1a4f8a;
  --forest-2: #2563a8;
  --brass: #4ea1e0;
  --brass-soft: #d7ebfb;
  --danger: #a33a3a;
  --danger-soft: #f6dede;
  --ok: #1f6f7a;
  --ok-soft: #d5eef1;
  --warn: #8a5a16;
  --warn-soft: #f6e7c8;
  --shadow: 0 10px 30px rgba(20, 48, 88, 0.10);
  --radius: 18px;
  --nav: 68px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
}
body {
  font-family: Outfit, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
a { color: inherit; }

.app-shell {
  width: 100%;
  max-width: 560px;
  min-height: 100svh;
  margin: 0 auto;
  position: relative;
  background: #f7fafc;
  display: flex;
  flex-direction: column;
}

.desktop-only { display: none !important; }
.mobile-only { display: grid; gap: 12px; }
.desktop-columns { display: grid; gap: 12px; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.toolbar .search { flex: 1 1 200px; margin-bottom: 0; }
.actions-row { justify-content: flex-start; gap: 8px; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #eef4fb;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tfoot td {
  background: #f3f7fc;
  font-weight: 600;
}
.data-table .btn { padding: 8px 12px; font-size: 13px; }
.app-shell.auth-only {
  min-height: auto;
  background: transparent;
}

.page {
  padding: 16px 14px 20px;
  flex: 1 1 auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
}

h1, h2, .serif {
  font-family: Fraunces, Georgia, serif;
  font-weight: 560;
  letter-spacing: -0.03em;
}

h1 { font-size: 28px; margin: 0; line-height: 1.15; }
h2 { font-size: 20px; margin: 0 0 10px; }

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  max-width: min(42vw, 160px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.sync-pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.sync-pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.sync-pill.dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.list-item {
  display: block;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
}
.list-item strong { display: block; font-size: 16px; }
.list-item span, .meta { color: var(--muted); font-size: 13px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge.due { background: var(--danger-soft); color: var(--danger); }
.badge.wait { background: var(--warn-soft); color: var(--warn); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.neutral { background: #dce8f5; color: #2a4668; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--forest);
  color: #f7f1e4;
  font-weight: 600;
  cursor: pointer;
}
.btn.secondary { background: #d9e6f5; color: var(--ink); }
.btn.ghost { background: transparent; color: var(--forest-2); padding-inline: 8px; }
.btn.danger { background: var(--danger); }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  cursor: pointer;
}

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }

.nav {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  flex: 0 0 auto;
  height: var(--nav);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(248, 251, 255, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.nav a {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}
.nav a.active {
  color: var(--forest);
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--forest);
}

.hero-auth {
  padding: 12px 16px 24px;
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
}
.hero-auth h1 {
  font-size: 22px;
  margin: 0;
}
.hero-auth .auth-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hero-auth .auth-head > div { min-width: 0; }
.mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, #163a6b, #1a4f8a 55%, #2f79c5);
  color: #b7dcff;
  display: grid;
  place-items: center;
  font-family: Fraunces, serif;
  font-size: 20px;
  flex-shrink: 0;
}
.hero-auth .stack { gap: 10px; }
.hero-auth input { padding: 11px; }
.hero-auth .btn { padding: 12px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: linear-gradient(160deg, #163a6b, #1f5f9e);
  color: #eef6ff;
  border-radius: 16px;
  padding: 14px;
}
.stat.alt { background: linear-gradient(160deg, #0f2b4d, #245f9a); }
.stat b { display: block; font-size: 26px; font-family: Fraunces, serif; }
.stat span { opacity: 0.75; font-size: 12px; }

.search {
  width: 100%;
  margin-bottom: 12px;
}

.lines { display: grid; gap: 8px; }
.line {
  display: grid;
  grid-template-columns: 1fr 88px 36px;
  gap: 8px;
  align-items: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 20;
  max-width: min(480px, 92vw);
}

.empty {
  text-align: center;
  padding: 28px 10px;
  color: var(--muted);
}
.empty strong { display: block; color: var(--ink); margin-bottom: 6px; }

.hidden { display: none !important; }

@media (min-width: 760px) {
  body {
    padding: 0;
    background:
      radial-gradient(1000px 480px at 12% -8%, #d9e9fb, transparent 55%),
      radial-gradient(800px 420px at 100% 0%, #cfe0f5, transparent 45%),
      var(--paper);
  }
  .app-shell {
    min-height: 100dvh;
    box-shadow: var(--shadow);
  }
}

@media (min-width: 900px) {
  body { padding: 20px 16px; }
  .app-shell {
    display: flex;
    flex-direction: column;
    max-width: 1180px;
    min-height: calc(100dvh - 40px);
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
  }
  .app-shell.auth-only {
    max-width: 480px;
    min-height: auto;
    overflow: visible;
  }
  .page {
    padding: 28px 32px 36px;
    overflow: auto;
  }
  .nav {
    height: 56px;
    padding: 0 16px;
    background: #f3f7fc;
  }
  .nav a {
    flex-direction: row;
    gap: 8px;
    font-size: 14px;
  }
  .nav a.active {
    background: transparent;
    box-shadow: inset 0 -3px 0 var(--forest);
  }
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
  .desktop-columns {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
  .stat-grid { max-width: 520px; }
  form.card,
  form.stack.card {
    max-width: 640px;
  }
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  h1 { font-size: 32px; }
}

@media print {
  body { background: #fff; padding: 0; }
  .nav, .sync-pill, .actions-row, .toolbar .btn { display: none !important; }
  .app-shell {
    display: block;
    max-width: none;
    box-shadow: none;
    border-radius: 0;
  }
  .page { padding: 0; }
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
}
