/* ===== Variables ===== */
:root {
  --bg-primary: #f5f5f5;
  --bg-white: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #1e293b;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;
  --accent: #1976d2;
  --accent-light: #e3f2fd;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --sidebar-width: 260px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg-primary); color: var(--text-primary); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); }
code { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.85em; background: #f0f0f0; padding: 2px 6px; border-radius: 3px; }
table { border-collapse: collapse; width: 100%; }
h1,h2,h3,h4 { font-weight: 600; color: var(--text-primary); }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.main-content { flex: 1; margin-left: var(--sidebar-width); padding: 24px 32px; max-width: calc(100vw - var(--sidebar-width)); overflow-x: hidden; }

/* ===== Sidebar ===== */
.sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh; background: var(--bg-sidebar); color: var(--text-sidebar); display: flex; flex-direction: column; z-index: 100; overflow-y: auto; }
.sidebar-header { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 1.15rem; font-weight: 700; margin-bottom: 12px; }
.sidebar-logo svg { color: var(--accent); }
.sidebar-status { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--error); }
.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: var(--text-sidebar); font-size: 0.9rem; font-weight: 500; transition: all 0.15s; border-left: 3px solid transparent; text-decoration: none; }
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); border-left-color: var(--accent); }
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

/* ===== Page Header ===== */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; margin-bottom: 4px; }
.page-header p { color: var(--text-secondary); font-size: 0.9rem; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stats-grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat-card { background: var(--bg-white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 16px; }
.stat-card-icon { width: 48px; height: 48px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-card-title { color: var(--text-secondary); font-size: 0.8rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card-subtitle { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }

/* ===== Panels ===== */
.panels-row { display: flex; gap: 24px; margin-bottom: 24px; }
.panel { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-large { flex: 2; }
.panel-small { flex: 1; }
.panel-half { flex: 1; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-light); }
.panel-header h3 { font-size: 0.95rem; }
.panel-body { padding: 16px 20px; max-height: 500px; overflow-y: auto; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-white); color: var(--text-primary); font-size: 0.85rem; font-weight: 500; transition: all 0.15s; }
.btn:hover { background: #f8f8f8; text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-ghost { border: none; background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-light); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #1565c0; }

/* ===== Badge ===== */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.badge-blue { background: #e3f2fd; color: #1565c0; }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-orange { background: #fff3e0; color: #e65100; }
.badge-red { background: #ffebee; color: #c62828; }
.badge-purple { background: #f3e5f5; color: #6a1b9a; }
.badge-teal { background: #e0f2f1; color: #00695c; }
.badge-gray { background: #f5f5f5; color: #616161; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; }
thead th { padding: 10px 12px; text-align: left; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); background: #fafafa; white-space: nowrap; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); font-size: 0.85rem; }
tbody tr:hover { background: #f8f9fa; }
tbody tr:nth-child(even) { background: #fafafa; }
tbody tr:nth-child(even):hover { background: #f0f2f5; }
.clickable-row { cursor: pointer; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; gap: 12px; }
.pagination-info { color: var(--text-muted); font-size: 0.8rem; }
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.pagination-page { color: var(--text-secondary); font-size: 0.85rem; }

/* ===== Search & Filters ===== */
.filters-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; font-family: var(--font); outline: none; transition: border 0.15s; }
.search-input:focus { border-color: var(--accent); }
.select-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; font-family: var(--font); outline: none; background: var(--bg-white); min-width: 160px; }
.select-input:focus { border-color: var(--accent); }

/* ===== Events Feed ===== */
.events-feed { display: flex; flex-direction: column; }
.event-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-light); cursor: pointer; transition: background 0.1s; }
.event-item:hover { background: #f8f9fa; margin: 0 -20px; padding: 10px 20px; }
.event-item:last-child { border-bottom: none; }
.event-item-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.event-summary { color: var(--text-primary); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-time { color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; margin-left: 12px; }
.event-new { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ===== PIX Items ===== */
.pix-item { padding: 12px 0; border-bottom: 1px solid var(--border-light); cursor: pointer; }
.pix-item:hover { background: #f8f9fa; margin: 0 -20px; padding: 12px 20px; }
.pix-item:last-child { border-bottom: none; }
.pix-item-top { display: flex; justify-content: space-between; align-items: center; }
.pix-value { font-weight: 600; font-size: 1rem; }
.pix-item-detail { color: var(--text-secondary); font-size: 0.85rem; margin-top: 4px; }
.pix-item-time { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }

/* ===== Conversations ===== */
.conversations-layout { display: flex; gap: 0; background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); height: calc(100vh - 140px); overflow: hidden; }
.conv-sidebar { width: 340px; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.conv-sidebar-header { padding: 12px; border-bottom: 1px solid var(--border-light); }
.conv-list { flex: 1; overflow-y: auto; }
.conv-item { padding: 12px 16px; border-bottom: 1px solid var(--border-light); cursor: pointer; transition: background 0.1s; }
.conv-item:hover { background: #f8f9fa; }
.conv-item.active { background: var(--accent-light); border-left: 3px solid var(--accent); }
.conv-item-header { display: flex; justify-content: space-between; align-items: center; }
.conv-name { font-weight: 600; font-size: 0.9rem; }
.conv-time { color: var(--text-muted); font-size: 0.75rem; }
.conv-preview { color: var(--text-secondary); font-size: 0.8rem; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-you { color: var(--accent); font-weight: 500; }
.conv-meta { display: flex; gap: 12px; color: var(--text-muted); font-size: 0.72rem; margin-top: 4px; }
.conv-main { flex: 1; display: flex; flex-direction: column; }
.conv-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.conv-header h3 { font-size: 1rem; }

/* ===== Chat Bubbles ===== */
.chat-messages { flex: 1; padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chat-bubble { max-width: 70%; padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.5; word-wrap: break-word; }
.chat-bubble.incoming { align-self: flex-start; background: #f0f0f0; border-bottom-left-radius: 4px; }
.chat-bubble.outgoing { align-self: flex-end; background: var(--accent-light); border-bottom-right-radius: 4px; }
.chat-text { white-space: pre-wrap; }
.chat-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; text-align: right; }
.chat-type { margin-bottom: 4px; display: block; }

/* ===== Detail Views ===== */
.detail-card { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.detail-grid { display: flex; flex-direction: column; gap: 8px; }
.detail-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.detail-row { display: flex; gap: 8px; font-size: 0.85rem; padding: 4px 0; }
.detail-row strong { min-width: 120px; color: var(--text-secondary); font-weight: 500; flex-shrink: 0; }
.detail-section { margin-top: 20px; }
.detail-section h4 { font-size: 0.9rem; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
.comprovante-img { max-width: 400px; border: 1px solid var(--border); border-radius: var(--radius); }

/* ===== Timeline ===== */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot { position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-white); }
.timeline-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.timeline-time { color: var(--text-muted); font-size: 0.78rem; }
.timeline-body { color: var(--text-secondary); font-size: 0.85rem; }

/* ===== JSON Viewer ===== */
.json-viewer { margin-top: 8px; }
.json-content { background: #1e293b; color: #e2e8f0; padding: 16px; border-radius: var(--radius-sm); font-size: 0.8rem; line-height: 1.6; overflow-x: auto; max-height: 400px; transition: max-height 0.3s; }
.json-content.collapsed { max-height: 0; padding: 0 16px; overflow: hidden; }

/* ===== Charts ===== */
.bar-chart { display: flex; align-items: flex-end; gap: 2px; padding-bottom: 20px; position: relative; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar { background: var(--accent); border-radius: 2px 2px 0 0; width: 100%; min-width: 4px; transition: height 0.3s; }
.bar-col:hover .bar { background: #1565c0; }
.bar-label { font-size: 0.6rem; color: var(--text-muted); margin-top: 4px; }
.hbar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.hbar-label { width: 160px; font-size: 0.8rem; color: var(--text-secondary); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; }
.hbar-track { flex: 1; height: 20px; background: #f0f0f0; border-radius: 3px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.hbar-value { width: 40px; font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }

/* ===== System Grid ===== */
.system-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.system-card { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.system-card h3 { font-size: 0.95rem; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; box-shadow: var(--shadow-md); animation: slideIn 0.3s ease; }
.toast-info { background: var(--accent); color: white; }
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--error); color: white; }
.toast-warning { background: var(--warning); color: white; }
.toast.fade-out { opacity: 0; transform: translateX(20px); transition: all 0.3s; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow-md); width: 90%; max-width: 750px; max-height: 85vh; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-light); }
.modal-title { font-size: 1.05rem; }
.modal-close { width: 32px; height: 32px; border: none; background: transparent; font-size: 1.4rem; color: var(--text-muted); border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: #f0f0f0; color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ===== Utilities ===== */
.loading-page { display: flex; align-items: center; justify-content: center; min-height: 200px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state p { margin-top: 8px; }
.error-state { text-align: center; padding: 40px 20px; color: var(--error); }
.text-muted { color: var(--text-muted); }
.text-error { color: var(--error); }

/* ===== Agent Selector ===== */
.agent-selector { padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.agent-selector-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-sidebar); margin-bottom: 6px; }
.agent-selector-select { width: 100%; padding: 6px 10px; border: 1px solid rgba(255,255,255,0.15); border-radius: var(--radius-sm); background: var(--bg-sidebar-hover); color: #fff; font-size: 0.82rem; font-family: var(--font); outline: none; cursor: pointer; }
.agent-selector-select:focus { border-color: var(--accent); }
.agent-selector-select option { background: var(--bg-sidebar); color: #fff; }

/* ===== Agent Form ===== */
.agent-form { display: flex; flex-direction: column; gap: 20px; }
.form-section { }
.form-section-title { font-size: 0.85rem; font-weight: 600; color: var(--accent); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border-light); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); }
.form-input { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; font-family: var(--font); outline: none; transition: border 0.15s; }
.form-input:focus { border-color: var(--accent); }
.form-textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.82rem; font-family: 'JetBrains Mono', 'Fira Code', monospace; outline: none; resize: vertical; line-height: 1.5; }
.form-textarea:focus { border-color: var(--accent); }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; padding-top: 12px; border-top: 1px solid var(--border-light); }

/* ===== Agent Cards ===== */
.agent-card { background: var(--bg-white); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; overflow: hidden; }
.agent-card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-light); }
.agent-card-title h3 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.agent-card-actions { display: flex; align-items: center; gap: 8px; }
.agent-card-info { padding: 16px 20px; }
.agent-info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.agent-info-item { display: flex; flex-direction: column; gap: 2px; }
.agent-info-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); }
.agent-info-value { font-size: 0.85rem; color: var(--text-primary); }
.agent-info-value code { font-size: 0.8rem; background: var(--bg-primary); padding: 1px 6px; border-radius: 3px; }

/* Session Panel */
.agent-session-panel { border-top: 1px solid var(--border-light); background: var(--bg-primary); padding: 16px 20px; }
.session-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.session-panel-header h4 { margin: 0; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.session-panel-body { margin-bottom: 12px; }
.session-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.session-info-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; margin-bottom: 4px; }
.session-info-label { font-weight: 500; color: var(--text-secondary); min-width: 70px; }

/* QR Code */
.qr-code-wrapper { text-align: center; padding: 12px 0; }
.qr-code-img { max-width: 260px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ===== Agent Form Page ===== */
.agent-form-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.agent-form-header-left { display: flex; align-items: center; gap: 16px; }
.agent-form-back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 0.85rem; font-weight: 500; padding: 6px 12px; border-radius: var(--radius-sm); transition: all 0.15s; text-decoration: none; }
.agent-form-back:hover { background: var(--bg-white); color: var(--text-primary); text-decoration: none; }
.agent-form-back svg { flex-shrink: 0; }
.agent-form-title { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }

.agent-form-layout { display: flex; gap: 0; background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-height: 520px; }

.agent-form-tabs { width: 220px; border-right: 1px solid var(--border-light); padding: 8px 0; flex-shrink: 0; background: #fafbfc; }
.agent-form-tab { display: flex; align-items: center; gap: 10px; padding: 12px 20px; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: all 0.15s; border-left: 3px solid transparent; }
.agent-form-tab:hover { background: var(--bg-white); color: var(--text-primary); }
.agent-form-tab.active { background: var(--bg-white); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.agent-form-tab svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.6; }
.agent-form-tab.active svg { opacity: 1; }

.agent-form-content { flex: 1; padding: 28px 32px; overflow-y: auto; max-height: calc(100vh - 200px); }
.agent-form-section { display: none; }
.agent-form-section.active { display: block; }
.agent-form-section-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.agent-form-section-desc { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 24px; }

.form-card { background: var(--bg-white); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.form-card-title { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 16px; }

.form-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }

.form-input-secret { position: relative; display: flex; }
.form-input-secret input { flex: 1; padding-right: 40px; }
.form-input-secret .btn-toggle-secret { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 36px; border: none; background: transparent; color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.form-input-secret .btn-toggle-secret:hover { color: var(--text-primary); background: #f0f0f0; }

.form-toggle-wrap { display: flex; align-items: center; gap: 10px; }
.form-toggle { position: relative; width: 44px; height: 24px; cursor: pointer; }
.form-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.form-toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 12px; transition: all 0.2s; }
.form-toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.form-toggle input:checked + .form-toggle-slider { background: var(--accent); }
.form-toggle input:checked + .form-toggle-slider::before { transform: translateX(20px); }
.form-toggle-label { font-size: 0.85rem; color: var(--text-secondary); }

.form-prompt-wrapper { position: relative; }
.form-prompt-wrapper textarea { min-height: 350px; font-size: 0.82rem; line-height: 1.7; }
.form-prompt-counter { position: absolute; bottom: 8px; right: 12px; font-size: 0.7rem; color: var(--text-muted); pointer-events: none; }

.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== Login Page ===== */
.login-body { background: var(--bg-primary); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { display: flex; align-items: center; justify-content: center; width: 100%; padding: 20px; }
.login-card { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 48px 40px; text-align: center; width: 100%; max-width: 400px; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.login-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 32px; }
.login-error { background: #ffebee; color: #c62828; padding: 10px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 16px; }
.login-loading { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; color: var(--text-secondary); font-size: 0.85rem; }
.login-card .g_id_signin { display: flex; justify-content: center; }

/* ===== Sidebar User ===== */
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08); margin-top: auto; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; color: #fff; font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { display: block; color: var(--text-sidebar); font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { background: none; border: none; color: var(--text-sidebar); padding: 6px; border-radius: var(--radius-sm); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.btn-logout:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ===== Calendar ===== */
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-nav .btn { display: flex; align-items: center; gap: 4px; }
.calendar-month-label { font-size: 1.2rem; font-weight: 600; color: var(--text-primary); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.calendar-header-cell { padding: 10px 8px; text-align: center; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); background: var(--bg-primary); border-bottom: 1px solid var(--border); }
.calendar-day { min-height: 100px; padding: 6px 8px; border-bottom: 1px solid var(--border-light); border-right: 1px solid var(--border-light); cursor: pointer; transition: background 0.15s; position: relative; }
.calendar-day:hover { background: var(--accent-light); }
.calendar-day.other-month { background: #fafafa; }
.calendar-day.other-month .day-number { color: var(--text-muted); }
.calendar-day.today { background: #e3f2fd; }
.calendar-day.today .day-number { background: var(--accent); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.calendar-day.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.calendar-day:nth-child(7n) { border-right: none; }
.day-number { font-size: 0.82rem; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.day-events { display: flex; flex-direction: column; gap: 2px; }
.day-event-bar { height: 4px; border-radius: 2px; width: 100%; }
.day-event-more { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }

/* Day Events Panel */
.day-events-panel { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 20px; box-shadow: var(--shadow); }
.day-events-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.day-events-header h3 { font-size: 1rem; font-weight: 600; }
.day-event-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s; border: 1px solid var(--border-light); margin-bottom: 8px; }
.day-event-item:hover { background: var(--bg-primary); }
.day-event-color { width: 4px; min-height: 36px; border-radius: 2px; flex-shrink: 0; margin-top: 2px; }
.day-event-info { flex: 1; min-width: 0; }
.day-event-title { font-weight: 500; font-size: 0.9rem; color: var(--text-primary); }
.day-event-meta { display: flex; gap: 12px; font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; flex-wrap: wrap; }
.day-event-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-event-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Calendar Form */
.form-row { display: flex; gap: 12px; align-items: flex-start; }
.form-checkbox { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; margin-bottom: 4px; }
.form-checkbox input { cursor: pointer; }
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-option { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: border-color 0.15s, transform 0.15s; }
.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--bg-white), 0 0 0 4px var(--text-muted); }
.btn-danger { background: var(--error); color: #fff; border: none; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost.btn-danger { background: none; color: var(--error); }
.btn-ghost.btn-danger:hover { background: #fef2f2; }

/* ===== Scheduler ===== */
.prompt-cell { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; }
.detail-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.detail-row { display: flex; align-items: center; gap: 12px; }
.detail-label { font-weight: 500; color: var(--text-secondary); min-width: 120px; font-size: 0.82rem; }
.detail-section { margin-top: 16px; }
.detail-section h4 { font-size: 0.85rem; margin-bottom: 8px; color: var(--text-secondary); }
.detail-box { background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 12px; font-size: 0.85rem; white-space: pre-wrap; word-break: break-word; }
.detail-box-success { border-left: 3px solid var(--success); }
.detail-box-error { border-left: 3px solid var(--error); background: #fef2f2; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .panels-row { flex-direction: column; }
  .detail-grid-2col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .nav-item span, .sidebar-logo span, .sidebar-status, .agent-selector, .user-info { display: none; }
  .sidebar-header { padding: 16px 10px; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .main-content { margin-left: 60px; padding: 16px; }
  .conversations-layout { flex-direction: column; height: auto; }
  .conv-sidebar { width: 100%; max-height: 300px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .calendar-day { min-height: 60px; padding: 4px; }
  .calendar-toolbar { flex-direction: column; align-items: stretch; }
  .calendar-toolbar .calendar-nav { justify-content: center; }
  .calendar-toolbar .calendar-month-label { text-align: center; }
  .day-event-bar { height: 3px; }
}
