/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --color-bg:       #f9fafb;
  --color-surface:  #ffffff;
  --color-border:   #e5e7eb;
  --color-text:     #111827;
  --color-muted:    #6b7280;
  --color-primary:  #2563eb;
  --color-primary-h:#1d4ed8;
  --color-success:  #059669;
  --color-danger:   #dc2626;
  --color-danger-h: #b91c1c;
  --color-warn-bg:  #fffbeb;
  --color-warn-bdr: #fbbf24;
  --radius:         6px;
  --shadow:         0 1px 3px rgba(0,0,0,.08);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif;
       font-size: 14px; background: var(--color-bg); color: var(--color-text); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, monospace; font-size: .9em;
       background: #f3f4f6; padding: 1px 5px; border-radius: 3px; }

/* ── Top nav ───────────────────────────────────────────────────── */
.topnav {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .75rem 2rem;
  background: var(--color-text); color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.logo { font-weight: 700; font-size: 1.1rem; letter-spacing: -.5px; }
.nav-links { display: flex; gap: 1rem; }
.nav-links a { color: #d1d5db; font-weight: 500; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: .75rem;
            color: #9ca3af; font-size: .85rem; }

/* ── Layout ────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }
.page-header { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 1.5rem; }
.page-header h2 { margin: 0; font-size: 1.4rem; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .9rem; border-radius: var(--radius);
  font-size: .85rem; font-weight: 500; cursor: pointer;
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); transition: background .15s;
  text-decoration: none;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-h); border-color: var(--color-primary-h); }
.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-h); }
.btn-secondary { background: #f3f4f6; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-link {
  background: none; border: none; color: #9ca3af; cursor: pointer;
  font-size: .85rem; padding: 0; text-decoration: underline;
}
.btn-link:hover { color: #fff; }

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius);
  margin-bottom: 1.25rem; font-size: .9rem;
}
.alert-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-key     { background: var(--color-warn-bg); border: 1px solid var(--color-warn-bdr); }
.key-display   { margin: .5rem 0; background: #fff; border: 1px solid var(--color-border);
                 border-radius: var(--radius); padding: .6rem .9rem; word-break: break-all; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 1rem; font-size: 1rem; }

/* ── Tables ────────────────────────────────────────────────────── */
.table {
  width: 100%; border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td { padding: .65rem 1rem; text-align: left; }
.table th { background: #f9fafb; font-weight: 600; font-size: .8rem;
            text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted);
            border-bottom: 1px solid var(--color-border); }
.table td { border-bottom: 1px solid #f3f4f6; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f9fafb; }
.table-sm th, .table-sm td { padding: .4rem .75rem; font-size: .85rem; }
.table-mono td { font-family: ui-monospace, monospace; font-size: .8rem; }

.actions { display: flex; gap: .4rem; white-space: nowrap; }
.truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis;
            white-space: nowrap; display: inline-block; vertical-align: bottom; }
.fw-medium { font-weight: 500; }
.text-muted { color: var(--color-muted); }

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.badge-s3      { background: #dbeafe; color: #1e40af; }
.badge-objecta { background: #d1fae5; color: #065f46; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-row { display: flex; gap: 1.25rem; margin-bottom: 1.25rem; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: .4rem; font-size: .875rem; }
.form-group input, .form-group select {
  width: 100%; padding: .5rem .75rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font-size: .875rem; background: var(--color-surface);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; padding-top: 1.5rem;
                border-top: 1px solid var(--color-border); }
.required { color: var(--color-danger); }
.inline-form { display: flex; gap: .75rem; align-items: center; }
.inline-form input { flex: 1; padding: .5rem .75rem; border: 1px solid var(--color-border);
                     border-radius: var(--radius); font-size: .875rem; }

/* ── Login page ────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: var(--color-bg); }
.login-card { background: var(--color-surface); border: 1px solid var(--color-border);
              border-radius: var(--radius); padding: 2.5rem; width: 360px;
              box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.login-card h1 { margin: 0 0 1.5rem; font-size: 1.4rem; text-align: center; }
.login-card label { display: block; font-weight: 500; margin-bottom: .4rem; font-size: .875rem; margin-top: 1rem; }
.login-card input { width: 100%; padding: .55rem .75rem; margin-bottom: .25rem;
                    border: 1px solid var(--color-border); border-radius: var(--radius);
                    font-size: .875rem; }
.login-card input:focus { outline: none; border-color: var(--color-primary);
                          box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.login-card .btn-primary { margin-top: 1.5rem; }

/* ── Metrics panel ─────────────────────────────────────────────── */
.metrics-panel { padding: .5rem 0 .75rem; }
.metrics-meta  { font-size: .8rem; margin-bottom: 1rem; color: var(--color-muted); }
.metrics-meta strong { color: var(--color-text); }
.metrics-section { margin-bottom: 1.25rem; }
.metrics-section h5 { margin: 0 0 .6rem; font-size: .8rem; text-transform: uppercase;
                      letter-spacing: .06em; color: var(--color-muted); }

/* Disk stats */
.disk-stat        { margin-bottom: .85rem; }
.disk-label       { display: flex; justify-content: space-between; align-items: baseline;
                    margin-bottom: .3rem; font-size: .875rem; }
.disk-pct         { font-variant-numeric: tabular-nums; font-weight: 600; font-size: .85rem; }
.pct-ok           { color: var(--color-success); }
.pct-warn         { color: #d97706; }
.pct-critical     { color: var(--color-danger); }
.capacity-bar-wrap { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden;
                    margin-bottom: .3rem; }
.capacity-bar     { height: 100%; border-radius: 999px; transition: width .4s ease; }
.bar-ok           { background: var(--color-success); }
.bar-warn         { background: #f59e0b; }
.bar-critical     { background: var(--color-danger); }
.disk-numbers     { font-size: .8rem; }

/* Stat cards (counts) */
.stat-grid  { display: flex; flex-wrap: wrap; gap: .75rem; }
.stat-card  { background: #f9fafb; border: 1px solid var(--color-border);
              border-radius: var(--radius); padding: .6rem 1rem; min-width: 110px; }
.stat-value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums;
              line-height: 1.2; }
.stat-label { font-size: .75rem; margin-top: .2rem; }

/* Raw metrics table (collapsed) */
.metrics-raw summary { cursor: pointer; font-size: .85rem; font-weight: 500;
                       padding: .5rem 0; color: var(--color-muted); user-select: none; }
.metrics-raw summary:hover { color: var(--color-text); }
.metrics-raw[open] summary { margin-bottom: .5rem; }

/* ── HTMX loading indicator ────────────────────────────────────── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* ── API docs ──────────────────────────────────────────────────── */
.docs-layout   { display: flex; gap: 2rem; align-items: flex-start; }
.docs-main     { flex: 1; min-width: 0; }
.docs-sidebar  { width: 340px; flex-shrink: 0; position: sticky; top: 1.5rem; }

.docs-section  { margin-bottom: 2.5rem; }
.docs-section h3 { font-size: 1.1rem; margin: 0 0 .75rem;
                   padding-bottom: .5rem; border-bottom: 1px solid var(--color-border); }
.docs-section h4 { font-size: .875rem; font-weight: 600; margin: 1.25rem 0 .5rem;
                   color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; }
.docs-section p  { margin: 0 0 .75rem; line-height: 1.6; }

.endpoint-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.endpoint-path   { font-size: 1rem; }
.method          { display: inline-block; padding: .2rem .6rem; border-radius: var(--radius);
                   font-size: .75rem; font-weight: 700; text-transform: uppercase; }
.method.get      { background: #dbeafe; color: #1e40af; }
.method.post     { background: #d1fae5; color: #065f46; }

.code-block { background: #1e293b; color: #e2e8f0; font-family: ui-monospace, monospace;
              font-size: .82rem; padding: 1rem 1.25rem; border-radius: var(--radius);
              overflow-x: auto; white-space: pre; line-height: 1.6; margin: 0 0 .75rem; }

.docs-table  { margin-bottom: 0; }
.docs-table td:first-child { white-space: nowrap; }

/* Try-it panel */
.try-panel   { background: var(--color-surface); border: 1px solid var(--color-border);
               border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.try-panel h3 { margin: 0 0 1.25rem; font-size: 1rem; }
.try-panel .form-group { margin-bottom: 1rem; }
.try-panel label { font-size: .8rem; font-weight: 600; text-transform: uppercase;
                   letter-spacing: .05em; color: var(--color-muted); display: block;
                   margin-bottom: .35rem; }
.try-panel input { width: 100%; padding: .45rem .7rem; font-size: .875rem;
                   border: 1px solid var(--color-border); border-radius: var(--radius); }
.try-panel input:focus { outline: none; border-color: var(--color-primary);
                         box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.field-hint  { font-size: .78rem; color: var(--color-muted); margin: .35rem 0 0; }

.try-success { background: #1e293b; border-radius: var(--radius); overflow: hidden; }
.try-json    { color: #86efac; font-family: ui-monospace, monospace; font-size: .8rem;
               padding: 1rem; margin: 0; white-space: pre; line-height: 1.6; overflow-x: auto; }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--color-muted); font-size: .95rem;
}
