:root {
  --navy: #0b2a4a;
  --ink: #102033;
  --muted: #617486;
  --turquoise: #16b8c7;
  --green: #3aa76d;
  --amber: #d9952f;
  --coral: #d75f4f;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-2: #eaf3f7;
  --line: #d7e4eb;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(11, 42, 74, .08);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f8fcfd 0%, var(--bg) 100%);
}

button, input, textarea, select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--navy);
  padding: 0 14px;
  font-weight: 800;
}

button:active {
  transform: translateY(1px);
}

.primary {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.danger {
  color: var(--danger);
  border-color: rgba(180, 35, 24, .28);
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  color: var(--navy);
  font-size: 23px;
  line-height: 1.1;
}

h2 {
  color: var(--navy);
  font-size: 23px;
  line-height: 1.16;
}

h3 {
  color: var(--navy);
  font-size: 16px;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 54px;
  height: 54px;
}

.login-copy {
  color: var(--muted);
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-status {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  max-width: 1120px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(90px + env(safe-area-inset-bottom));
}

.app-shell.locked {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 14px;
  background: rgba(245, 248, 251, .94);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--turquoise));
  font-weight: 950;
  font-size: 24px;
}

.eyebrow {
  color: #087e8b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 950;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button {
  width: auto;
  min-width: 48px;
  padding: 0 10px;
  border-color: rgba(22, 184, 199, .35);
  background: #eefafd;
  color: var(--navy);
  font-size: 12px;
}

.main {
  display: grid;
  gap: 14px;
}

.hero-panel,
.panel,
.input-card,
.item,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 14px;
  align-items: end;
  padding: 16px;
}

.panel,
.input-card,
.item,
.empty {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.empty {
  color: var(--muted);
  box-shadow: none;
}

.split-grid,
.system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid.mini {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 13px;
}

.stat strong {
  display: block;
  color: var(--navy);
  font-size: 24px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat.accent {
  border-color: rgba(22, 184, 199, .45);
  background: #ebfbfd;
}

.segmented {
  display: flex;
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.segmented.wrap {
  flex-wrap: nowrap;
}

.chip {
  flex: 1 0 auto;
  min-width: 84px;
  border: 0;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.chip.active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 3px 12px rgba(11, 42, 74, .08);
}

.form-grid,
.inline-form {
  display: grid;
  gap: 9px;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.form-grid.compact {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.button-row,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stack {
  display: grid;
  gap: 10px;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.item-title {
  color: var(--navy);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.item.done {
  opacity: .68;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.file-input {
  display: inline-grid;
  width: fit-content;
  border: 1px dashed #087e8b;
  border-radius: 8px;
  padding: 12px;
  color: var(--navy);
}

.file-input input {
  display: none;
}

.system-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.system-row span {
  color: var(--muted);
  font-weight: 800;
}

.system-row strong {
  color: var(--navy);
  text-align: right;
  overflow-wrap: anywhere;
}

a {
  color: #087e8b;
  font-weight: 900;
}

.json-view {
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.notice {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(22, 184, 199, .45);
  border-radius: 8px;
  background: #ebfbfd;
  color: var(--navy);
  padding: 14px;
  overflow-wrap: anywhere;
}

.danger-text {
  border-color: rgba(180, 35, 24, .28);
  background: #fff7f6;
  color: var(--danger);
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 5;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  width: min(1120px, 100%);
  padding: 9px 9px max(9px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(14px);
}

.nav-item {
  min-height: 54px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 4px;
  font-size: 12px;
}

.nav-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item.active {
  background: var(--navy);
  color: #fff;
}

.nav-item.nav-core.active {
  background: #087e8b;
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 11px;
  }

  .hero-panel,
  .split-grid,
  .system-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 21px;
  }

  h2 {
    font-size: 21px;
  }

  .button-row button,
  .item-actions button {
    flex: 1;
  }

  .top-actions {
    gap: 6px;
  }

  .icon-button {
    min-width: 44px;
    font-size: 11px;
  }
}
