/* innoSMS GUI */
:root {
  --brand: #e8481c;
  --brand-dark: #c23a12;
  --brand-soft: #fdeee8;
  --ink: #1d2126;
  --ink-2: #4a525c;
  --muted: #6b7480;
  --line: #e3e6ea;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ok: #19794a;
  --ok-soft: #e6f4ec;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff5e0;
  --info: #1f5fa8;
  --info-soft: #e8f1fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; }
a { color: var(--brand-dark); }
a:hover { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #f0f1f3; padding: .1em .35em; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .6rem max(16px, calc((100% - 1200px) / 2));
  position: sticky; top: 0; z-index: 10;
}
.brand img { height: 26px; display: block; }
.mainnav { display: flex; gap: .2rem; flex-wrap: wrap; align-items: center; flex: 1; }
.mainnav a {
  text-decoration: none; color: var(--ink-2); padding: .45rem .7rem; border-radius: 8px; font-weight: 500;
}
.mainnav a:hover { background: var(--bg); color: var(--ink); }
.mainnav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-sep { width: 1px; height: 22px; background: var(--line); margin: 0 .4rem; }
.userbox { display: flex; align-items: center; gap: .9rem; white-space: nowrap; }
.userbox a { text-decoration: none; color: var(--ink); font-weight: 500; line-height: 1.2; text-align: right; }
.userbox a small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.userbox a.active { color: var(--brand-dark); }
.userbox form { margin: 0; }
.nav-toggle { display: none; }

@media (max-width: 960px) {
  .topbar { flex-wrap: wrap; gap: .6rem; }
  .nav-toggle {
    display: inline-block; margin-left: auto; border: 1px solid var(--line); background: #fff;
    border-radius: 8px; padding: .4rem .8rem; font: inherit; cursor: pointer;
  }
  .mainnav, .userbox { display: none; width: 100%; }
  .topbar.open .mainnav { display: flex; flex-direction: column; align-items: stretch; }
  .topbar.open .userbox { display: flex; justify-content: space-between; padding-top: .5rem; border-top: 1px solid var(--line); }
  .nav-sep { width: 100%; height: 1px; margin: .3rem 0; }
  .userbox a { text-align: left; }
}

/* ---------- layout ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.auth-container { width: 100%; max-width: 440px; margin: 0 auto; padding: 3rem 16px; }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo img { height: 40px; display: block; margin: 0 auto .3rem; }
.auth-logo span { color: var(--muted); font-size: .9rem; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; min-width: 0;
}
.card.narrow { max-width: 640px; }
.auth-card { padding: 1.75rem; }
.card-head, .page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.page-head h1 { margin: 0; }
.card-head h2 { margin: 0; }
.sticky { position: sticky; top: 80px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-2.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.align-start { align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
@media (max-width: 800px) {
  .grid-2, .grid-2.wide-left { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}
.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack > .card { margin-bottom: 0; }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; font-size: .92rem; }
label > input:not([type=checkbox]):not([type=radio]), label > select, label > textarea { display: block; margin-top: .3rem; }
label.check, label.chip-check { display: flex; flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
label.inline { display: flex; flex-direction: row; align-items: center; gap: .6rem; }
label.inline > select { margin-top: 0; width: auto; }
.stack > .btn, .stack > button { align-self: flex-start; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #cdd2d8; border-radius: 8px; padding: .55rem .7rem; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
input[type=file] { font: inherit; padding: .4rem 0; }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); flex: none; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: .7rem; }
legend { font-weight: 600; padding: 0 .3rem; font-size: .92rem; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.filters label { min-width: 150px; }
.filters .grow { flex: 1 1 240px; }
.filters.inline { margin-bottom: .8rem; }
.filters .check { align-self: center; min-width: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--ink); background: #fff; border: 1px solid #cdd2d8; border-radius: 8px; padding: .55rem 1rem;
}
.btn:hover { background: #f3f4f6; color: var(--ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { color: var(--bad); border-color: #f1b8b2; }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-small { padding: .3rem .65rem; font-size: .85rem; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.btn-row form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-dark); cursor: pointer; text-decoration: underline; }
.inline-form { margin-top: 1rem; color: var(--muted); }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: .8rem 0; border-top: 1px solid var(--line); }

/* ---------- alerts, badges ---------- */
.alert { border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cf; }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: #f5c2bd; }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: #f3dca6; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #c4dbf3; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 99px; background: var(--info-soft); color: var(--info); vertical-align: middle; margin-left: .3rem; }
.badge-muted { background: #eceef1; color: var(--muted); }
.chip { display: inline-block; font-size: .78rem; background: #f0f1f3; border-radius: 6px; padding: .1rem .45rem; margin: 0 .25rem .25rem 0; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.ok { color: var(--ok); font-weight: 500; }
.bad { color: var(--bad); font-weight: 500; }
.nowrap { white-space: nowrap; }

/* ---------- dashboard ---------- */
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.action-card {
  display: flex; flex-direction: column; gap: .2rem; text-decoration: none; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
  border-left: 4px solid var(--brand);
}
.action-card:hover { border-color: var(--brand); color: var(--ink); }
.action-card span { color: var(--muted); font-size: .88rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; min-width: 0; }
.stats.compact .stat { padding: .7rem .9rem; }
.card .stat { box-shadow: none; background: var(--bg); border: 0; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats.compact .stat-value { font-size: 1.25rem; }
.stat-sub { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: .55rem .6rem; border-bottom: 1px solid var(--line); background: #fafbfc; }
.table td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:hover { background: #fafbfc; }
.table .num { text-align: right; }
.table td.msg { min-width: 240px; max-width: 520px; white-space: pre-wrap; overflow-wrap: anywhere; }
.table tr.is-inactive td { color: var(--muted); }
.table tr.row-problem { background: #fff8f7; }
.table.review td { vertical-align: middle; }
.table.review .input-dest { width: 9.5rem; }
.table.review textarea { min-width: 260px; }
.table.preview td { white-space: nowrap; }
.table.users a.strong { text-decoration: none; color: var(--ink); }
.table.users a.strong:hover { color: var(--brand-dark); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .25rem; box-shadow: inset 0 -1px 0 var(--line); margin-bottom: .6rem; overflow-x: auto; overflow-y: hidden; }
.tabs a {
  display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap;
  padding: .6rem 1rem; text-decoration: none; color: var(--ink-2); font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tab-count { font-size: .75rem; font-weight: 600; background: #eceef1; color: var(--muted); border-radius: 99px; padding: .05rem .5rem; }
.tabs a.active .tab-count { background: var(--brand-soft); color: var(--brand-dark); }
.tab-help { margin: 0 0 1rem; }

/* ---------- senders page ---------- */
.refresh-note { margin: -.2rem 0 .8rem; }
.bulk-bar { margin-bottom: .5rem; min-height: 2rem; }
.table.senders td:first-child, .table.senders th:first-child { width: 1%; }
.users-preview { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

/* ---------- misc components ---------- */
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: 0 0 1.25rem; }
.steps li { padding: .35rem .8rem; border-radius: 99px; background: #eceef1; color: var(--muted); font-size: .85rem; font-weight: 500; }
.steps li.current { background: var(--brand); color: #fff; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.review-head p { margin: 0; }
.counter { margin: -.4rem 0 0; }
.counter.over { color: var(--bad); }

.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .45rem 1rem; margin: 0 0 1rem; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.secret { user-select: all; }
details summary { cursor: pointer; color: var(--brand-dark); }

.picker { border: 1px solid var(--line); border-radius: 8px; }
.picker-tools { display: flex; align-items: center; gap: .6rem; padding: .5rem; border-bottom: 1px solid var(--line); }
.picker-tools input { flex: 1; }
.picker-list { max-height: 340px; overflow-y: auto; padding: .5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .25rem .6rem; }
.chip-check { padding: .25rem .35rem; border-radius: 6px; font-size: .9rem; }
.chip-check:hover { background: var(--bg); }
.chip-check:has(input:checked) { background: var(--brand-soft); }
