/* ============================================================================
   Azure Cost Dashboard — design system
   Dark, calm, GitHub-adjacent. Tokens first, then base, then components.
   All class/ID names referenced by app.js are preserved.
   ========================================================================== */

:root {
  /* surfaces */
  --bg: #0c1016;
  --bg-grad-1: #0e131d;
  --bg-grad-2: #0a0d13;
  --surface: #151b24;
  --surface-2: #1b2230;
  --surface-3: #222c3a;
  --border: #28313f;
  --border-soft: #1f2733;

  /* text */
  --text: #e6edf3;
  --text-dim: #b6c2cf;
  --muted: #8593a3;

  /* accent + status */
  --accent: #4c8dff;
  --accent-2: #2f6fe4;
  --accent-soft: rgba(76, 141, 255, .14);
  --ok: #4ac46a;   --ok-soft: rgba(74, 196, 106, .14);
  --warn: #e0a734; --warn-soft: rgba(224, 167, 52, .14);
  --bad: #ff5f56;  --bad-soft: rgba(255, 95, 86, .13);

  /* legacy aliases (kept so any inline var() refs stay valid) */
  --panel: var(--surface);
  --panel-2: var(--surface-2);

  /* shape + depth */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow: 0 6px 22px rgba(0, 0, 0, .32);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
  --ring: 0 0 0 3px rgba(76, 141, 255, .35);
  --ease: .18s cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  min-height: 100%;
  background-color: var(--bg-grad-2);
  background-image: radial-gradient(1200px 600px at 80% -5%, #131c2b 0%, transparent 60%),
                    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2) 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}

/* tidy scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #2c3a4c; background-clip: content-box; }

/* ---- top bar ---------------------------------------------------------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 24px;
  background: rgba(15, 20, 28, .72);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
#topbar .brand {
  font-weight: 700; letter-spacing: .2px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px; color: var(--text);
}
#topbar .brand::first-letter { font-size: 1.15em; }
#topbar nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#topbar nav a {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 7px 12px; border-radius: var(--radius-sm); transition: color var(--ease), background var(--ease);
}
#topbar nav a:hover { color: var(--text); background: var(--surface-2); }
#topbar nav a.active { color: #fff; background: var(--accent-soft); }
#who {
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--border);
}

/* ---- layout / type ---------------------------------------------------- */
main { padding: 32px 24px 64px; max-width: 1120px; margin: 0 auto; }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.4px; font-weight: 700; }
h2 { font-size: 15px; margin: 30px 0 14px; letter-spacing: .3px; text-transform: uppercase; color: var(--text-dim); font-weight: 700; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--text-dim); font-weight: 600; }
.sub { color: var(--muted); font-size: 14.5px; margin: 0 0 24px; max-width: 70ch; }

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

