/* sip-provision admin UI — flat dark theme (no gradients, hairline borders) */
* { box-sizing: border-box; }
:root {
  --bg: #0d0f13;
  --panel: #14171d;
  --panel-2: #181c23;     /* table head / panel head */
  --panel-3: #1c212a;     /* hover / inputs */
  --line: #262b34;        /* hairline border */
  --line-2: #303642;      /* slightly stronger */
  --fg: #e6e9ef;
  --fg-dim: #aab2c0;
  --muted: #6f7889;
  --accent: #6366f1;
  --accent-fg: #ffffff;
  --accent-dim: rgba(99, 102, 241, 0.14);
  --good: #22c55e;  --good-bg: rgba(34, 197, 94, 0.13);
  --bad:  #ef4444;  --bad-bg:  rgba(239, 68, 68, 0.13);
  --warn: #f59e0b;  --warn-bg: rgba(245, 158, 11, 0.14);
  --radius: 8px;
  --radius-sm: 6px;
}

html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

/* ---- flat icons ---- */
.ic {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  flex: none; vertical-align: -2px;
}

/* ---- top bar ---- */
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  height: 56px; padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-fg);
}
.logo .ic { width: 17px; height: 17px; }
.logo.lg { width: 48px; height: 48px; border-radius: 12px; margin: 0 auto 14px; }
.logo.lg .ic { width: 26px; height: 26px; }
header nav { display: flex; gap: 18px; align-items: center; font-size: 13px; }
#who { color: var(--muted); }
.navlink { display: inline-flex; align-items: center; gap: 7px; color: var(--fg-dim); text-decoration: none; }
.navlink:hover { color: var(--fg); }

/* ---- layout ---- */
main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
h2 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
h3 {
  margin: 0; font-size: 12px; font-weight: 650; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--fg-dim);
  display: inline-flex; align-items: center; gap: 8px;
}
h3 .ic { width: 15px; height: 15px; color: var(--muted); }
.muted { color: var(--muted); }
.sub { margin: 5px 0 0; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }

/* ---- panels (clearly defined sections) ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 22px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th {
  background: var(--panel-2);
  font-weight: 600; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
th.num, td.num { text-align: center; width: 1%; white-space: nowrap; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-3); }
.actions-cell { width: 1%; white-space: nowrap; text-align: right; }
.actions-cell .btn + .btn { margin-left: 6px; }
td .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---- buttons ---- */
.btn {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--panel-3); border-color: var(--line-2); }
.btn .ic { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: #585bf0; border-color: #585bf0; }
.btn.danger { color: var(--bad); border-color: var(--line-2); background: transparent; }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }

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

/* ---- pills (flat) ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.on   { background: var(--good-bg); color: var(--good); }
.pill.off  { background: var(--bad-bg);  color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.neutral { background: var(--panel-3); color: var(--fg-dim); }
.pill.bare { background: var(--panel-3); color: var(--fg-dim); }
.pill.bare::before { display: none; }

/* ---- call direction ---- */
.dir { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 12.5px; }
.dir .ic { width: 15px; height: 15px; }
.dir.in  { color: var(--good); }
.dir.out { color: var(--accent); }

/* ---- switch (flat) ---- */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 36px; height: 20px; border-radius: 11px;
  background: var(--panel-3); border: 1px solid var(--line-2);
  position: relative; transition: background .15s, border-color .15s; flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--fg-dim); transition: transform .16s, background .16s;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-dim); }

/* ---- detail header ---- */
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.crumb:hover { color: var(--fg); text-decoration: none; }
.crumb .ic { width: 16px; height: 16px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.detail-head h2 { font-size: 21px; }
.detail-head .muted { margin-top: 3px; }

/* ---- stat cards ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.stat .k { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .k .ic { width: 14px; height: 14px; }
.stat .v { font-size: 15px; font-weight: 600; margin-top: 8px; }
.stat .v .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.stat .x { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- pagination ---- */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--panel-2); border-top: 1px solid var(--line);
}
.pager-info { font-size: 12px; color: var(--muted); }
.pager-ctrl { display: flex; align-items: center; gap: 4px; }
.pg {
  min-width: 30px; height: 30px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--fg-dim);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.pg:hover:not(:disabled):not(.active) { background: var(--panel-3); color: var(--fg); }
.pg.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); cursor: default; }
.pg:disabled { opacity: 0.4; cursor: not-allowed; }
.pg.gap { border: 0; background: none; cursor: default; color: var(--muted); min-width: 18px; }
.pg .ic { width: 16px; height: 16px; }

/* ---- empty state ---- */
.empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty b { color: var(--fg-dim); font-weight: 600; }

/* ---- dialog ---- */
dialog {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 22px 24px;
  min-width: 420px; max-width: 92vw;
}
dialog::backdrop { background: rgba(5, 7, 10, 0.6); }
dialog h3 { margin: 0 0 14px; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--fg); }
dialog label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
dialog input, dialog select {
  width: 100%; padding: 9px 11px; margin-bottom: 12px;
  background: var(--panel-3); color: var(--fg);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit;
}
dialog input:focus, dialog select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 8px 0 0; }
dialog button {
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--fg); cursor: pointer; font-size: 13px; font-weight: 500;
}
dialog button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

/* ---- login card ---- */
#login-card {
  max-width: 420px; margin: 72px auto; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px;
}
#login-card h2 { margin-bottom: 8px; }
#login-card p { color: var(--muted); margin: 8px 0 20px; }

/* ---- responsive ---- */
@media (max-width: 720px) {
  main { padding: 18px 14px 48px; }
  header { padding: 0 16px; }
  th, td { padding: 10px 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .pager { flex-direction: column; align-items: stretch; gap: 8px; }
  .pager-info { text-align: center; }
  .pager-ctrl { justify-content: center; }
}
