:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e0e4e9;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

header.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header.topbar .brand { font-weight: 700; font-size: 16px; }
header.topbar .who { font-size: 13px; color: var(--muted); }
header.topbar .who b { color: var(--text); }

nav.tabs {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 4px;
  padding: 0 16px;
  overflow-x: auto;
}

nav.tabs button {
  background: none;
  border: none;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

nav.tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.card h2 { margin: 0 0 14px; font-size: 16px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
label:first-child { margin-top: 0; }

input[type=text], input[type=url], input[type=password], input[type=number], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

textarea { min-height: 60px; resize: vertical; }

.checkbox-line { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; }
.checkbox-line label { margin: 0; color: var(--text); font-size: 13px; }
.checkbox-line input { width: auto; }

button.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
button.btn:hover { background: var(--primary-dark); }
button.btn:disabled { background: #9ca3af; cursor: not-allowed; }

button.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.btn.secondary:hover { background: #f3f4f6; }

button.btn.danger { background: var(--danger); }
button.btn.danger:hover { background: #b91c1c; }

button.btn.small { padding: 5px 10px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr.detail-row td { background: #fafbfc; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge.ok, .badge.posted, .badge.done, .badge.active { background: #dcfce7; color: #166534; }
.badge.pending, .badge.downloading, .badge.posting { background: #fef3c7; color: #92400e; }
.badge.failed, .badge.inactive { background: #fee2e2; color: #991b1b; }
.badge.downloaded { background: #dbeafe; color: #1e40af; }
.badge.oauth { background: #ede9fe; color: #5b21b6; }
.badge.manual { background: #f3f4f6; color: #374151; }

.muted { color: var(--muted); }
.error-box { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.success-box { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.info-box { background: #dbeafe; color: #1e40af; padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.channel-check-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.channel-check-list label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 13px; }
.channel-check-list input { width: auto; }

.link-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

.empty-state { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }

.hidden { display: none !important; }
