:root {
  --navy: #0f1f3d;
  --indigo: #1e3a8a;
  --indigo-light: #3b5fc0;
  --accent: #4f8ef7;
  --accent-hover: #3b7cf6;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #64748b;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

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

/* ── Header ── */
.header {
  background: var(--navy);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-logo span { color: var(--accent); }
.header-nav { display: flex; align-items: center; gap: 16px; }
.header-nav a { color: rgba(255,255,255,0.8); font-size: 14px; }
.header-nav a:hover { color: #fff; text-decoration: none; }
.btn-logout {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.btn-logout:hover { background: rgba(255,255,255,0.18); }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.page-title { font-size: 20px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 20px; }

/* ── Filter bar ── */
.filter-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.filter-group label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.filter-group select, .filter-group input {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.filter-group select:focus, .filter-group input:focus { border-color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #edf0f7; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Instance cards ── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.results-count { font-size: 13px; color: var(--text-muted); }

.instance-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .15s;
}
.instance-card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  gap: 12px;
  user-select: none;
}
.card-header:hover { background: #fafbfd; }

.instance-name { font-size: 15px; font-weight: 600; color: var(--navy); }
.instance-specs { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-general  { background: #e8f0fe; color: #1e3a8a; }
.badge-compute  { background: #ede9fe; color: #4c1d95; }
.badge-memory   { background: #dcfce7; color: #14532d; }
.badge-storage  { background: #fef3c7; color: #92400e; }

.od-price { text-align: right; }
.od-price .price-val { font-size: 16px; font-weight: 600; color: var(--navy); }
.od-price .price-label { font-size: 11px; color: var(--text-muted); }

.chevron { color: var(--text-muted); font-size: 14px; transition: transform .2s; flex-shrink: 0; }
.chevron.open { transform: rotate(180deg); }

.card-detail {
  display: none;
  border-top: 1px solid var(--border);
  padding: 18px;
}
.card-detail.open { display: block; }

/* ── Price sections ── */
.price-section { margin-bottom: 18px; }
.price-section:last-child { margin-bottom: 0; }
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.price-cell {
  background: var(--bg);
  border-radius: 7px;
  padding: 10px 12px;
}
.price-cell-label { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.price-cell-value { font-size: 17px; font-weight: 600; color: var(--navy); }
.price-cell-sub { font-size: 11px; color: var(--text-muted); }

.savings-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-top: 8px;
}

.ri-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.ri-tab {
  padding: 4px 11px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  background: #fff;
  color: var(--text-muted);
  transition: all .15s;
}
.ri-tab:hover { border-color: var(--accent); color: var(--accent); }
.ri-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

.card-actions { display: flex; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ── Auth pages ── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--indigo) 100%);
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 14px;
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.auth-logo {
  text-align: center;
  margin-bottom: 24px;
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}
.auth-logo span { color: var(--accent); }
.auth-title { font-size: 18px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.auth-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 5px; }
.form-group input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--accent); }

.btn-full { width: 100%; height: 42px; font-size: 14px; justify-content: center; border-radius: 8px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }

.alert {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert.show { display: block; }

/* ── History page ── */
.history-table { width: 100%; border-collapse: collapse; }
.history-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.history-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: #fafbfd; }

/* ── Loading ── */
.loading { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 13px; }
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .filter-bar { gap: 10px; }
  .filter-group { min-width: calc(50% - 6px); }
  .auth-card { padding: 28px 24px; }
  .price-grid { grid-template-columns: 1fr 1fr; }
}
