/* SPX Combo Strategy - Responsive Stylesheet (Optimized for 390px mobile & desktop) */
:root {
  --bg-primary: #0b0f19;
  --bg-card: #131c2e;
  --bg-card-hover: #1b263b;
  --bg-input: #0f172a;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border-color: #23324d;
  --accent-blue: #38bdf8;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

/* Header & Navigation */
header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-container {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 640px) {
  .header-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.nav-link:hover, .nav-link.active {
  color: #fff;
  background-color: var(--border-color);
  text-decoration: none;
}

/* Clocks Banner */
.clock-banner {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.6);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}
.clock-pill {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Main Container */
main.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
  min-height: calc(100vh - 120px);
}

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

/* Card Component */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  overflow: visible;
}

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

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Responsive Grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.grid-4 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 960px) {
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Strategy Member Cards */
.member-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 4px solid var(--border-color);
}
.member-card.status-ok {
  border-left-color: var(--accent-green);
}
.member-card.status-warn {
  border-left-color: var(--accent-yellow);
}
.member-card.status-stop {
  border-left-color: var(--accent-red);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.badge-ok {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-green);
}
.badge-warn {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-yellow);
}
.badge-stop {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
}
.badge-neutral {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}

/* Tables */
.table-responsive {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
  box-sizing: border-box;
}

th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Key-value property tables */
.table-kv {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  box-sizing: border-box;
}
.table-kv td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Mobile responsive card tables */
@media (max-width: 640px) {
  .table-responsive-cards thead {
    display: none;
  }
  .table-responsive-cards, 
  .table-responsive-cards tbody, 
  .table-responsive-cards tr, 
  .table-responsive-cards td {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .table-responsive-cards tr {
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.4);
  }
  .table-responsive-cards td {
    padding: 4px 0;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .table-responsive-cards td::before {
    content: attr(data-label);
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 8px;
    flex-shrink: 0;
  }
}

th {
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(15, 23, 42, 0.4);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 14px;
  width: 100%;
  max-width: 100%;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="date"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.warning-box {
  background: rgba(245, 158, 11, 0.12);
  border-left: 4px solid var(--accent-yellow);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 0.84rem;
  color: #fef08a;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 42px;
}

.btn-primary {
  background: #0284c7;
  color: #fff;
}
.btn-primary:hover {
  background: #0369a1;
  text-decoration: none;
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-secondary {
  background: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: #2d3f60;
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

/* Alert Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-dialog {
  background: var(--bg-card);
  border: 2px solid var(--accent-red);
  border-radius: 12px;
  max-width: 500px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.8);
}

.modal-header {
  background: rgba(239, 68, 68, 0.15);
  padding: 14px 18px;
  border-bottom: 1px solid rgba(239, 68, 68, 0.3);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fca5a5;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.6;
}

.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

/* Info & Helper boxes */
.info-box {
  background: rgba(56, 189, 248, 0.1);
  border-left: 3px solid var(--accent-blue);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #bae6fd;
  margin-bottom: 12px;
}
.warning-box {
  background: rgba(245, 158, 11, 0.1);
  border-left: 3px solid var(--accent-yellow);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #fde68a;
  margin-bottom: 12px;
}

/* Mobile specific tuning */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  .card {
    padding: 12px;
  }
  th, td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
  .clock-banner {
    flex-direction: column;
    gap: 2px;
  }
}
