* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --red: #dc2626;
  --orange: #ea580c;
  --green: #16a34a;
  --gray: #6b7280;
  --light: #f3f4f6;
  --border: #e5e7eb;
  --white: #ffffff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--light);
  color: #111827;
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--blue);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 20px; font-weight: 700; }
.header-user { font-size: 13px; opacity: 0.85; }

/* Nav */
.nav {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 57px;
  z-index: 99;
}
.nav button {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.nav button.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}
.nav-more {
  position: relative;
  display: flex;
  align-items: stretch;
}
.nav-more-btn {
  flex: none !important;
  padding: 12px 14px !important;
  font-size: 16px !important;
  line-height: 1;
}
.nav-more-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}
.nav-more-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
  white-space: nowrap;
}
.nav-more-dropdown.open {
  display: block;
}
.nav-more-dropdown button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray);
  cursor: pointer;
  border-bottom: none !important;
}
.nav-more-dropdown button:hover {
  background: #f9fafb;
}
.nav-more-dropdown button.active {
  color: var(--blue);
  background: #eff6ff;
}

/* Views */
.view { display: none; padding: 16px; }
.view.active { display: block; }

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Item rows */
.item {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.item.overdue { border-left: 4px solid var(--red); }
.item.due-soon { border-left: 4px solid var(--blue); }
.item.upcoming { border-left: 4px solid var(--blue); }
.item.no-date { border-left: 4px solid var(--gray); }

.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; overflow-wrap: break-word; }
.item-meta { font-size: 12px; color: var(--gray); margin-top: 2px; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 20px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.badge.overdue { background: #fee2e2; color: var(--red); }
.badge.due-soon { background: #dbeafe; color: var(--blue); }
.badge.upcoming { background: #dbeafe; color: var(--blue); }
.badge.no-date { background: var(--light); color: var(--gray); }

/* Buttons */
.btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: white; }
.btn-success { background: var(--green); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-ghost { background: var(--light); color: #374151; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:active { opacity: 0.85; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue); }

/* Login */
#login-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 24px;
  background: var(--blue);
}
#login-view h1 { color: white; font-size: 28px; margin-bottom: 8px; }
#login-view p { color: rgba(255,255,255,0.8); margin-bottom: 32px; font-size: 15px; }
#login-form,
#login-2fa,
#login-forgot,
#login-reset { background: white; border-radius: 16px; padding: 24px; width: 100%; max-width: 360px; }
#login-form .form-group label,
#login-2fa .form-group label,
#login-forgot .form-group label,
#login-reset .form-group label { color: #374151; }
#login-2fa p,
#login-forgot p,
#login-reset p { color: #6b7280; margin-bottom: 16px; font-size: 14px; }
#login-error { color: var(--red); font-size: 13px; margin-top: 8px; text-align: center; }

/* Section headers */
.section-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  margin: 20px 0 8px;
}
.section-header:first-child { margin-top: 0; }

/* Chat */
#chat-messages {
  height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 12px;
}
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}
.chat-msg.user { background: var(--blue); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg.assistant { background: white; border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg.thinking { color: var(--gray); font-style: italic; }

.chat-input-row { display: flex; gap: 8px; margin-top: 8px; }
.chat-input-row input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 24px; font-size: 14px; outline: none; }
.chat-input-row input:focus { border-color: var(--blue); }
.chat-input-row button { border-radius: 50%; width: 42px; height: 42px; padding: 0; font-size: 18px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: 20px 20px 0 0;
  padding: 24px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close { background: var(--light); border: none; border-radius: 50%; width: 32px; height: 32px; font-size: 18px; cursor: pointer; }

/* Fab */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 12px rgba(37,99,235,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
}

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--gray); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* Category group */
.category-group { margin-bottom: 20px; }
.category-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  padding: 4px 0;
  margin-bottom: 6px;
}

/* Logout */
.logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
}

#notif-btn {
  color: #f59e0b !important;
  font-size: 18px;
}

/* Actions row */
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Complete checkbox */
.complete-checkbox {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--green);
}
