/* 1817 platform shell — shared across Softphone / Operator / Lab */
:root {
  --shell-bg: #f4f2ee;
  --shell-ink: #1c1917;
  --shell-muted: #78716c;
  --shell-line: #e7e5e4;
  --shell-card: #fffcf8;
  --shell-side: #1c1917;
  --shell-side-text: #d6d3d1;
  --shell-side-muted: #a8a29e;
  --shell-accent: #0f766e;
  --shell-accent-soft: #ccfbf1;
  --shell-danger: #b91c1c;
  --shell-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --shell-sans: "IBM Plex Sans", "PingFang HK", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }

.app-shell {
  display: flex !important;
  flex-direction: row !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--shell-bg) !important;
  color: var(--shell-ink) !important;
  font-family: var(--shell-sans) !important;
}

/* ---- Sidebar (identical on every page) ---- */
.app-shell > .sidebar {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 22px 14px 18px;
  background: var(--shell-side);
  color: var(--shell-side-text);
  border-right: 0;
}

.app-shell > .sidebar .sb-brand {
  padding: 2px 12px 20px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #fafaf9;
  line-height: 1.1;
}

.app-shell > .sidebar .sb-sub {
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--shell-side-muted);
}

.app-shell > .sidebar .sb-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0 0 4px;
}

.app-shell > .sidebar .sb-label {
  padding: 12px 12px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #78716c;
}

.app-shell > .sidebar .sb-split {
  height: 1px;
  margin: 14px 10px;
  background: rgba(255, 255, 255, 0.08);
}

.app-shell > .sidebar .sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--shell-side-text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.app-shell > .sidebar .sb-item::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #57534e;
  flex: none;
}

.app-shell > .sidebar .sb-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.app-shell > .sidebar .sb-item.on {
  background: rgba(15, 118, 110, 0.28);
  color: #f0fdfa;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.25);
}

.app-shell > .sidebar .sb-item.on::before {
  background: #2dd4bf;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2);
}

.app-shell > .sidebar .sb-foot {
  margin-top: auto;
  padding: 12px 12px 4px;
  font-size: 0.7rem;
  color: #57534e;
  line-height: 1.4;
}

/* ---- Main canvas ---- */
.app-shell > .main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 22px 22px;
  overflow: auto;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(15, 118, 110, 0.06), transparent 55%),
    var(--shell-bg);
}

.app-shell > .main > .main-inner {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.app-shell > .main > .main-inner.narrow {
  max-width: 440px;
}

/* Softphone: full-bleed on phone; capped stage on desktop */
.app-shell.softphone-mode {
  background: #000 !important;
}
.app-shell.softphone-mode > .sidebar {
  display: none !important;
}
.app-shell.softphone-mode > .main {
  padding: 0;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.app-shell.softphone-mode > .main > .main-inner {
  max-width: none;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.app-shell.softphone-mode > .main > .main-inner.narrow {
  max-width: none;
}

@media (min-width: 520px) {
  .app-shell.softphone-mode > .main {
    align-items: center;
    justify-content: center;
    padding: 16px;
  }
  .app-shell.softphone-mode > .main > .main-inner,
  .app-shell.softphone-mode > .main > .main-inner.narrow {
    /* only caps — fills available window space otherwise */
    width: 100%;
    height: 100%;
    max-width: 390px;
    max-height: 844px;
    flex: none;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
  }
}

.app-shell > .main > .main-inner.wide {
  max-width: none;
}

/* ---- Shared bottom app tabs (Softphone / Operator / Lab) ---- */
.phone-tabs {
  margin-top: auto;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: stretch;
  gap: 0;
  padding: 8px 4px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid #e5e5ea;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex: none;
  width: 100%;
  box-sizing: border-box;
  z-index: 20;
}
.phone-tabs .tab {
  border: 0;
  background: transparent;
  color: #8e8e93;
  font-size: 0.62rem;
  font-weight: 500;
  font-family: inherit;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.phone-tabs .tab:active { opacity: 0.55; }
.phone-tabs .tab svg { width: 22px; height: 22px; flex: none; }
.phone-tabs .tab.active { color: #007aff; }

/* Laptop pages: bottom nav, full-window (no max w/h) */
.app-shell.desk-mode {
  flex-direction: column !important;
  background: var(--shell-bg) !important;
}
.app-shell.desk-mode > .sidebar {
  display: none !important;
}
.app-shell.desk-mode > .main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: auto;
  padding: 16px 18px 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-shell.desk-mode > .main > .main-inner,
.app-shell.desk-mode > .main > .main-inner.wide,
.app-shell.desk-mode > .main > .main-inner.narrow,
.app-shell.desk-mode > .main > .main-inner.wrap {
  max-width: none;
  width: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.app-shell.desk-mode > .phone-tabs {
  background: #fff;
  border-top: 1px solid var(--shell-line);
  box-shadow: 0 -8px 24px rgba(28, 25, 23, 0.04);
  flex: none;
  position: sticky;
  bottom: 0;
}

.page-head { display: none; }

.page-head h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--shell-ink);
}

.page-head p {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--shell-muted);
}

.surface {
  background: var(--shell-card);
  border: 1px solid var(--shell-line);
  border-radius: 18px;
  box-shadow: 0 1px 0 rgba(28, 25, 23, 0.04), 0 12px 32px rgba(28, 25, 23, 0.05);
}

@media (max-width: 760px) {
  .app-shell {
    flex-direction: column !important;
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
  .app-shell > .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 14px 12px;
  }
  .app-shell > .sidebar .sb-brand {
    width: 100%;
    padding: 0 4px 8px;
  }
  .app-shell > .sidebar .sb-split {
    width: 100%;
    margin: 6px 0;
  }
  .app-shell > .sidebar .sb-group {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .app-shell > .sidebar .sb-label,
  .app-shell > .sidebar .sb-foot {
    display: none;
  }
  .app-shell > .sidebar .sb-item {
    width: auto;
  }
  .app-shell > .main {
    padding: 14px;
  }
}
