:root {
  --navy: #0f2430;
  --navy-soft: #1b3545;
  --teal: #1a7f8e;
  --teal-dark: #136875;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --border: #dde3e6;
  --text: #16242c;
  --muted: #6b7f89;
  --ok: #1d7a4c;
  --ok-bg: #e6f4ec;
  --warn: #9a6400;
  --warn-bg: #fdf3e0;
  --error: #b02a2a;
  --error-bg: #fbeaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 36, 48, .06), 0 4px 16px rgba(15, 36, 48, .05);
}

* { box-sizing: border-box; }

/* Author `display` rules outrank the browser's `[hidden] { display: none }`. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- brand ------------------------------------------------------------- */

.brand { display: flex; flex-direction: column; line-height: 1.05; }
.brand-inline { flex-direction: row; align-items: baseline; gap: 7px; }
.brand-mark { font-weight: 800; letter-spacing: .13em; font-size: 17px; color: var(--navy); }
.brand-sub { font-weight: 500; letter-spacing: .22em; font-size: 11px; color: var(--teal); }

/* --- login ------------------------------------------------------------- */

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(160deg, var(--navy) 0%, #143040 100%);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

.auth-card .brand { align-items: flex-start; margin-bottom: 6px; }
.auth-intro { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

/* --- layout ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: grid;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-title { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.card-hint { margin: 0 0 18px; color: var(--muted); font-size: 13px; max-width: 70ch; }
.muted { color: var(--muted); font-size: 13px; }

/* --- forms ------------------------------------------------------------- */

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--navy-soft); }
.field > span small { font-weight: 400; color: var(--muted); }
.field-grow { flex: 1 1 260px; margin-bottom: 0; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: 2px solid rgba(26, 127, 142, .35);
  outline-offset: 1px;
  border-color: var(--teal);
}

.upload-form { margin: 0; }
.upload-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.upload-row .field { margin-bottom: 0; }
.upload-status { margin-top: 12px; font-size: 13px; }

/* --- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #eef1f3;
  color: var(--navy);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: #e3e8eb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: #f0f3f4; }
.btn-danger { background: var(--error-bg); color: var(--error); }
.btn-danger:hover { background: #f6dada; }
.btn-block { width: 100%; margin-top: 6px; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

/* --- alerts ------------------------------------------------------------ */

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--error-bg); color: var(--error); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* --- table ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.designs { width: 100%; border-collapse: collapse; font-size: 14px; }
.designs th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 650;
  padding: 0 12px 9px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.designs td { padding: 13px 12px; border-bottom: 1px solid #eef1f3; vertical-align: top; }
.designs tr:last-child td { border-bottom: none; }
.col-actions { width: 1%; }

.design-title { font-weight: 600; }
.design-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.design-error { color: var(--error); font-size: 12.5px; margin-top: 4px; max-width: 46ch; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .02em;
}
.badge-active { background: var(--ok-bg); color: var(--ok); }
.badge-closed { background: #eceff1; color: var(--muted); }
.badge-expired { background: var(--warn-bg); color: var(--warn); }
.badge-processing { background: #e7f0fb; color: #1f5fa8; }
.badge-failed { background: var(--error-bg); color: var(--error); }

.row-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; min-width: 360px; }
.row-actions-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions select { width: auto; padding: 6px 8px; font-size: 12.5px; }

.duration { display: inline-flex; gap: 4px; align-items: center; }
.duration .duration-amount { width: 64px; padding: 6px 8px; font-size: 12.5px; }

.empty { text-align: center; color: var(--muted); padding: 28px 0; margin: 0; }

/* --- diagnostics ------------------------------------------------------- */

.summary-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.pill { padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 650; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-error { background: var(--error-bg); color: var(--error); }
.pill-muted { background: #eceff1; color: var(--muted); }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.check { display: flex; gap: 12px; padding: 11px 12px; border-radius: 8px; align-items: flex-start; }
.check-ok { background: #fafcfb; }
.check-warn { background: var(--warn-bg); }
.check-error { background: var(--error-bg); }
.check-icon {
  flex: 0 0 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  margin-top: 1px;
}
.check-ok .check-icon { background: var(--ok); }
.check-warn .check-icon { background: var(--warn); }
.check-error .check-icon { background: var(--error); }
.check-name { font-weight: 620; font-size: 14px; }
.check-detail { color: var(--muted); font-size: 13px; margin-top: 2px; word-break: break-word; }

.runtime { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0 0 16px; font-size: 13.5px; }
.runtime dt { color: var(--muted); }
.runtime dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-all; }

code { background: #eef1f3; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 5px;
  background: #e7f0f2;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  vertical-align: middle;
  cursor: help;
}

.design-note {
  color: var(--warn);
  background: var(--warn-bg);
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: 6px;
  margin-top: 5px;
  max-width: 52ch;
}

.link-btn {
  background: none;
  border: none;
  padding: 2px 0 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--teal);
  cursor: pointer;
  text-decoration: underline;
}

/* --- modal ------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 36, 48, .5);
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; }

.activity { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 2px; }
.activity li { padding: 8px 10px; border-radius: 7px; background: #f7f9fa; }
.activity-time { font-size: 13.5px; font-weight: 600; }

/* --- toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .25);
  z-index: 50;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast-error { background: var(--error); }
.toast-warn { background: #8a5a00; }

@media (max-width: 680px) {
  .designs thead { display: none; }
  .designs tr { display: block; border-bottom: 1px solid var(--border); padding: 12px 0; }
  .designs td { display: block; border: none; padding: 3px 0; }
  .row-actions { align-items: flex-start; margin-top: 10px; min-width: 0; }
  .row-actions-line { justify-content: flex-start; }
  .upload-row { flex-direction: column; align-items: stretch; }
}
