:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e2e6ee;
  --text: #1f2330;
  --muted: #6b7280;
  --primary: #06c755; /* LINE green */
  --primary-dark: #04a046;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #06c755 0%, #04a046 100%);
}
.login-card {
  background: white; padding: 32px; border-radius: 12px; min-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}
.login-card h1 { margin: 0 0 4px 0; color: var(--primary); }
.login-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card input { width: 100%; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.login-card button { width: 100%; padding: 11px; background: var(--primary); color: white; border: 0; border-radius: 6px; font-size: 15px; cursor: pointer; }
.login-card button:hover { background: var(--primary-dark); }
.login-card .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.login-card .ver { color: var(--muted); font-size: 12px; text-align: center; margin-top: 16px; }

/* Layout */
.topbar {
  background: white; border-bottom: 1px solid var(--border); padding: 10px 20px;
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 600; color: var(--primary); font-size: 16px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 6px 12px; border-radius: 6px; color: var(--text); }
.topbar nav a.active, .topbar nav a:hover { background: #eef9f1; color: var(--primary-dark); text-decoration: none; }
.topbar .right { color: var(--muted); font-size: 13px; display: flex; gap: 12px; align-items: center; }
.topbar .right button { background: transparent; border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; cursor: pointer; }

.container { padding: 20px; max-width: 1280px; margin: 0 auto; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px 0; font-size: 16px; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f8f9fb; font-weight: 600; font-size: 12px; color: var(--muted); }
tr:hover td { background: #fafbfd; }

.btn { padding: 6px 12px; border: 1px solid var(--border); background: white; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn:hover { background: #f5f6fa; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-small { padding: 4px 8px; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.in { background: #e3f2fd; color: #1565c0; }
.badge.out { background: #e8f5e9; color: #2e7d32; }
.badge.human { background: #fff3e0; color: #ef6c00; }
.badge.faq { background: #f3e5f5; color: #6a1b9a; }
.badge.ai { background: #e0f7fa; color: #00838f; }
.badge.echo { background: #f5f5f5; color: var(--muted); }
.badge.off { background: #ffebee; color: #c62828; }
.badge.on { background: #e8f5e9; color: #2e7d32; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-bg.show { display: flex; }
.modal { background: white; border-radius: 10px; padding: 20px; min-width: 480px; max-width: 720px; width: 92vw; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin: 0 0 14px 0; }
.modal .row { margin-bottom: 10px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.modal input[type=text], .modal input[type=password], .modal textarea, .modal select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit;
}
.modal textarea { min-height: 80px; resize: vertical; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal .err { color: var(--danger); font-size: 12px; min-height: 16px; }
.modal .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filter-row select, .filter-row input { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
tr.row-draft td { background: #fffaf0; }
tr.row-draft:hover td { background: #fff5e0; }
