@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg: #eef2f3;
  --panel: #ffffff;
  --panel-soft: #f7faf9;
  --text: #18211f;
  --muted: #65716e;
  --line: #d9e2df;
  --primary: #106b5b;
  --primary-strong: #0a4d42;
  --accent: #b4571b;
  --danger: #b42318;
  --success: #1d7b52;
  --shadow: 0 18px 42px rgba(21, 39, 36, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: var(--bg);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.notification-rail {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 28px);
  padding: 0 16px;
  overflow: auto;
  pointer-events: none;
}

.shell {
  width: 100%;
  margin: 0;
  padding: 18px;
  display: grid;
  gap: 18px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel label,
.tool-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.login-panel input,
.tool-panel input,
.tool-panel select,
.tool-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.cloud-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.tool-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.actions.left {
  justify-content: flex-start;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  font-family: "IBM Plex Mono", monospace;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
}

.summary {
  margin-top: 10px;
  color: var(--muted);
  max-width: 64rem;
}

.actions,
.modal-actions,
.phone-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 120ms ease, background 120ms ease, border-color 120ms ease;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.btn-small {
  padding: 8px 10px;
  font-size: 13px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-secondary {
  background: #e6efec;
  color: var(--primary);
  border: 1px solid #c9d9d4;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn.danger {
  color: var(--danger);
  background: #f8e7e5;
  border-color: #efc9c4;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric,
.tabs-card,
.preview-panel,
.modal-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px 20px;
}

.metric-label,
.path-badge,
.session-meta dt {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 36px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.workspace.preview-open {
  grid-template-columns: minmax(0, 2fr) minmax(460px, 1fr);
}

.tabs-card,
.preview-panel {
  padding: 18px;
  min-width: 0;
}

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

.path-badge {
  color: var(--muted);
  text-align: right;
  word-break: break-all;
}

.tabs {
  display: grid;
  gap: 16px;
}

.tab-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tab-button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-toolbar,
.phone-filter-main {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px;
  gap: 10px;
}

.account-toolbar {
  margin-bottom: 12px;
}

.phone-filter-toolbar {
  margin-bottom: 8px;
}

.account-toolbar input,
.account-toolbar select,
.phone-filter-main input,
.phone-filter-main select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: var(--panel-soft);
}

.phone-filter-main {
  flex: 1 1 440px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.phones-table {
  min-width: 1180px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  text-align: left;
  padding: 12px 14px;
  font-size: 13px;
}

tbody td {
  padding: 14px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.muted {
  color: var(--muted);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.status-pill,
.event-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.pending {
  background: rgba(180, 87, 27, 0.12);
  color: #8d3f0f;
}

.status-pill.loaded,
.event-status.running {
  background: rgba(16, 107, 91, 0.12);
  color: var(--primary);
}

.status-pill.saved,
.event-status.success {
  background: rgba(29, 123, 82, 0.12);
  color: var(--success);
}

.event-status.failed {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.12);
}

.event-meta {
  color: var(--muted);
  font-size: 13px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--primary);
}

.switch input {
  width: 18px;
  height: 18px;
}

.events-list,
.logs-list {
  display: grid;
  gap: 12px;
}

.logs-list {
  max-height: 820px;
  overflow: auto;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
  color: #dce7e4;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.event,
.log-entry {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.event-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}

.log-entry.error {
  border-color: rgba(180, 35, 24, 0.28);
}

.log-entry.warning {
  border-color: rgba(180, 87, 27, 0.3);
}

.log-entry pre {
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #edf3f1;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.log-line {
  display: grid;
  grid-template-columns: 150px 54px minmax(180px, 0.7fr) minmax(260px, 1.8fr);
  gap: 10px;
  padding: 4px 10px;
  border-bottom: 1px solid rgba(220, 231, 228, 0.08);
  align-items: baseline;
}

.log-line:last-child {
  border-bottom: 0;
}

.log-line.error {
  color: #ffd2cc;
  background: rgba(180, 35, 24, 0.16);
}

.log-line.warning {
  color: #ffe0bd;
  background: rgba(180, 87, 27, 0.13);
}

.log-time,
.log-level,
.log-meta {
  color: #8fa19d;
}

.log-level {
  font-weight: 700;
}

.log-msg,
.log-meta {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.session-meta {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.session-meta dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.session-meta div {
  display: grid;
  gap: 3px;
}

.session-meta dd {
  margin: 0;
  font-weight: 700;
}

.preview-frame {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  min-height: 560px;
  background: #edf3f1;
  border: 1px solid #c8d9d4;
}

.phone-toolbar,
.phone-op-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.phone-toolbar {
  flex-wrap: wrap;
}

.phone-toolbar-main,
.phone-toolbar-inline {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.phone-toolbar-inline {
  margin-left: auto;
  justify-content: flex-end;
}

.phone-toolbar-inline label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-weight: 700;
}

.phone-toolbar-inline select {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.tool-strip {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.tool-strip label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.tool-strip input,
.tool-strip select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.phone-operation-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.phone-op-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.phone-op-meta > div {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.phone-op-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.phone-op-meta strong {
  overflow-wrap: anywhere;
}

.phone-op-group {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.phone-op-group h3,
.phone-op-result h3 {
  margin: 0;
  font-size: 14px;
}

.phone-op-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shell-box textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: 12px/1.45 "IBM Plex Mono", monospace;
  background: var(--panel-soft);
}

.phone-op-result {
  display: grid;
  gap: 8px;
}

.phone-op-result pre {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 8px;
  padding: 10px;
  background: #101817;
  color: #dce7e4;
  font: 12px/1.45 "IBM Plex Mono", monospace;
}

#previewImage {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 22, 20, 0.38);
}

.modal[hidden] {
  display: none;
}

.modal-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog.small {
  width: min(520px, calc(100vw - 32px));
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-filter input,
.backup-fields input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font: inherit;
  background: var(--panel-soft);
}

.account-choice-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  overflow: auto;
  min-height: 180px;
  max-height: min(48vh, 440px);
  padding-right: 4px;
}

.account-choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
}

.account-choice span {
  display: grid;
  gap: 4px;
}

.backup-fields {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

.backup-fields label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.radio-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.modal-actions {
  position: sticky;
  bottom: -18px;
  margin: 12px -18px -18px;
  padding: 12px 18px 18px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  z-index: 2;
}

.account-note-cell {
  max-width: 260px;
  color: var(--muted);
}

.account-detail-dialog {
  width: min(860px, calc(100vw - 32px));
}

.account-detail-body {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding-right: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid > div,
.detail-row {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.detail-grid span,
.note-editor span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.note-editor {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.note-editor textarea,
.note-editor select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: var(--panel-soft);
}

.note-editor textarea {
  resize: vertical;
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section h3 {
  margin: 0;
  font-size: 15px;
}

.detail-list {
  display: grid;
  gap: 8px;
}

.detail-row.user-row {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  align-items: center;
}

.detail-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.grant-cell {
  min-width: 112px;
}

.notice {
  pointer-events: auto;
  display: grid;
  gap: 8px;
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 16px 18px;
  border-radius: 8px;
  color: #fff;
  background: rgba(24, 33, 31, 0.96);
  box-shadow: 0 20px 50px rgba(24, 33, 31, 0.22);
}

.notice.error {
  background: rgba(180, 35, 24, 0.96);
}

.notice.success {
  background: rgba(16, 107, 91, 0.96);
}

.notice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.notice-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

@media (max-width: 1180px) {
  .hero,
  .workspace,
  .workspace.preview-open {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-frame {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 10px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .actions .btn,
  .modal-actions .btn {
    width: 100%;
  }

  .preview-frame {
    min-height: 320px;
  }

  .detail-grid,
  .log-line,
  .phone-op-meta,
  .phone-filter-main,
  .account-toolbar,
  .tool-strip,
  .detail-row.user-row {
    grid-template-columns: 1fr;
  }

  .phone-toolbar-inline {
    margin-left: 0;
    justify-content: flex-start;
  }

  .detail-row-actions {
    justify-content: flex-start;
  }
}
