* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Hide native number-input spinner buttons on inputs that opt into the
 * custom paired +/- stepper UI (used by the Premium Tiers override editor).
 * Native spinner clicks don't reliably reveal their direction, so we
 * replace them with explicit buttons that know which way they're stepping. */
.no-native-spinner::-webkit-inner-spin-button,
.no-native-spinner::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
.no-native-spinner {
  -moz-appearance: textfield;
  appearance: textfield;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
  line-height: 1.6;
}

#root {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 2px solid #333;
  margin-bottom: 20px;
}

.header h1 {
  font-size: 1.75rem;
  color: #5865F2;
  margin: 0;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 0.85rem;
}

.status-badge.running {
  background: #43B581;
  color: white;
}

.status-badge.stopped {
  background: #F04747;
  color: white;
}

.status-badge.crashed {
  background: #FAA61A;
  color: #1a1a1a;
}

/* Cards */
.card {
  background: #2a2a2a;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #333;
}

.card h2 {
  color: #5865F2;
  margin-bottom: 12px;
  font-size: 1.25rem;
}

.card h3 {
  color: #ccc;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
  margin-bottom: 10px;
  transition: all 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: #5865F2;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #4752C4;
}

.btn-secondary {
  background: #4f545c;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #686d75;
}

.btn-success {
  background: #43B581;
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #3AA076;
}

.btn-danger {
  background: #F04747;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #D84040;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

.btn-warning {
  background: #FAA61A;
  color: #1a1a1a;
}

.btn-warning:hover:not(:disabled) {
  background: #E89510;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: #ccc;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 10px;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 5px;
  color: #e0e0e0;
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: #5865F2;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: #999;
  font-size: 0.85rem;
}

/* Instructions */
.instructions {
  background: #1a1a1a;
  padding: 12px;
  border-radius: 4px;
  border-left: 3px solid #5865F2;
}

.instructions h4 {
  color: #5865F2;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.instructions ol {
  margin-left: 18px;
  color: #ccc;
  font-size: 0.9rem;
}

.instructions li {
  margin-bottom: 4px;
}

/* Logs */
.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.logs-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.auto-scroll-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.logs-container {
  height: 400px;
  overflow-y: auto;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 0.5rem;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.4;
}

.log-line {
  padding: 0.25rem 0.5rem;
  border-left: 2px solid transparent;
  word-wrap: break-word;
}

.log-line:hover {
  background: rgba(255, 255, 255, 0.05);
}

.log-line.error {
  color: #ff6b6b;
  border-left-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.05);
}

.log-line.warning {
  color: #ffd93d;
  border-left-color: #ffd93d;
  background: rgba(255, 217, 61, 0.05);
}

.logs-empty {
  text-align: center;
  color: #999;
  padding: 2rem;
}

/* Loading Spinner */
.loading {
  text-align: center;
  padding: 40px;
  color: #999;
}

/* Legacy inline messages (kept for non-dismissible context messages like bot_not_running) */
.error-message {
  background: #F04747;
  color: white;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
}

.success-message {
  background: #43B581;
  color: white;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
}

.info-message {
  background: #5865F2;
  color: white;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
  border-left: 4px solid #4752C4;
}

/* ─── Toast Notification System ─── */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: auto;
  max-width: 520px;
}

.toast {
  pointer-events: auto;
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(-12px);
  animation: toast-in 0.25s ease forwards;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 520px;
  cursor: pointer;
}

.toast.toast-out {
  animation: toast-out 0.2s ease forwards;
}

.toast-error   { background: #d83c3e; }
.toast-success { background: #3ba55d; }
.toast-info    { background: #5865F2; }
.toast-warning { background: #f5af19; color: #1a1a1a; }

.toast.toast-sticky {
  border: 2px solid rgba(255, 255, 255, 0.35);
  font-weight: 600;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-12px); }
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #333;
}

.info-item:last-child {
  border-bottom: none;
}

.info-label {
  color: #999;
  font-weight: 600;
}

.info-value {
  color: #e0e0e0;
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  margin-bottom: 20px;
  border-bottom: 2px solid #333;
  padding-bottom: 0;
}

.tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #999;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  bottom: -2px;
  flex-shrink: 0;
  white-space: nowrap;
}

.tab:hover {
  color: #5865F2;
  background: rgba(88, 101, 242, 0.1);
}

.tab.active {
  color: #5865F2;
  border-bottom-color: #5865F2;
}

.tab-content {
  min-height: 300px;
}

/* Panel System - Button styles */
.button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
  margin-bottom: 10px;
  transition: all 0.2s;
  background: #5865F2;
  color: white;
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  background: #4752C4;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.button.secondary {
  background: #4f545c;
  color: #fff;
}

