/* SimHub 控制台：扁平、克制，少圆角、无厚阴影，靠留白和排版分层。 */
:root {
  --bg: #f5f5f7; --panel: #ffffff; --line: #e4e5ea; --text: #15171c; --muted: #6b7280; --faint: #a3a8b3;
  --accent: #3d5bf5; --accent-soft: #e8edff; --green: #1e9e52; --red: #d93636; --amber: #b7791f;
  --bubble-in: #ffffff; --bubble-out: #3d5bf5; --radius: 6px; --side: 200px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --panel: #171a21; --line: #262a33; --text: #f2f3f6; --muted: #a2a8b3; --faint: #6e7480;
    --accent: #6f86ff; --accent-soft: #222b4d; --bubble-in: #1f232c; --bubble-out: #3d5bf5; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .error { color: var(--red); min-height: 1.2em; margin: 6px 0 0; }
code { font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; background: var(--accent-soft); padding: 1px 5px; border-radius: 3px; }
code.wrap { display: block; word-break: break-all; padding: 8px 10px; margin-bottom: 8px; }
h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: 0.2px; }
h2 { font-size: 15px; font-weight: 700; margin: 28px 0 10px; }
h3 { font-size: 13px; font-weight: 700; margin: 0 0 8px; color: var(--muted); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 7px 14px;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), background 150ms ease; }
button:active { transform: scale(0.97); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:disabled { opacity: 0.5; cursor: default; }
button.small { padding: 5px 10px; font-size: 13px; }
button.link { border: 0; background: transparent; color: var(--accent); padding: 4px 6px; }
button.danger { color: var(--red); }
input, select, textarea { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { resize: vertical; }

/* 登录 */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 360px; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.login-card h1 { margin-bottom: 4px; } .login-card label { display: block; margin: 18px 0 6px; font-weight: 600; }
.login-card input { width: 100%; } .login-card button { width: 100%; margin-top: 16px; }

/* 布局 */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 4px 10px 18px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.on { background: var(--green); } .dot.off { background: var(--red); }
.side a { padding: 8px 10px; border-radius: var(--radius); color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-foot { margin-top: auto; }
.badge { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 9px; min-width: 18px; text-align: center; }
.main { padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }

/* 卡 */
.sim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.sim-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.sim-card .tag { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 4px; display: inline-block; }
.sim-card .carrier { font-size: 17px; font-weight: 700; margin-top: 4px; }
.sim-card .state { font-size: 12px; font-weight: 600; }
.sim-card.off .carrier { color: var(--faint); }
.tag.t0 { background: #e3e8fe; color: #2a43c9; } .tag.t1 { background: #fdebdc; color: #9a4a06; }
.tag.t2 { background: #ddf3ef; color: #0b6b5d; } .tag.t3 { background: #ede6fe; color: #5b33c9; }
@media (prefers-color-scheme: dark) {
  .tag.t0 { background: #26305a; color: #c3ccff; } .tag.t1 { background: #4a2c14; color: #ffc897; }
  .tag.t2 { background: #123f38; color: #8fe3d3; } .tag.t3 { background: #34265a; color: #d6c6ff; }
}
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; margin-left: auto; }
.bars i { width: 3px; background: var(--line); border-radius: 1px; } .bars i.on { background: var(--text); }
.ok { color: var(--green); } .bad { color: var(--red); } .warn { color: var(--amber); }

/* 列表 / 表格 */
.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.list li { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col > div { min-width: 0; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.table th, .table td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.table th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 12px; }
.table td.num { font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* 短信 */
.sms-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; height: calc(100vh - 76px); }
.threads { display: flex; flex-direction: column; min-height: 0; }
.filter { margin-bottom: 10px; }
.threads-list { overflow: auto; flex: 1; }
.threads-list li { cursor: pointer; flex-direction: column; gap: 2px; align-items: stretch; }
.threads-list li.active { background: var(--accent-soft); }
.threads-list .row { display: flex; gap: 8px; align-items: baseline; }
.threads-list .peer { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.threads-list .snippet { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.thread > div { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.empty { margin: auto; color: var(--faint); }
.thread-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.thread-head .peer { font-weight: 700; font-size: 16px; }
.messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.msg { max-width: 72%; display: flex; flex-direction: column; gap: 3px; }
.msg.in { align-self: flex-start; } .msg.out { align-self: flex-end; align-items: flex-end; }
.msg .bubble { padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.msg.in .bubble { background: var(--bubble-in); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg.out .bubble { background: var(--bubble-out); color: #fff; border-bottom-right-radius: 3px; }
.msg .meta { font-size: 11px; color: var(--muted); }
.composer { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: end; }

/* 通讯录 */
.book { margin-bottom: 20px; }
.book h3 { display: flex; gap: 8px; align-items: center; }

/* 二维码 */
.qr-row { display: flex; gap: 20px; align-items: flex-start; }
#qr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }

/* 对话框 / 提示 */
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; background: var(--panel); color: var(--text); width: 420px; max-width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,0.35); }
.dialog-card { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
.dialog-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); font-size: 13px;
  animation: toast-in 200ms cubic-bezier(0.23, 1, 0.32, 1); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.97); } }
.only-mobile { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .brand { padding: 4px 8px; width: 100%; }
  .side-foot { margin-left: auto; }
  .main { padding: 16px; }
  .sms-layout { grid-template-columns: 1fr; height: auto; }
  .sms-layout.in-thread .threads { display: none; }
  .sms-layout:not(.in-thread) .thread { display: none; }
  .thread { height: calc(100vh - 140px); }
  .two-col { grid-template-columns: 1fr; }
  .only-mobile { display: inline-block; }
  .qr-row { flex-direction: column; }
}
