:root {
  --bg: #0f1220;
  --panel: #171b2c;
  --panel-2: #202642;
  --text: #f5f7ff;
  --muted: #9aa4bf;
  --line: rgba(255,255,255,.08);
  --accent: #4f8cff;
  --accent-2: #34d399;
  --gold: #f4c95d;
  --orange: #fb923c;
  --gray: #8a93a8;
  --red: #f87171;
  --shadow: 0 18px 55px rgba(0,0,0,.34);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -10%, rgba(79,140,255,.22), transparent 34rem),
    linear-gradient(180deg, #11162a 0%, var(--bg) 18rem);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: 0;
  padding: env(safe-area-inset-top) 0 calc(86px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

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

button {
  color: inherit;
}

.shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
}

.auth-screen {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
}

.auth-card {
  display: grid;
  gap: 12px;
  padding: 22px 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 8px;
}

.auth-error {
  color: #fecaca;
  text-align: center;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
  background: rgba(15,18,32,.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.caption {
  margin: 0 0 1px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  text-align: center;
}

h2,
h3,
p {
  margin: 0;
}

.content {
  padding: 14px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  display: grid;
  place-items: center;
  font-size: 23px;
}

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

.logout-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 9px;
}

.icon-button:active,
.logout-button:active,
.button:active,
.chip:active,
.card:active {
  transform: translateY(1px);
}

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

.counter {
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.065), rgba(255,255,255,.035));
}

.counter strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  margin-bottom: 8px;
}

.counter span,
.muted,
.meta,
.empty,
.loading {
  color: var(--muted);
}

.counter span {
  display: block;
  font-size: 13px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 2px 10px;
}

.section-title h2 {
  font-size: 17px;
}

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

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset;
  padding: 14px;
}

.card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card h3 {
  font-size: 16px;
  line-height: 1.25;
}

.meta {
  font-size: 13px;
  margin-top: 6px;
}

.text {
  margin-top: 10px;
  color: #d7dded;
}

.two-lines {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -14px 12px;
  padding: 0 14px 4px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  color: #dce4f8;
  white-space: nowrap;
}

.chip.active {
  border-color: rgba(79,140,255,.65);
  background: rgba(79,140,255,.22);
  color: var(--text);
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  line-height: 1.1;
  border: 1px solid transparent;
  color: var(--text);
}

.status-new { background: rgba(79,140,255,.16); border-color: rgba(79,140,255,.35); }
.status-work { background: rgba(52,211,153,.14); border-color: rgba(52,211,153,.34); }
.status-wait { background: rgba(244,201,93,.14); border-color: rgba(244,201,93,.36); }
.status-done { background: rgba(52,211,153,.2); border-color: rgba(52,211,153,.45); }
.status-bad { background: rgba(248,113,113,.16); border-color: rgba(248,113,113,.38); }
.status-muted { background: rgba(154,164,191,.12); border-color: rgba(154,164,191,.25); }

.priority {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  font-size: 12px;
  font-weight: 700;
}

.priority-high { color: var(--gold); }
.priority-mid { color: var(--orange); }
.priority-low { color: var(--gray); }

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.actions.single {
  grid-template-columns: 1fr;
}

.button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,.07);
  color: var(--text);
  font-weight: 700;
  padding: 11px 12px;
}

.button.primary {
  background: var(--accent);
}

.button.good {
  background: rgba(52,211,153,.2);
  border-color: rgba(52,211,153,.38);
}

.button.soft {
  background: rgba(79,140,255,.16);
  border-color: rgba(79,140,255,.3);
}

.button.warn {
  background: rgba(244,201,93,.14);
  border-color: rgba(244,201,93,.3);
}

.button.full {
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11172a;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  color-scheme: dark;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(79,140,255,.65);
}

.field select.readonly:disabled {
  opacity: 1;
  color: var(--text);
  background: rgba(79,140,255,.12);
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: -2px 0 0;
}

.empty,
.loading,
.error {
  padding: 28px 14px;
  text-align: center;
}

.error {
  border: 1px solid rgba(248,113,113,.35);
  border-radius: 8px;
  background: rgba(248,113,113,.12);
  color: #fecaca;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(100%, 480px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: rgba(15,18,32,.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  min-height: 55px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.bottom-nav span {
  display: block;
  font-size: 20px;
  line-height: 1.1;
  margin-bottom: 2px;
}

.bottom-nav button.active {
  background: rgba(79,140,255,.14);
  color: var(--text);
}

.shade {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,.58);
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 31;
  width: min(100%, 480px);
  max-height: 84vh;
  overflow: auto;
  transform: translateX(-50%);
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: #151a2c;
  box-shadow: var(--shadow);
}

.sheet h2 {
  font-size: 18px;
  margin: 6px 2px 12px;
}

.sheet-list {
  display: grid;
  gap: 8px;
}

.sheet-actions {
  display: grid;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 40;
  width: min(92%, 430px);
  transform: translateX(-50%);
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(245,247,255,.96);
  color: #11172a;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 700;
}

a {
  color: #9ec1ff;
  text-decoration: none;
}

@media (min-width: 481px) {
  body {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}
