:root {
  color-scheme: dark;
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-raised: #22252f;
  --border: rgba(255, 255, 255, 0.06);
  --text: #e4e4e7;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #34d399;
  --danger: #f87171;
  --sidebar-w: 220px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

a { color: var(--accent-hover); text-decoration: none; }

/* --- SIDEBAR --- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  left: 0;
  position: fixed;
  top: 0;
  width: var(--sidebar-w);
  z-index: 100;
}

.sidebar-brand {
  align-items: center;
  border-bottom: 1px solid var(--border);
  color: #fff;
  display: flex;
  font-size: 1.1rem;
  font-weight: 700;
  gap: 0.6rem;
  letter-spacing: -0.03em;
  padding: 1.25rem 1.2rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
  padding: 0.75rem 0.6rem;
}

.sidebar-nav a {
  align-items: center;
  border-radius: 8px;
  color: var(--text-muted);
  display: flex;
  font-size: 0.88rem;
  font-weight: 500;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--text);
}

.sidebar-nav a.active {
  color: var(--accent-hover);
}

.sidebar-nav .nav-icon {
  font-size: 1.1rem;
  width: 1.4rem;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.2rem;
}

.sidebar-footer .user-name {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

.sidebar-footer .user-email {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.sidebar-footer .logout-link {
  color: var(--text-muted);
  display: inline-block;
  font-size: 0.75rem;
  margin-top: 0.4rem;
}

/* --- MAIN --- */

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 960px;
  width: 100%;
}

/* --- CAPTURE BAR --- */

.capture-bar {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.6rem;
}

.capture-bar textarea {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1;
  font: inherit;
  font-size: 0.9rem;
  min-height: 2.4rem;
  outline: none;
  padding: 0.5rem 0.6rem;
  resize: none;
}

.capture-bar textarea::placeholder {
  color: var(--text-muted);
}

.capture-bar button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  white-space: nowrap;
  align-self: flex-end;
}

.capture-bar button.voice-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.capture-bar button.voice-btn.listening {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* --- ITEM LIST --- */

.item-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.item-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: auto 1fr auto;
  margin-bottom: 0.5rem;
  padding: 1rem 1.2rem;
  transition: border-color 0.15s;
}

.item-row:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.item-intent {
  align-self: start;
  background: var(--surface-raised);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.5rem;
  text-transform: uppercase;
}

.item-intent.remind { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.item-intent.tell { color: #60a5fa; background: rgba(96, 165, 250, 0.1); }
.item-intent.schedule { color: #34d399; background: rgba(52, 211, 153, 0.1); }
.item-intent.forward { color: #c084fc; background: rgba(192, 132, 252, 0.1); }
.item-intent.note, .item-intent.idea { color: var(--text-muted); }

.item-body {
  min-width: 0;
}

.item-text {
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 0.3rem;
}

.item-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.item-agent-note {
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
  padding-left: 0.6rem;
}

.item-actions {
  align-self: center;
  display: flex;
  gap: 0.4rem;
}

.item-actions form {
  display: inline;
}

.btn {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }

.btn-approve {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.btn-reject {
  background: rgba(248, 113, 113, 0.1);
  color: var(--danger);
}

.btn-done {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-hover);
}

.btn-archive {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-hover);
}

.btn-email {
  background: rgba(96, 165, 250, 0.1);
  color: #60a5fa;
}

.btn-delete {
  background: rgba(248, 113, 113, 0.08);
  color: var(--danger);
}

.action-detail {
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.78rem;
  margin-top: 0.5rem;
  padding: 0.6rem 0.8rem;
}

.action-detail strong {
  color: var(--text);
  text-transform: capitalize;
}

.action-detail .action-status {
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.5rem;
  padding: 0.15rem 0.4rem;
}

.action-detail .action-status.pending { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.action-detail .action-status.executed { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.action-detail .action-status.rejected { background: rgba(248, 113, 113, 0.1); color: var(--danger); }
.action-detail .action-status.failed { background: rgba(248, 113, 113, 0.1); color: var(--danger); }

.action-detail pre {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 0.3rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.action-error {
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

.empty-state {
  color: var(--text-muted);
  padding: 3rem 1rem;
  text-align: center;
}

.empty-state p {
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* --- LOGIN --- */

.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  margin-left: 0;
  min-height: 100vh;
  width: 100%;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 380px;
  padding: 2.5rem 2rem;
  width: 100%;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-stack {
  display: grid;
  gap: 1rem;
}

.form-stack label {
  color: var(--text-muted);
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}

.form-stack input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 0.7rem 0.8rem;
  width: 100%;
}

.form-stack input:focus {
  border-color: var(--accent);
  outline: none;
}

.form-stack button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  margin-top: 0.5rem;
  padding: 0.8rem;
  width: 100%;
}

/* --- ADMIN --- */

.admin-grid {
  display: grid;
  gap: 1rem;
}

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}

.admin-card h3 {
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.admin-card .meta {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.admin-card code {
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.72rem;
  padding: 0.2rem 0.4rem;
}

.admin-card select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
}

.admin-card .btn {
  margin-left: 0.4rem;
}

.invite-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  padding: 1.2rem;
}

.invite-form h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.invite-form .form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.invite-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  flex: 1;
  font: inherit;
  font-size: 0.85rem;
  min-width: 140px;
  padding: 0.5rem 0.7rem;
}

.invite-form button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  white-space: nowrap;
}

/* --- NOTICE --- */

.notice {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 8px;
  color: var(--accent-hover);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  padding: 0.7rem 1rem;
}

/* --- BOTTOM NAV (mobile) --- */

.bottom-nav {
  background: var(--surface);
  border-top: 1px solid var(--border);
  bottom: 0;
  display: none;
  left: 0;
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom, 0px));
  position: fixed;
  right: 0;
  z-index: 200;
}

.bottom-nav nav {
  display: flex;
  justify-content: space-around;
}

.bottom-nav a {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  font-size: 0.68rem;
  gap: 0.2rem;
  padding: 0.3rem 0.6rem;
  text-decoration: none;
}

.bottom-nav a.active {
  color: var(--accent-hover);
}

.bottom-nav .tab-icon {
  font-size: 1.3rem;
}

/* --- RESPONSIVE --- */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .bottom-nav { display: block; }
  .content { padding-bottom: 5rem; }
}