/* ---- buttons ---------------------------------------------------------- */
button {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff; border: 0; border-radius: var(--radius-sm);
  padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--ease), filter var(--ease), box-shadow var(--ease), background var(--ease);
}
button:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: var(--shadow); }
button:active { transform: translateY(0); filter: brightness(.96); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button.ghost {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  box-shadow: none;
}
button.ghost:hover { background: var(--surface-3); color: var(--text); filter: none; }
button.danger { background: transparent; border: 1px solid var(--bad-soft); color: var(--bad); box-shadow: none; }
button.danger:hover { background: var(--bad-soft); filter: none; color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; filter: none; }

/* ---- form controls ---------------------------------------------------- */
input, select {
  width: 100%; padding: 10px 13px; background: var(--bg);
  color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; transition: border-color var(--ease), box-shadow var(--ease);
}
input::placeholder { color: #5d6b7a; }
input:hover, select:hover { border-color: #34414f; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
input[type=checkbox] {
  width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; vertical-align: middle;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 500; }

/* ---- cards ------------------------------------------------------------ */
.card {
  background: linear-gradient(180deg, var(--surface), #131922);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm);
}
.center-card { max-width: 380px; margin: 9vh auto 0; box-shadow: var(--shadow-lg); }

/* auth logo on the login screen */
.auth-logo {
  width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 14px;
  display: grid; place-items: center; font-size: 26px;
  background: var(--accent-soft); border: 1px solid var(--border);
}

/* ---- inline messages -------------------------------------------------- */
.error { color: var(--bad); font-size: 13px; margin: 12px 0 0; }
.notice { color: var(--muted); font-size: 13px; margin: 10px 0; }

/* ---- dashboard grid + tiles ------------------------------------------ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.tile {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface), #131922);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.tile::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), #7aa6ff);
  opacity: 0; transition: opacity var(--ease);
}
.tile:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.tile:hover::before { opacity: 1; }
.tile .name { font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .cost { font-size: 30px; font-weight: 750; letter-spacing: -.5px; margin: 10px 0 8px; font-variant-numeric: tabular-nums; }
.tile .cost.stale { color: var(--muted); }
.tile .meta { color: var(--muted); font-size: 12px; }
.tile .subid { color: #6b7888; font-size: 11px; font-family: ui-monospace, "SF Mono", Menlo, monospace; margin-top: 10px; word-break: break-all; }

/* ---- drag-to-reorder -------------------------------------------------- */
.tile { -webkit-user-select: none; user-select: none; }
.tile .drag-handle {
  position: absolute; top: 8px; right: 10px;
  color: #6b7888; font-size: 13px; line-height: 1; letter-spacing: -2px;
  cursor: grab; opacity: 0; transition: opacity var(--ease);
}
.tile:hover .drag-handle { opacity: .7; }
.tile.dragging {
  opacity: .55; cursor: grabbing;
  border-color: var(--accent); box-shadow: var(--shadow);
  transform: none;
}
.tile.dragging::before { opacity: 1; }
.grid:has(.dragging) .tile { transition: none; }

/* ---- status pills ----------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px;
  padding: 3px 9px; border-radius: var(--radius-pill); font-weight: 600;
  letter-spacing: .2px; white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.reconnect { background: var(--bad-soft); color: var(--bad); }
.pill.no_cost_access { background: var(--warn-soft); color: var(--warn); }
.pill.over { background: var(--bad-soft); color: var(--bad); }
.pill.approaching { background: var(--warn-soft); color: var(--warn); }

/* budget status on tiles + detail: red = over the limit, amber = past pre-cost */
.tile.over::before { background: var(--bad); opacity: 1; }
.tile.approaching::before { background: var(--warn); opacity: 1; }
.tile.over { border-color: rgba(255, 95, 86, .35); }
.tile.approaching { border-color: rgba(224, 167, 52, .35); }
.cost.over, .big.over { color: var(--bad); }
.cost.approaching, .big.approaching { color: var(--warn); }
.budget-line { font-size: 12px; margin: 2px 0 0; font-weight: 500; }
.budget-line.over { color: var(--bad); }
.budget-line.approaching { color: var(--warn); }

/* ---- tables ----------------------------------------------------------- */
.card > table, .card table { width: 100%; }
table { width: 100%; border-collapse: collapse; overflow: hidden; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); font-size: 14px; }
thead th {
  color: var(--muted); font-weight: 600; font-size: 11.5px; letter-spacing: .5px;
  text-transform: uppercase; background: rgba(255, 255, 255, .015);
}
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- detail summary cards -------------------------------------------- */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin: 18px 0; }
.summary-cards .card { padding: 18px 20px; }
.summary-cards .muted { font-size: 12px; letter-spacing: .4px; text-transform: uppercase; font-weight: 600; }
.summary-cards .big { font-size: 28px; font-weight: 750; margin-top: 8px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }

/* ---- rows / pickers --------------------------------------------------- */
.row-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; align-items: center; }
.list-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 10px; transition: border-color var(--ease), background var(--ease);
}
.list-item:not(.disabled):hover { border-color: #36465a; background: var(--surface-2); }
.list-item.disabled { opacity: .5; }
.list-item input[type=checkbox] { width: 17px; }
.list-item .li-main { flex: 1; }
.li-name { font-weight: 600; }
.li-sub { color: var(--muted); font-size: 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---- misc ------------------------------------------------------------- */
.muted { color: var(--muted); }

.spinner { color: var(--muted); padding: 56px 0; text-align: center; font-size: 14px; }
.spinner::before {
  content: ''; display: block; width: 30px; height: 30px; margin: 0 auto 14px;
  border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

hr { border: 0; border-top: 1px solid var(--border); margin: 26px 0; }
.divider-or {
  text-align: center; color: var(--muted); font-size: 12px; margin: 22px 0;
  display: flex; align-items: center; gap: 14px;
}
.divider-or::before, .divider-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* empty state (dashboard / picker) */
.empty-state { text-align: center; padding: 40px 24px; }
.empty-state .empty-ico {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px; font-size: 28px;
  display: grid; place-items: center; background: var(--accent-soft); border: 1px solid var(--border);
}
.empty-state p { color: var(--muted); margin: 0 0 18px; }

/* ---- recipient chips (cost-alert email list) ------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 26px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 4px 7px 4px 13px; font-size: 13px; font-weight: 500;
}
.chip-x {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 4px; width: auto; box-shadow: none;
  transition: color var(--ease);
}
.chip-x:hover { color: var(--bad); background: none; transform: none; filter: none; }

/* fade content in on render */
#app { animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- responsive ------------------------------------------------------- */
@media (max-width: 640px) {
  main { padding: 22px 16px 48px; }
  #topbar { padding: 10px 14px; }
  #topbar .brand span.brand-text { display: none; }
  h1 { font-size: 22px; }
  .summary-cards { grid-template-columns: 1fr; }
}
