/* dxSMS — modernes, responsives UI. Hell/Dunkel via prefers-color-scheme. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --border: #e2e7f0;
  --text: #1c2434;
  --text-muted: #6b7488;
  --primary: #2f6df0;
  --primary-hover: #2559cc;
  --primary-contrast: #ffffff;
  --success: #1f9d59;
  --danger: #d93a4a;
  --warning: #c98a12;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.08), 0 4px 16px rgba(20, 30, 60, 0.06);
  --radius: 10px;
  --sidebar-w: 248px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #161c2b;
    --surface-2: #1d2536;
    --border: #29324a;
    --text: #e7ebf3;
    --text-muted: #97a1b8;
    --primary: #4c86ff;
    --primary-hover: #6a9bff;
    --success: #35b872;
    --danger: #f2555f;
    --warning: #e0a637;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.login-card .brand {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -.5px;
  margin-bottom: .25rem;
}
.login-card .brand span { color: var(--primary); }
.login-card .sub { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -.5px;
  padding: 1.25rem 1.25rem .75rem;
}
.sidebar .brand span { color: var(--primary); }
.nav { flex: 1; overflow-y: auto; padding: .5rem; }
.nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .8rem;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--primary); color: var(--primary-contrast); }
.nav a .ico { width: 20px; text-align: center; }
.nav .group-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 1rem .8rem .35rem;
}
.sidebar .foot {
  border-top: 1px solid var(--border);
  padding: .9rem 1.25rem;
  font-size: .85rem;
  color: var(--text-muted);
}
.sidebar .foot .user { color: var(--text); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.content { padding: 1.5rem; max-width: 1100px; width: 100%; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.page-head h1 { font-size: 1.5rem; margin: 0; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h3 { font-size: 1.05rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin: .6rem 0 .25rem; }
input, select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 109, 240, .18);
}
textarea { resize: vertical; min-height: 90px; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.inline { display: flex; align-items: center; gap: .5rem; }
.inline input[type="checkbox"] { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .55rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-contrast);
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--text-muted); border-color: transparent; padding: .35rem .5rem; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: .3rem .6rem; font-size: .85rem; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.actions-cell { white-space: nowrap; text-align: right; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px;
  font-size: .76rem; font-weight: 650;
}
.badge.sent { background: rgba(31,157,89,.15); color: var(--success); }
.badge.failed { background: rgba(217,58,74,.15); color: var(--danger); }
.badge.pending { background: rgba(201,138,18,.15); color: var(--warning); }

/* ---------- Toolbar / search / pagination ---------- */
.toolbar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; }
.pagination { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: 1rem; color: var(--text-muted); }

/* ---------- Segment counter ---------- */
.seg-info { font-size: .82rem; color: var(--text-muted); margin-top: .35rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.seg-info .warn { color: var(--warning); font-weight: 600; }

/* ---------- Chips (Empfaenger-Auswahl) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .25rem .5rem .25rem .7rem; border-radius: 999px; font-size: .85rem;
}
.chip button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.chip button:hover { color: var(--danger); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,15,30,.5);
  display: grid; place-items: center; padding: 1rem; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 520px; padding: 1.5rem; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; }

/* ---------- Toast ---------- */
#toast-container { position: fixed; bottom: 1.25rem; right: 1.25rem; display: flex; flex-direction: column; gap: .6rem; z-index: 200; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 8px; box-shadow: var(--shadow); padding: .7rem 1rem; min-width: 240px; max-width: 360px;
  animation: slidein .2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

.help { font-size: .85rem; color: var(--text-muted); margin: .25rem 0 0; }
.empty { text-align: center; color: var(--text-muted); padding: 2rem 1rem; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
code.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--surface-2); padding: .1rem .35rem; border-radius: 5px; font-size: .85em; }

/* ---------- Mobile ---------- */
.menu-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text); }
@media (max-width: 800px) {
  .sidebar {
    position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .2s;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; }
  .content { padding: 1rem; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
}