.button.secondary:hover:not(:disabled) {
  background: #5d6269;
}

/* Panel List */
.panel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: #2a2a2a;
  border-radius: 6px;
  padding: 20px;
}

/* Guild Web-UI Styles */

/* OAuth Login */
.oauth-loading, .oauth-error, .oauth-login {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.oauth-card {
  background: #2a2a2a;
  border-radius: 8px;
  padding: 40px;
  max-width: 500px;
  width: 100%;
  text-align: center;
}

.oauth-card h1 {
  margin: 0 0 10px 0;
  color: #e0e0e0;
}

.discord-login-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #5865F2;
  color: white;
  border: none;
  border-radius: 5px;
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  margin: 30px 0;
  transition: all 0.2s;
}

.discord-login-button:hover {
  background: #4752C4;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(88, 101, 242, 0.3);
}

.oauth-info {
  text-align: left;
  background: #1f1f1f;
  padding: 20px;
  border-radius: 5px;
  margin-top: 20px;
}

.oauth-info ul {
  margin: 10px 0;
  padding-left: 20px;
}

.oauth-info .note {
  font-size: 0.9rem;
  color: #999;
  margin-top: 10px;
}

/* Guild Selector */
.guild-selector {
  min-height: 100vh;
  background: #1a1a1a;
}

.guild-selector-header {
  background: #2a2a2a;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #333;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-avatar, .user-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.user-avatar-placeholder {
  background: #5865F2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.2rem;
}

