:root {
  --blue: #1da1f2;
  --blue-dark: #1a91da;
  --ink: #14171a;
  --muted: #657786;
  --border: #e1e8ed;
  --bg: #f5f8fa;
  --danger: #e0245e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--blue);
  color: #fff;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.brand { color: #fff; font-weight: 700; font-size: 18px; }
.brand:hover { text-decoration: none; }
.brand-bird { font-size: 20px; }
.topnav { display: flex; align-items: center; gap: 12px; }
.who { color: #fff; opacity: .9; font-size: 14px; }

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

/* Buttons */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-block { display: block; width: 100%; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: rgba(224,36,94,.08); }

.inline { display: inline; margin: 0; }

/* Centered auth/connect cards */
body.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.auth-card h1 { margin: 8px 0 4px; font-size: 22px; }
.auth-logo { font-size: 40px; }
.auth-logo.success { color: #17bf63; font-weight: 700; }
.auth-logo.error { color: var(--danger); font-weight: 700; }

.stack { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-top: 16px; }
.stack label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
input, textarea, select {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); }

.stack .checkbox { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.stack .checkbox input { width: auto; }

.topnav .navlink { color: #fff; opacity: .9; font-weight: 700; font-size: 14px; }
.topnav .navlink:hover { opacity: 1; text-decoration: none; }

/* Admin import results */
.import-result { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; background: var(--bg); }
.import-result p { margin: 0; }
.import-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 5px; }
.import-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.import-list .tag { font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; flex: 0 0 auto; }
.import-list li.ok .tag { background: #cdeccd; color: #0a7a28; }
.import-list li.skip .tag { background: #fde0e6; color: #b00638; }
.import-list .who { font-weight: 700; }
.import-list .msg { font-size: 13px; }
.small code { background: #eef3f6; padding: 0 4px; border-radius: 4px; font-size: 12px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.alert {
  background: #fde0e6; color: #b00638; border: 1px solid #f5c2cf;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 8px;
}

/* Dashboard */
.dash { display: flex; flex-direction: column; gap: 20px; }
.card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px;
}
.card-head h2 { margin: 0 0 4px; font-size: 18px; }
.card-head .muted { margin: 0 0 16px; font-size: 14px; }

.link-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.link-form input { flex: 1 1 200px; }
.link-form select { flex: 0 1 180px; }
.link-form .btn { flex: 0 0 auto; }

.link-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.link-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.link-meta { flex: 1; min-width: 0; }
.link-label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.link-oauth { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.link-url { font-size: 13px; color: var(--muted); background: var(--bg); border: none; }
.link-actions { display: flex; align-items: center; gap: 6px; }

.oauth-app-form { display: grid; grid-template-columns: 1fr 0.7fr 1fr 1fr auto; gap: 8px; margin-bottom: 16px; }
.oauth-app-callback-input { grid-column: 1 / -1; }
.oauth-app-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.oauth-app-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.oauth-app-label { display: block; font-weight: 700; font-size: 14px; }
.oauth-app-key, .oauth-app-callback { display: block; color: var(--muted); font-size: 12px; }
.oauth-app-callback { margin-top: 3px; overflow-wrap: anywhere; }
.oauth-app-tag {
  border: 1px solid var(--border); border-radius: 100px; color: var(--muted);
  font-size: 11px; font-weight: 700; padding: 3px 8px; text-transform: uppercase;
}

.account-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
}
.account-card {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
}
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--bg); object-fit: cover; }
.account-id { flex: 1; min-width: 0; }
.account-id .name { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-id .handle { color: var(--muted); font-size: 13px; }
.account-actions { display: flex; flex-direction: column; gap: 6px; }
.account-actions .btn { padding: 6px 12px; font-size: 13px; text-align: center; }

.empty { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* API usage card */
.usage-head { display: flex; align-items: baseline; justify-content: space-between; }
.usage-head h2 { margin: 0; font-size: 18px; }
.usage-count { font-weight: 800; font-size: 18px; color: var(--blue); }
.usage-count.full { color: var(--danger); }
.usage-bar { height: 8px; background: var(--bg); border-radius: 100px; overflow: hidden; margin: 12px 0 10px; }
.usage-fill { height: 100%; background: var(--blue); border-radius: 100px; transition: width .3s ease; }
.usage-fill.full { background: var(--danger); }
.usage-note { margin: 0; }

/* Admin activity log */
.activity-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.activity-list li {
  display: flex; align-items: baseline; gap: 8px; padding: 7px 0;
  border-bottom: 1px solid var(--border); font-size: 13px; flex-wrap: wrap;
}
.activity-list li:last-child { border-bottom: none; }
.act-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
.act-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  border-radius: 4px; padding: 1px 6px; color: #fff; background: var(--muted); white-space: nowrap;
}
.act-connect { background: #17bf63; }
.act-tweet { background: var(--blue); }
.act-reply { background: #794bc4; }
.act-retweet { background: #17bf63; }
.act-delete, .act-undo_retweet { background: var(--danger); }
.act-bio { background: #e0a800; }
.act-follow { background: #1a91da; }
.act-unfollow { background: #657786; }
.act-user { font-weight: 700; }
.act-acct { color: var(--muted); }
.act-detail { color: var(--ink); opacity: .85; word-break: break-word; flex: 1 1 200px; }

.pager { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.pager a { font-weight: 700; }

@media (max-width: 760px) {
  .oauth-app-form { grid-template-columns: 1fr; }
  .oauth-app-callback-input { grid-column: auto; }
  .oauth-app-row { align-items: flex-start; flex-wrap: wrap; }
}
