:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #232334;
  --border: #2a2a3d;
  --text: #e8e8f0;
  --text2: #8888a0;
  --accent: #4f7cff;
  --accent2: #3d63d4;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 12px;
}
[data-theme="light"] {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f8f9fa;
  --border: #e0e0e8;
  --text: #1a1a2e;
  --text2: #6b7280;
  --accent: #4f7cff;
  --accent2: #3d63d4;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
#app { height:100vh; overflow:hidden; display:flex; flex-direction:column; }

/* Login */
.login-page {
  display:flex; align-items:center; justify-content:center;
  min-height:100vh; padding:20px;
}
.login-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 40px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-box h1 { font-size:28px; margin-bottom:4px; }
.login-box .subtitle { color:var(--text2); margin-bottom:28px; font-size:14px; }
.login-box .logo { font-size:48px; margin-bottom:16px; display:block; }
.form-group { margin-bottom:16px; }
.form-group label { display:block; font-size:13px; color:var(--text2); margin-bottom:6px; }
.form-group input {
  width:100%; padding:12px 14px; border-radius:8px;
  border:1px solid var(--border); background:var(--surface2);
  color:var(--text); font-size:15px; outline:none;
}
.form-group input:focus { border-color:var(--accent); }
.btn {
  padding:12px 24px; border-radius:8px; border:none;
  background:var(--accent); color:#fff; font-size:15px;
  cursor:pointer; font-weight:600; transition:0.2s;
}
.btn:hover { background:var(--accent2); }
.btn:active { transform:scale(0.97); }
.btn-full { width:100%; }
.login-error { color:var(--red); font-size:13px; margin-top:8px; display:none; }

/* Nav */
.nav {
  display:flex; background:var(--surface); border-bottom:1px solid var(--border);
  padding:0 16px; overflow-x:auto; flex-shrink:0;
  -webkit-overflow-scrolling:touch;
}
.nav a {
  color:var(--text2); text-decoration:none; padding:14px 16px;
  font-size:13px; font-weight:600; white-space:nowrap;
  border-bottom:2px solid transparent; transition:0.2s;
}
.nav a.active { color:var(--accent); border-bottom-color:var(--accent); }
.nav a:hover { color:var(--text); }
.nav .spacer { flex:1; }
.nav .status-dot {
  width:8px; height:8px; border-radius:50%; margin:auto 8px auto 0;
  background:var(--green); flex-shrink:0;
}
.nav .status-dot.offline { background:var(--red); }

/* Pages */
.page { flex:1; padding:20px; display:none; overflow-y:auto; }
.page.active { display:flex; flex-direction:column; }

/* Dashboard cards */
.cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:16px; }
.card {
  background:var(--surface); border-radius:var(--radius);
  padding:20px; border:1px solid var(--border);
}
.card h3 { font-size:14px; color:var(--text2); margin-bottom:12px; text-transform:uppercase; letter-spacing:0.5px; }
.card .big-number { font-size:36px; font-weight:700; }
.card .green { color:var(--green); }

.item-list { list-style:none; }
.item-list li {
  padding:10px 0; border-bottom:1px solid var(--border);
  display:flex; justify-content:space-between; align-items:center;
  font-size:14px;
}
.item-list li:last-child { border-bottom:none; }
.badge {
  font-size:11px; padding:3px 8px; border-radius:20px; font-weight:600;
}
.badge.production { background:rgba(52,211,153,0.15); color:var(--green); }
.badge.submitted { background:rgba(79,124,255,0.15); color:var(--accent); }
.badge.ready { background:rgba(251,191,36,0.15); color:var(--yellow); }
.badge.fixes { background:rgba(251,191,36,0.15); color:var(--yellow); }
.badge.broken { background:rgba(248,113,113,0.15); color:var(--red); }

/* Chat */
.chat-page { padding:0!important; display:none; flex-direction:column; overflow:hidden; flex:1; min-height:0; }
.chat-page.active { display:flex; }
.chat-messages {
  flex:1; overflow-y:auto; padding:16px;
  display:flex; flex-direction:column-reverse; gap:8px;
}
.msg {
  max-width:80%; padding:10px 14px; border-radius:16px;
  font-size:14px; line-height:1.5; word-wrap:break-word;
  position:relative;
}
.msg .ts {
  font-size:10px; color:var(--text2); margin-top:4px; display:block;
}
.msg.user {
  align-self:flex-end; background:var(--accent); color:#fff;
  border-bottom-right-radius:4px;
}
.msg.user .ts { color:rgba(255,255,255,0.6); }
.msg.smitty {
  align-self:flex-start; background:var(--surface2);
  border-bottom-left-radius:4px;
}
.msg .label { font-size:11px; font-weight:600; margin-bottom:2px; display:block; }
.msg.smitty .label { color:var(--accent); }
.msg.user .label { color:rgba(255,255,255,0.8); }
.msg audio { display:block; margin-top:6px; width:100%; max-width:250px; height:36px; }
.typing {
  align-self:flex-start; padding:10px 14px; background:var(--surface2);
  border-radius:16px; font-size:13px; color:var(--text2);
  display:none;
}
.typing.show { display:block; }
.typing span { animation:pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:0.4} 50%{opacity:1} }

