:root {
  --primary: #2c5f4f;
  --primary-light: #e8f0ed;
  --text: #1f2a26;
  --muted: #6b7a74;
  --border: #dde5e1;
  --danger: #b03a2e;
  --bg: #fafbfa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: white;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  width: 90%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 { margin: 0; color: var(--primary); }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; }

input, button {
  font-size: 1rem;
  padding: 0.75rem;
  width: 100%;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

button:hover { opacity: 0.9; }

.error-text { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; }

.app-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.app-header h1 { margin: 0; color: var(--primary); font-size: 1.4rem; }

#category-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

#category-nav button {
  width: auto;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

#category-nav button.active { background: var(--primary); color: white; }

#logout-btn { width: auto; background: transparent; color: var(--muted); border: 1px solid var(--border); }

#main-content { padding: 1.5rem; max-width: 900px; margin: 0 auto; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

#add-item-btn { width: auto; }

.item-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
}

.item-card h3 { margin: 0 0 0.25rem; }
.item-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.alert-badge {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  background: #fdecea;
  color: var(--danger);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

#chat-messages { max-height: 300px; overflow-y: auto; margin-bottom: 0.75rem; }
.chat-msg { padding: 0.6rem 0.9rem; border-radius: 8px; margin-bottom: 0.5rem; }
.chat-msg.user { background: var(--primary-light); text-align: right; }
.chat-msg.assistant { background: #f0f0f0; }

#chat-form { display: flex; gap: 0.5rem; }
#chat-form input { margin-bottom: 0; }
#chat-form button { width: auto; }

#back-to-list { width: auto; background: transparent; color: var(--muted); margin-bottom: 1rem; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  z-index: 100;
}

.modal-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
}

.modal-card h2 { margin-top: 0; color: var(--primary); }

.modal-card label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.modal-card input, .modal-card textarea {
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.modal-actions button { width: auto; flex: 1; }
.modal-actions button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

.doc-upload {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.doc-upload-btn {
  display: inline-block;
  width: auto;
  padding: 0.6rem 1rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.doc-upload-btn:hover { opacity: 0.85; }

#doc-upload-status { color: var(--muted); font-size: 0.85rem; width: 100%; margin: 0.5rem 0 0; }
