:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-dim: #8b8d98;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --bar-bg: #2a2d3a;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Account Selector */
.account-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.account-bar label {
  color: var(--text-dim);
  font-size: 0.9rem;
  white-space: nowrap;
}

#account-select {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

#account-select:focus {
  outline: none;
  border-color: var(--accent);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

/* Plan Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.info-item .label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.info-item .value {
  font-size: 1.1rem;
  font-weight: 600;
}

.status-active { color: var(--green); }
.status-expired { color: var(--red); }

/* Quota Bars */
.quota-row {
  margin-bottom: 1rem;
}

.quota-row:last-child { margin-bottom: 0; }

.quota-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.quota-header .name { color: var(--text-dim); }
.quota-header .detail { color: var(--text); font-weight: 500; }

.progress-bar {
  height: 8px;
  background: var(--bar-bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  min-width: 2px;
}

.fill-low { background: var(--green); }
.fill-mid { background: var(--yellow); }
.fill-high { background: var(--red); }

/* Section Header with controls */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h2 { margin-bottom: 0; }

.month-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.month-picker button {
  background: var(--border);
  color: var(--text);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.month-picker button:hover { background: var(--accent); }

#month-label {
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 80px;
  text-align: center;
}

/* Daily Table */
.table-wrap {
  overflow-x: auto;
}

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

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(99, 102, 241, 0.05); }

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* States */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-dim);
}

.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  text-align: center;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 1.5rem;
}

#refresh-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

#refresh-btn:hover { background: var(--accent-light); }
#refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }
