:root {
  --bg-color: #f4f6f9;
  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(255, 255, 255, 0.6);
  --line-soft: rgba(0, 0, 0, 0.04);
  --text-main: #2c3e50;
  --text-muted: #7f8c8d;
  --accent: #5a8dee;
  --accent-hover: #487eb0;
  --danger: #ff7675;
  --warn: #fdcb6e;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-soft: 0 8px 32px -8px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 12px 40px -8px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.gm-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 32px;
  position: relative;
  z-index: 1;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.login-error {
  min-height: 1.5em;
  color: #ff9b9b;
}

.login-link {
  color: var(--accent);
  text-align: center;
  font-size: 14px;
  text-decoration: none;
}

.login-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.gm-table {
  width: 100%;
  border-collapse: collapse;
}

.gm-table th,
.gm-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  text-align: left;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background-color: #f0f4f8;
  background-image: 
    linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 100%),
    radial-gradient(circle at 15% 25%, rgba(132, 172, 250, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(0, 210, 211, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 120%, rgba(108, 92, 231, 0.05) 0%, transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.bg-grid, .bg-ring {
  display: none;
}

.hero {
  display: flex;
  justify-content: space-between;
  padding: 32px 6vw 16px 6vw;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.hero__brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.brand-sub {
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.wrap {
  padding: 0 6vw 80px 6vw;
  max-width: 1400px;
  margin: 0 auto;
}

.topnav {
  display: flex;
  gap: 24px;
  padding: 0 6vw 12px 6vw;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(244, 246, 249, 0.7);
  z-index: 10;
  margin-bottom: 24px;
}

.topnav__item {
  color: var(--text-muted);
  text-decoration: none;
  padding: 10px 4px;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.topnav__item:hover {
  color: var(--accent);
}

.topnav__item.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.topnav__logout {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.gm-nav-notice {
  margin: -12px 6vw 20px;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  font-size: 13px;
}

.gm-nav-notice--error {
  border-left-color: var(--danger);
  color: #b54848;
}

.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  margin: 24px 0;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: var(--transition);
}

.panel:hover {
  box-shadow: var(--shadow-hover);
}

.panel__title {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.4);
}

.panel__content {
  padding: 24px;
}

.grid-2 {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-3 {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.is-hidden {
  display: none !important;
}

.field input, .field select, .field textarea {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 141, 238, 0.15);
  background: #ffffff;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.mail-targets,
.mail-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
  align-items: center;
}

.mail-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(90, 141, 238, 0.25);
  border-radius: var(--radius-sm);
  background: rgba(90, 141, 238, 0.08);
  color: var(--text-main);
  font-size: 12px;
}

.mail-tag button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.mail-item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

@media (max-width: 600px) {
  .mail-item-row { grid-template-columns: 1fr auto; }
  .mail-item-row .mail-item-count { grid-column: 1; }
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

.actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(90, 141, 238, 0.2);
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(90, 141, 238, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn.warn {
  background: var(--warn);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(253, 203, 110, 0.2);
}

.btn.warn:hover {
  background: #f1c40f;
  box-shadow: 0 6px 16px rgba(253, 203, 110, 0.3);
}

.btn.danger {
  background: var(--danger);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(255, 118, 117, 0.2);
}

.btn.danger:hover {
  background: #ff4757;
  box-shadow: 0 6px 16px rgba(255, 118, 117, 0.3);
}

.req {
  margin-top: 20px;
  border-radius: var(--radius-md);
  background: rgba(244, 246, 249, 0.6);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.req__title {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.5);
}

pre {
  margin: 0;
  padding: 16px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 13px;
  color: #2f3640;
  white-space: pre-wrap;
  word-break: break-all;
  background: transparent;
}

.preview-panel .panel__content {
  padding-top: 12px;
}

.preview-line {
  display: none;
  border: 1px dashed rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-md);
  margin: 8px 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.8);
  transition: var(--transition);
}

.preview-line:hover {
  background: #ffffff;
  border-color: var(--accent);
}

.preview-line.is-visible {
  display: block;
}

.toast {
  position: fixed;
  right: 24px;
  top: 24px;
  bottom: auto;
  background: #ffffff;
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 16px 20px 16px 24px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  z-index: 9999;
  min-width: 280px;
  max-width: 400px;
  text-align: left;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.15), 0 4px 12px -2px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--accent);
  line-height: 1.5;
  word-wrap: break-word;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 20px;
  background: #ffffff;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--line-soft);
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge {
  position: fixed;
  right: 6vw;
  top: 24px;
  z-index: 20;
}

.status.online {
  color: #2ed573;
  border-color: rgba(46, 213, 115, 0.2);
  background: rgba(46, 213, 115, 0.05);
}

.status.offline {
  color: var(--danger);
  border-color: rgba(255, 118, 117, 0.2);
  background: rgba(255, 118, 117, 0.05);
}

.response {
  min-height: 120px;
  border-radius: var(--radius-md);
  background: rgba(244, 246, 249, 0.6);
  border: 1px solid var(--line-soft);
}

.footer {
  padding: 24px 6vw 40px 6vw;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-top: 1px solid var(--line-soft);
  max-width: 1400px;
  margin: 0 auto;
}

.footer code {
  background: rgba(0, 0, 0, 0.04);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

@media (max-width: 768px) {
  .hero {
    padding: 24px 6vw 12px 6vw;
  }
  .brand-title {
    font-size: 20px;
  }
  .topnav {
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
  }
  .topnav__item {
    white-space: nowrap;
  }
  .status-badge {
    position: relative;
    right: auto;
    top: auto;
    margin: 0 6vw 16px;
  }
}

.btn--small {
  padding: 7px 11px;
  font-size: 12px;
}

.grid-span-2 {
  grid-column: 1 / -1;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.metric-item {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
}

.metric-item span,
.metric-item strong,
.metric-item small {
  display: block;
}

.metric-item span,
.metric-item small {
  color: var(--text-muted);
  font-size: 12px;
}

.metric-item strong {
  margin: 5px 0;
  color: var(--text-main);
  font-size: 22px;
}

.metric-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-note {
  float: right;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 20px;
}

.gm-table td {
  white-space: pre-line;
  vertical-align: top;
}

.state-tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.06);
  font-size: 12px;
}

.state-tag--published,
.state-tag--sent {
  color: #21784b;
  background: rgba(46, 213, 115, 0.14);
}

.state-tag--withdrawn,
.state-tag--cancelled,
.state-tag--failed {
  color: #b43d3d;
  background: rgba(255, 118, 117, 0.14);
}

.state-tag--processing {
  color: #8a6500;
  background: rgba(253, 203, 110, 0.25);
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.actions .btn + .btn {
  margin-left: 0;
}

.system-actions {
  margin-top: 16px;
}

.log-view {
  overflow: auto;
  max-height: 420px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: #dfe6e9;
  background: #202a35;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

.empty-state {
  color: var(--text-muted);
}

@media (max-width: 700px) {
  .grid-span-2 {
    grid-column: auto;
  }

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

.workspace-toolbar {
  display: grid;
  gap: 12px;
  padding-bottom: 4px;
}

.permission-banner {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid rgba(90, 141, 238, 0.2);
  border-radius: var(--radius-md);
  color: var(--text-main);
  background: rgba(90, 141, 238, 0.08);
  font-size: 13px;
}

.permission-banner strong {
  color: var(--accent-hover);
  white-space: nowrap;
}

.quick-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: thin;
}

.quick-nav a {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.48);
  font-size: 12px;
  text-decoration: none;
}

.quick-nav a:hover {
  color: var(--accent);
  border-color: rgba(90, 141, 238, 0.35);
}

.workflow-callout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px dashed rgba(90, 141, 238, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(90, 141, 238, 0.05);
}

.workflow-callout strong {
  color: var(--text-main);
  font-size: 13px;
}

.workflow-callout select {
  flex: 1 1 220px;
  min-width: 180px;
}

.workflow-callout .muted {
  flex: 1 1 260px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.player-search {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.player-search__field {
  min-width: 0;
}

.player-table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

.player-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.player-pagination .btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.player-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.player-heading strong {
  display: inline-block;
  font-size: 20px;
}

.player-heading strong + span {
  display: inline-block;
  margin-left: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.player-status {
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.player-status--active {
  color: #21784b;
  background: rgba(46, 213, 115, 0.14);
}

.player-status--inactive {
  color: #b43d3d;
  background: rgba(255, 118, 117, 0.14);
}

.player-summary-grid,
.player-currency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.player-summary-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.42);
}

.player-summary-item span,
.player-summary-item strong {
  display: block;
}

.player-summary-item span {
  color: var(--text-muted);
  font-size: 12px;
}

.player-summary-item strong {
  overflow: hidden;
  margin-top: 4px;
  color: var(--text-main);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.player-action-group {
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.36);
}

.player-action-group h2,
.player-history-grid h2 {
  margin: 0 0 16px;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 600;
}

.player-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.history-list {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.history-row {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.history-row strong {
  color: var(--text-main);
  font-size: 13px;
}

.history-row span {
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 600px) {
  .player-search {
    grid-template-columns: 1fr;
  }

  .player-pagination {
    justify-content: space-between;
  }

  .player-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