.chat-input-bar {
  display:flex; gap:8px; padding:12px 16px;
  background:var(--surface); border-top:1px solid var(--border);
  align-items:flex-end;
  flex-shrink:0;
}
.chat-input-bar textarea {
  flex:1; padding:10px 14px; border-radius:20px;
  border:1px solid var(--border); background:var(--surface2);
  color:var(--text); font-size:15px; font-family:inherit;
  resize:none; outline:none; max-height:120px; min-height:42px;
  line-height:1.4;
}
.chat-input-bar textarea:focus { border-color:var(--accent); }
.chat-btn {
  width:42px; height:42px; border-radius:50%;
  border:none; cursor:pointer; display:flex;
  align-items:center; justify-content:center;
  font-size:18px; flex-shrink:0; transition:0.2s;
}
.send-btn { background:var(--accent); color:#fff; }
.send-btn:hover { background:var(--accent2); }
.mic-btn { background:var(--surface2); color:var(--text); border:1px solid var(--border); }
.mic-btn.recording { background:var(--red); color:#fff; border-color:var(--red); animation:pulse 1s infinite; }

/* Extensions & Apps pages */
.list-page { max-width:700px; width:100%; margin:0 auto; }
.list-page h2 { margin-bottom:16px; font-size:20px; }
.list-card {
  background:var(--surface); border-radius:var(--radius);
  border:1px solid var(--border); overflow:hidden; margin-bottom:12px;
}
.list-card .lc-header {
  padding:16px; display:flex; justify-content:space-between; align-items:center;
}
.list-card .lc-header h3 { font-size:16px; }
.list-card .lc-body { padding:0 16px 16px; font-size:13px; color:var(--text2); }

/* Settings */
.settings-page { max-width:500px; width:100%; margin:0 auto; }
.settings-page h2 { margin-bottom:20px; }
.setting-row {
  display:flex; justify-content:space-between; align-items:center;
  padding:16px; background:var(--surface); border-radius:var(--radius);
  margin-bottom:12px; border:1px solid var(--border);
}
.toggle {
  width:48px; height:26px; border-radius:13px;
  background:var(--border); position:relative; cursor:pointer;
  transition:0.3s;
}
.toggle.on { background:var(--accent); }
.toggle::after {
  content:''; width:22px; height:22px; border-radius:50%;
  background:#fff; position:absolute; top:2px; left:2px;
  transition:0.3s;
}
.toggle.on::after { left:24px; }

@media(max-width:600px) {
  .cards { grid-template-columns:1fr; }
  .msg { max-width:88%; }
  .nav a { padding:12px; font-size:12px; }
}

/* Remember me checkbox */
.remember-row { display:flex; align-items:center; }
.checkbox-label { display:flex; align-items:center; gap:8px; font-size:14px; color:var(--text2); cursor:pointer; }
.checkbox-label input { width:18px; height:18px; accent-color:var(--accent); }

/* Login error */
.login-error { display:none; color:#ef4444; font-size:14px; text-align:center; margin-top:12px; padding:8px; background:rgba(239,68,68,0.1); border-radius:8px; }

/* Toast notification */
.toast { position:fixed; bottom:80px; left:50%; transform:translateX(-50%) translateY(20px); background:#1e293b; color:#f1f5f9; padding:12px 20px; border-radius:12px; font-size:14px; opacity:0; transition:all 0.3s ease; z-index:9999; white-space:nowrap; box-shadow:0 4px 12px rgba(0,0,0,0.3); }
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

/* Voice audio controls */
.audio-wrap { margin-top: 6px; }
.audio-wrap audio { width: 100%; max-width: 280px; height: 36px; }
.speed-btns { display: flex; gap: 4px; margin-top: 4px; }
.speed-btns button { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #aaa; border-radius: 4px; padding: 2px 6px; font-size: 11px; cursor: pointer; }
.speed-btns button.active { background: #6C63FF; color: #fff; border-color: #6C63FF; }
.speed-btns button:hover { background: rgba(108,99,255,0.3); }

/* Message delivery status */
.msg-status { font-size:11px; color:rgba(255,255,255,0.4); margin-left:4px; letter-spacing:-1px; }
.msg-status.delivered { color:rgba(100,200,255,0.8); }
