* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px; color: #1f2937; background: #f3f4f6; line-height: 1.5;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-family: "SF Mono", Menlo, Consolas, monospace; }
.small { font-size: 11px; }
.muted { color: #6b7280; font-size: 13px; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: #111827; color: #e5e7eb;
    display: flex; flex-direction: column; padding: 20px 0;
    position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 18px; font-weight: 700; padding: 0 20px 20px; border-bottom: 1px solid #1f2937; }
.sidebar nav { padding: 20px 0; flex: 1; }
.sidebar nav a { display: block; padding: 10px 20px; color: #d1d5db; border-left: 3px solid transparent; transition: all 0.15s; }
.sidebar nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #1f2937; color: #fff; border-left-color: #25d366; }
.sidebar-footer { padding: 20px; border-top: 1px solid #1f2937; }
.user-info { font-size: 13px; margin-bottom: 8px; color: #9ca3af; }
.logout { color: #f87171; font-size: 13px; }
.content { flex: 1; padding: 30px 40px; max-width: 1400px; }

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #25d366 0%, #128c7e 100%); }
.auth-card { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.15); width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 22px; margin-bottom: 5px; }
.auth-subtitle { color: #6b7280; margin-bottom: 25px; }
.auth-hint { font-size: 11px; color: #9ca3af; margin-top: 18px; text-align: center; }

h1 { font-size: 24px; font-weight: 600; margin-bottom: 20px; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 16px; }

.card { background: #fff; border-radius: 10px; padding: 24px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid #e5e7eb; }
.card.highlight { border-left: 4px solid #2563eb; background: #eff6ff20; }
.card.highlight-success { border-left: 4px solid #25d366; background: #f0fdf440; }
.card-header { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #f3f4f6; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; padding: 20px; border-radius: 10px; border: 1px solid #e5e7eb; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.stat-card.success { border-left: 4px solid #25d366; }
.stat-num { font-size: 32px; font-weight: 700; color: #111827; }
.stat-label { color: #6b7280; font-size: 13px; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 12px; background: #f9fafb; border-bottom: 1px solid #e5e7eb; font-weight: 600; font-size: 13px; color: #374151; }
.table td { padding: 12px; border-bottom: 1px solid #f3f4f6; }
.table tr:last-child td { border-bottom: none; }
.table .empty { text-align: center; color: #9ca3af; padding: 30px; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; color: #374151; }
.field small { display: block; color: #6b7280; font-size: 12px; margin-top: 4px; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=url], .field input[type=number],
.field textarea, .field select {
    width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; font-family: inherit; background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.checkbox-field label { font-weight: 400; cursor: pointer; }
.checkbox-field input { margin-right: 8px; }

.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; border: 1px solid #d1d5db; background: #fff; color: #374151; cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit; transition: all 0.15s; text-decoration: none; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: #25d366; border-color: #25d366; color: #fff; }
.btn-primary:hover { background: #1fbf5b; border-color: #1fbf5b; }
.btn-danger { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 10px; margin-top: 20px; }

.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; }
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; background: #e5e7eb; color: #374151; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-info { background: #dbeafe; color: #1e40af; }

.info-box { background: #eff6ff; border: 1px solid #bfdbfe; padding: 14px; border-radius: 8px; margin-bottom: 18px; font-size: 13px; }
.info-box code { background: #fff; }

.docs-list { margin-top: 16px; }
.doc-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #f9fafb; border-radius: 6px; margin-bottom: 6px; font-size: 13px; }

.inline-form select { padding: 8px 12px; border-radius: 6px; border: 1px solid #d1d5db; }

.chat-container { background: #fff; border-radius: 10px; border: 1px solid #e5e7eb; display: flex; flex-direction: column; height: calc(100vh - 200px); }
.chat-messages { flex: 1; padding: 20px; overflow-y: auto; background: #efeae2; display: flex; flex-direction: column; }
.msg { max-width: 70%; margin-bottom: 12px; padding: 10px 14px; border-radius: 10px; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,0.05); }
.msg-meta { font-size: 10px; opacity: 0.7; margin-bottom: 4px; }
.msg-body { font-size: 14px; }
.msg-in { background: #fff; align-self: flex-start; margin-right: auto; }
.msg-ai { background: #dcf8c6; margin-left: auto; }
.msg-op { background: #d1e7ff; margin-left: auto; }
.msg-sys { background: #fff3cd; margin: 12px auto; max-width: 90%; font-style: italic; }
.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid #e5e7eb; background: #fff; }
.chat-input textarea { flex: 1; padding: 10px; border: 1px solid #d1d5db; border-radius: 6px; resize: none; font-family: inherit; }

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .sidebar nav { display: flex; overflow-x: auto; padding: 10px; }
    .sidebar nav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
    .sidebar nav a.active { border-left: none; border-bottom-color: #25d366; }
    .content { padding: 20px; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