.logout-button {
  background: #ed4245;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}

.logout-button:hover {
  background: #c73a3c;
}

.guild-selector-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.guild-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.guild-card {
  background: #2a2a2a;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.guild-card:hover {
  background: #333;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.guild-icon, .guild-icon-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  flex-shrink: 0;
}

.guild-icon-placeholder {
  background: #5865F2;
  display: flex;
  align-items: center;
  justify-center;
  font-weight: 600;
  font-size: 1.5rem;
}

.guild-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.guild-id {
  color: #999;
  font-size: 0.85rem;
}

.guild-arrow {
  font-size: 1.5rem;
  color: #999;
}

/* Guild Panels Panel */
.guild-panels-panel {
  min-height: 100vh;
  background: #1a1a1a;
}

.guild-panel-header {
  background: #2a2a2a;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #333;
}

.back-button {
  background: #4f545c;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}

.back-button:hover {
  background: #5d6269;
}

.guild-header-info {
  flex: 1;
  text-align: center;
}

.guild-header-info h2 {
  margin: 0;
}

.user-info-small {
  color: #999;
}

.guild-panel-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.panel-list-container h3 {
  margin-top: 0;
}

/* Empty states */
.guild-selector-empty, .guild-selector-loading, .guild-selector-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: 40px;
  text-align: center;
}

.guild-selector-empty ul {
  text-align: left;
  margin: 20px 0;
}

.panel-loading, .panel-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

/* Spinner */
.spinner {
  border: 4px solid #333;
  border-top: 4px solid #5865F2;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* Credentials Panel Styles */
.credentials-panel {
  padding: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.credentials-header {
  margin-bottom: 30px;
}

.credentials-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 40px;
}

.credentials-form {
  background: #2a2a2a;
  padding: 25px;
  border-radius: 10px;
}


.instruction-card {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.instruction-card:last-child {
  margin-bottom: 0;
}

/* ── Usage tab ─────────────────────────────────────────────────────────── */

.usage-panel {
  padding: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.usage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
}

.usage-live-indicator {
  flex: 1;
  color: #888;
  font-size: 0.78rem;
}

.usage-notice {
  background: #3a3320;
  border: 1px solid #8a7a2a;
  color: #fee75c;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.usage-offline {
  background: #2a2a2a;
  border-radius: 10px;
  padding: 40px;
  text-align: center;
  color: #aaa;
}

.usage-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.usage-stat-card {
  background: #2a2a2a;
  border-radius: 10px;
  padding: 14px 16px;
}

.usage-stat-title {
  color: #aaa;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.usage-stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.usage-stat-sub {
  color: #888;
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.usage-sparkline {
  display: block;
  margin-top: 4px;
  opacity: 0.9;
}

.usage-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.usage-areachart {
  background: #2a2a2a;
  border-radius: 10px;
  padding: 12px 14px;
}

.usage-areachart-label {
  color: #aaa;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.usage-areachart-range {
  display: flex;
  justify-content: space-between;
  color: #777;
  font-size: 0.72rem;
  margin-top: 4px;
}

.usage-areachart-placeholder {
  color: #666;
  padding: 30px 0;
  text-align: center;
}

.usage-boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.usage-board {
  background: #2a2a2a;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.usage-board h3 {
  margin: 0 0 10px 0;
  font-size: 1rem;
}

.usage-honesty {
  color: #888;
  font-size: 0.78rem;
  margin-bottom: 10px;
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.usage-table th {
  text-align: left;
  color: #aaa;
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid #444;
  white-space: nowrap;
}

.usage-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #333;
}

.usage-table-compact {
  font-size: 0.8rem;
}

/* Fleet tables pin their column widths so a live status push (changed guild
   counts, statuses, or an appearing/disappearing assign control) cannot resize
   columns and make the table jump. Scoped to fleet tables only - the shared
   .usage-table(-compact) metrics tables keep their content-based sizing. */
.fleet-table {
  table-layout: fixed;
}
.fleet-table td {
  word-break: break-word;
}

.usage-sortable {
  cursor: pointer;
  user-select: none;
}

.usage-sortable:hover {
  color: #fff;
}

.usage-guild-row {
  cursor: pointer;
}

.usage-guild-row:hover td {
  background: #313131;
}

.usage-guild-detail {
  background: #232323;
  border-radius: 8px;
  padding: 12px 14px;
}

.usage-guild-detail-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.usage-guild-detail h4 {
  margin: 0 0 8px 0;
  font-size: 0.85rem;
  color: #ccc;
}

.usage-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.usage-bar-label {
  width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  color: #ccc;
}

.usage-bar-track {
  flex: 1;
  height: 10px;
  background: #1c1c1c;
  border-radius: 5px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: #5865f2;
  border-radius: 5px;
}

.usage-bar-value {
  width: 80px;
  text-align: right;
  font-size: 0.78rem;
  color: #aaa;
}

.usage-badge-heavy {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #5c2b2b;
  color: #f0a0a0;
  font-size: 0.68rem;
  vertical-align: middle;
}

.usage-empty {
  color: #777;
  padding: 14px 0;
  text-align: center;
}

@media (max-width: 1000px) {
  .usage-charts,
  .usage-boards,
  .usage-guild-detail-cols {
    grid-template-columns: 1fr;
  }
}

.instruction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: #2a2a2a;
  border-bottom: 1px solid #444;
  transition: background 0.2s;
}

.instruction-header:hover {
  background: #333;
}

.instruction-header h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #e0e0e0;
}

.instruction-content {
  padding: 15px;
}

.instruction-content ol {
  margin: 0;
  padding-left: 20px;
  color: #999;
  font-size: 0.9rem;
  line-height: 1.6;
}

.instruction-example {
  margin-top: 10px;
  padding: 10px;
  background: #1a1a1a;
  border-radius: 4px;
  color: #FAA61A;
  font-size: 0.85rem;
}

.instruction-example code {
  color: #5865F2;
  word-break: break-all;
}

.instruction-placeholder {
  background: #1a1a1a;
  border: 2px dashed #444;
  border-radius: 8px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.section-divider {
  height: 2px;
  background: linear-gradient(90deg, transparent, #444, transparent);
  margin: 40px 0;
}

.credentials-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 30px;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .credentials-section {
    grid-template-columns: 1fr;
  }


@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }


/* Scrollbar Styling for Instructions */
.credentials-instructions::-webkit-scrollbar {
  width: 8px;
}

.credentials-instructions::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-radius: 4px;
}

.credentials-instructions::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

.credentials-instructions::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Instruction Card Link Styles */
.instruction-content a {
  color: #5865F2 !important;
  text-decoration: underline;
  transition: color 0.2s, opacity 0.2s;
}

.instruction-content a:hover {
  color: #7289DA !important;
  opacity: 0.8;
}

.instruction-content a:active {
  opacity: 0.6;
}

/* Fix instruction card sizing */

.instruction-card {
  min-height: fit-content;
  flex-shrink: 0;
}

.instruction-content {
  padding: 15px;
  max-height: none;
  overflow: visible;
}

/* Fixed instruction container styles */
.credentials-instructions {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-right: 10px;
}
