:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --text: #17211c;
  --muted: #69756e;
  --line: #dfe5e1;
  --green: #16794a;
  --green-bg: #eaf7ef;
  --amber: #9a6500;
  --amber-bg: #fff6df;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
}

.auth-locked .shell > :not(.login-modal) {
  visibility: hidden;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: #fff;
  background: var(--green);
  font-size: 18px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 13px;
  letter-spacing: .08em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.top-actions,
.connection,
.button {
  display: flex;
  align-items: center;
}

.top-actions { gap: 8px; }

.connection {
  gap: 7px;
  margin-right: 6px;
  color: var(--muted);
  font-size: 12px;
}

.connection i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d89b28;
}

.connection-online i { background: #22a35f; }
.connection-error i { background: #d84949; }
.connection-loading i { animation: blink 1s infinite; }

.button {
  height: 34px;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}

.button:hover { border-color: #b7c2bc; background: #fafcfb; }
.button:disabled { cursor: wait; opacity: .55; }

.button-primary {
  width: 100%;
  border-color: var(--green);
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

.button-primary:hover { border-color: #12673f; background: #12673f; }

.page-heading {
  padding: 38px 0 22px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: 27px;
  letter-spacing: -.025em;
}

.page-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.stats article {
  min-height: 112px;
  padding: 20px;
  border-right: 1px solid var(--line);
}

.stats article:last-child { border: 0; }

.stats span,
.stats small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.stats strong {
  display: block;
  margin: 9px 0 5px;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
}

.stats .time-stat { font-size: 23px; }

.backups-section { padding: 38px 0; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

.legend {
  display: flex;
  gap: 15px;
  color: var(--muted);
  font-size: 11px;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
}

.dot-ok { background: #22a35f; }
.dot-warn { background: #d89b28; }

.backup-list { display: grid; gap: 8px; }

.backup-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.backup-card-warning { border-color: #ead39c; }

.backup-summary {
  min-height: 68px;
  display: grid;
  grid-template-columns: 36px 1fr auto 70px auto 30px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-bg);
  font-size: 13px;
  font-weight: 800;
}

.backup-card-warning .status-icon {
  color: var(--amber);
  background: var(--amber-bg);
}

.backup-date strong,
.backup-date span {
  display: block;
}

.backup-date strong {
  font-size: 13px;
  text-transform: capitalize;
}

.backup-date span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.backup-size {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.status-pill {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-bg);
  font-size: 10px;
  text-align: center;
}

.backup-card-warning .status-pill {
  color: var(--amber);
  background: var(--amber-bg);
}

.backup-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-button {
  height: 29px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
}

.action-button:hover { background: #f5f7f6; }
.action-button:disabled { cursor: wait; opacity: .6; }
.download-button { color: var(--green); }
.delete-button { color: #bb3939; border-color: #ebcece; }
.delete-button:hover { background: #fff3f3; }

.expand-button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  transition: transform .2s;
}

.expanded .expand-button { transform: rotate(180deg); }

.file-list {
  display: none;
  margin: 0;
  padding: 0 16px 12px 66px;
  list-style: none;
}

.expanded .file-list { display: block; }

.file-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.file-icon {
  color: var(--green);
  font-size: 9px;
  font-weight: 800;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size { font-variant-numeric: tabular-nums; }

.skeleton {
  height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(90deg, #fff, #f0f3f1, #fff);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.empty-state {
  padding: 55px 20px;
  border: 1px dashed #cbd4cf;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  text-align: center;
}

.empty-state > span { color: var(--green); font-size: 30px; }
.empty-state h3 { margin: 9px 0 6px; color: var(--text); font-size: 15px; }
.empty-state p { margin-bottom: 0; font-size: 12px; }

footer {
  padding: 20px 0 30px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.login-modal {
  width: min(400px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 20px 70px rgba(15, 31, 23, .18);
}

.login-modal::backdrop {
  background: var(--bg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.login-modal form { padding: 28px; }
.login-modal h2 { margin-bottom: 7px; font-size: 21px; }

.login-modal form > p:not(.form-error) {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 13px;
}

.login-modal label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
}

.login-modal input {
  width: 100%;
  height: 42px;
  margin-bottom: 7px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  color: var(--text);
  background: #fff;
}

.login-modal input:focus { border-color: var(--green); }

.form-error {
  min-height: 18px;
  margin: 0 0 7px;
  color: #c63f3f;
  font-size: 11px;
}

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes blink { 50% { opacity: .25; } }

@media (max-width: 760px) {
  .connection { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats article:nth-child(2) { border-right: 0; }
  .stats article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .backup-summary { grid-template-columns: 34px 1fr auto 28px; gap: 9px; }
  .backup-size, .status-pill { display: none; }
  .file-list { padding-left: 58px; }
}

@media (max-width: 460px) {
  .shell { width: min(100% - 20px, 1040px); }
  .top-actions .button { width: 34px; padding: 0; overflow: hidden; white-space: nowrap; color: transparent; }
  .top-actions .button span { color: var(--text); }
  .stats { grid-template-columns: 1fr; }
  .stats article { min-height: 96px; border-right: 0; border-bottom: 1px solid var(--line); }
  .stats article:last-child { border-bottom: 0; }
  .legend { display: none; }
  .backup-actions { gap: 4px; }
  .action-button { width: 30px; padding: 0; overflow: hidden; color: transparent; }
  .postgres-download::before { content: "DB"; color: var(--green); font-size: 9px; font-weight: 800; }
  .minio-download::before { content: "S3"; color: var(--green); font-size: 9px; font-weight: 800; }
  .delete-button::before { content: "×"; color: #bb3939; font-size: 16px; }
}
