* { box-sizing: border-box; }
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .16);
}
html { font-size: 15px; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar { width: 220px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 20; }
.sidebar .brand { padding: 20px 20px 14px; font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .01em; }
.sidebar .brand .sub { display: block; font-weight: 400; font-size: 11px; color: #64748b; margin-top: 2px; }
.sidebar nav { flex: 1; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #94a3b8; font-size: 14px; font-weight: 500; }
.sidebar nav a svg { width: 17px; height: 17px; flex: 0 0 17px; }
.sidebar nav a:hover { background: #1e293b; color: #e2e8f0; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .logout { margin: 10px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #64748b; font-size: 14px; }
.sidebar .logout:hover { background: #1e293b; color: #e2e8f0; text-decoration: none; }
.sidebar .logout svg { width: 17px; height: 17px; }

.content { flex: 1; margin-left: 220px; padding: 28px 32px 60px; max-width: 1280px; }
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: static; width: 100%; flex-direction: row; align-items: center; }
  .sidebar .brand { padding: 14px 16px; }
  .sidebar .brand .sub { display: none; }
  .sidebar nav { flex-direction: row; padding: 8px; overflow-x: auto; }
  .sidebar .logout { margin: 8px; }
  .content { margin-left: 0; padding: 20px 16px 60px; }
}

.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 6px; font-size: 16px; font-weight: 650; }
.card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover td { background: #f8fafc; }

input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 9px; font-size: 14px; background: #fff; width: 100%; color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
input::placeholder { color: #94a3b8; }

button, .btn { background: var(--primary); color: #fff; border: 0; border-radius: 9px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
button svg, .btn svg { width: 15px; height: 15px; }
button:hover, .btn:hover { background: var(--primary-hover); text-decoration: none; }
button.secondary { background: #fff; color: var(--text); border: 1px solid #cbd5e1; }
button.secondary:hover { background: #f8fafc; }
button.danger { background: var(--red); }
button.danger:hover { background: #b91c1c; }
button:disabled { opacity: .45; cursor: not-allowed; }

.flash { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.flash.success { background: var(--green-soft); color: #065f46; border-color: #a7f3d0; }
.flash.error { background: var(--red-soft); color: #991b1b; border-color: #fecaca; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 5px; }

.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 650; }
.badge.green { background: var(--green-soft); color: #065f46; }
.badge.gray { background: #f1f5f9; color: var(--muted); }
.badge.red { background: var(--red-soft); color: #991b1b; }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.indigo { background: var(--primary-soft); color: var(--primary); }

.favicon { width: 22px; height: 22px; border-radius: 5px; vertical-align: middle; background: #f1f5f9; object-fit: contain; flex: 0 0 22px; }
.letter { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 700; vertical-align: middle; flex: 0 0 22px; }
.site-name { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; }

.board-tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.board-tabs .tab { padding: 8px 15px; border-radius: 999px; background: #fff; border: 1px solid var(--border); font-size: 13.5px; font-weight: 600; color: #475569; display: inline-flex; gap: 7px; align-items: center; }
.board-tabs .tab svg { width: 13px; height: 13px; }
.board-tabs .tab.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.board-tabs .tab:hover { text-decoration: none; border-color: #94a3b8; }
.newboard-wrap { display: none; align-items: center; gap: 6px; }
.newboard-wrap.open { display: inline-flex; }
.newboard-wrap input { width: 140px; padding: 7px 11px; font-size: 13px; }

.statusbar { border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1px solid transparent; }
.statusbar.auto { background: var(--green-soft); border-color: #a7f3d0; }
.statusbar.manual { background: var(--amber-soft); border-color: #fde68a; }
.statusbar .status-label { display: flex; align-items: center; gap: 12px; }
.statusbar .dot { width: 11px; height: 11px; border-radius: 999px; flex: 0 0 11px; }
.statusbar.auto .dot { background: var(--green); animation: pulse 2s infinite; }
.statusbar.manual .dot { background: #f59e0b; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(5,150,105,.35); } 50% { box-shadow: 0 0 0 6px rgba(5,150,105,0); } }
.statusbar .status-text strong { font-size: 15px; }
.statusbar .status-text .desc { color: #475569; font-size: 13.5px; margin-top: 2px; }
.statusbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.kanban { display: grid; grid-template-columns: 1fr 1.15fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .kanban { grid-template-columns: 1fr; } }
.kanban-col { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.kanban-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; padding: 2px 4px 0; }
.kanban-head strong { font-size: 14.5px; }
.kanban-head .hint { color: var(--muted); font-size: 12.5px; }
.site-list { max-height: 600px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 2px; }

.site-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.site-row .meta { flex: 1; min-width: 0; }
.site-row .meta .line2 { color: var(--muted); font-size: 12px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-row .vis { color: #475569; font-size: 12.5px; text-align: right; white-space: nowrap; }
.site-row .vis b { font-size: 13.5px; }
.add-btn { flex: 0 0 auto; background: var(--green-soft); color: #065f46; border: 1px solid #a7f3d0; width: auto; padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.add-btn:hover { background: #d1fae5; }

.pool-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px; cursor: grab; border-left: 4px solid var(--primary); }
.pool-item:first-child { border-left-color: #f59e0b; background: #fffdf5; }
.pool-item:active { cursor: grabbing; }
.pool-item.dragging { opacity: .45; border-style: dashed; }
.pool-item .rank { width: 30px; height: 30px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 30px; }
.pool-item:first-child .rank { background: #fef3c7; color: #b45309; }
.pool-item .meta { flex: 1; min-width: 0; }
.pool-item .meta .line2 { color: var(--muted); font-size: 12px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pool-item .vis { color: #475569; font-size: 12.5px; text-align: right; white-space: nowrap; }
.pool-item .vis b { font-size: 13.5px; }
.pool-item .drag-grip { color: #cbd5e1; display: inline-flex; }
.pool-item .drag-grip svg { width: 14px; height: 14px; }
.del-btn { flex: 0 0 auto; background: #fff; color: #94a3b8; border: 1px solid var(--border); width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 8px; }
.del-btn:hover { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.del-btn svg { width: 13px; height: 13px; }
.empty-note { color: var(--muted); font-size: 13.5px; padding: 14px 6px; line-height: 1.5; }

.savebar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(140%); background: #0f172a; color: #fff; border-radius: 14px; padding: 13px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-lg); z-index: 50; transition: transform .25s ease; max-width: min(92vw, 640px); }
.savebar.show { transform: translateX(-50%) translateY(0); }
.savebar .msg { font-size: 13.5px; }
.savebar .msg .warn { color: #fbbf24; display: block; font-size: 12.5px; margin-top: 2px; }
.savebar button { background: #22c55e; }
.savebar button:hover { background: #16a34a; }
.savebar button.ghost { background: transparent; border: 1px solid #475569; }

details.advanced { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
details.advanced summary { cursor: pointer; color: var(--muted); font-size: 13.5px; font-weight: 600; user-select: none; }
details.advanced[open] summary { margin-bottom: 12px; }

.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 170px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: #475569; margin-bottom: 5px; }
.login-box { max-width: 400px; margin: 90px auto; }

.top3-row td { background: #fffbeb; }
