:root {
  --green: #128c7e;
  --green-d: #075e54;
  --green-l: #dcf8c6;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #1f2328;
  --muted: #667085;
  --line: #e4e7ec;
  --red: #d92d20;
  --amber: #b54708;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 10px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.logo { color: #25d366; font-size: 22px; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--green-d), var(--green)); }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 16px; padding: 24px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.tabs-inline { display: flex; gap: 6px; margin: 16px 0; background: var(--bg); padding: 4px; border-radius: 10px; }
.tabs-inline button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs-inline button.active { background: #fff; color: var(--green-d); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* Form */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; color: #344054; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #25d36655; border-color: var(--green); }
input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
input[type=color] { padding: 2px; height: 38px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; font-weight: 500; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }

.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; color: var(--text); }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); border-color: #fecdca; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.full { width: 100%; padding: 11px; }
.btn:disabled { opacity: .6; cursor: wait; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--green-d); color: #fff; }
.topbar .brand { color: #fff; }
.topbar .btn.ghost { color: #fff; }
.device-pick { flex: 1; display: flex; justify-content: flex-end; }
.device-pick select { max-width: 240px; margin: 0; padding: 6px 8px; }
.nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 54px; z-index: 4; }
.nav button { white-space: nowrap; border: 0; background: transparent; padding: 8px 12px; border-radius: 20px; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted); }
.nav button.active { background: var(--green-l); color: var(--green-d); }
main { max-width: 1000px; margin: 0 auto; padding: 16px 12px 60px; }
.banner { background: #fffaeb; color: var(--amber); border-bottom: 1px solid #fedf89; padding: 10px 14px; font-size: 14px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.06); border: 1px solid var(--line); }
.head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat b { display: block; font-size: 22px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; background: #f2f4f7; color: #475467; }
.pill.green { background: #dcfae6; color: #067647; }
.pill.amber { background: #fef0c7; color: var(--amber); }
.pill.red { background: #fee4e2; color: var(--red); }
.pill.blue { background: #d1e9ff; color: #175cd3; }

.list-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fff; }
.list-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.list-item .title { font-weight: 700; }
.preview { white-space: pre-wrap; background: var(--green-l); border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 14px; max-height: 120px; overflow: auto; }
.meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.err { color: var(--red); font-size: 12.5px; margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table-wrap { overflow-x: auto; }

.qr-box { text-align: center; }
.qr-box img { width: 260px; max-width: 100%; border: 8px solid #fff; box-shadow: 0 0 0 1px var(--line); border-radius: 8px; }
.pair-code { font-size: 34px; letter-spacing: 4px; font-weight: 800; font-family: ui-monospace, monospace; background: var(--green-l); padding: 12px; border-radius: 10px; margin: 10px 0; }
ol.steps { text-align: left; font-size: 14px; padding-left: 20px; }

.group-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; margin-top: 6px; }
.group-list label { font-weight: 500; margin: 0; padding: 5px; display: flex; align-items: center; }

.modal { position: fixed; inset: 0; background: rgba(16,24,40,.5); display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; z-index: 20; }
.modal-box { position: relative; background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 520px; }
.modal-close { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #101828; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90%; font-size: 14px; }
.toast.error { background: var(--red); }

@media (max-width: 600px) {
  .topbar .brand .app-name { display: none; }
  .row { grid-template-columns: 1fr; }
  .nav { top: 50px; }
}
