:root {
  --teal: #1b7580;
  --teal-dark: #135761;
  --slab: #2b2f33;
  --sand: #e9e7e2;
  --paper: #f7f7f5;
  --ink: #1d2125;
  --muted: #646b72;
  --line: #d4d2cc;
  --danger: #b3261e;
  --danger-bg: #fbe9e7;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "IBM Plex Sans", Tahoma, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
}

/* ================= Login page ================= */
.stage {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 470px);
}

/* Image */
.hero { position: relative; overflow: hidden; background: #d9dcdc; min-height: 100vh; }
.hero img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 0;
  transform-origin: 50% 28%;
  animation:
    focus-in 1.6s cubic-bezier(.2,.7,.2,1) both,
    drift 30s 1.6s ease-in-out infinite alternate;
}
@keyframes focus-in {
  from { filter: blur(12px) brightness(.8); transform: scale(1.14); }
  to   { filter: none; transform: scale(1); }
}
@keyframes drift {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}

/* Form */
.panel { display: grid; place-items: center; padding: 32px 28px; background: var(--paper); }
.card {
  width: 100%; max-width: 380px;
  animation: rise .8s .9s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}
.card h1 { margin: 0 0 6px; font-size: 1.9rem; font-weight: 700; }
.sub { margin: 0 0 26px; color: var(--muted); font-size: .98rem; }

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; margin-bottom: 6px; font-weight: 500; font-size: .95rem; }
.field input {
  width: 100%; height: 48px; padding: 0 14px;
  font: inherit; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 6px;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: #a3a8ad; }
.field input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(27,117,128,.2); }

.pw { position: relative; }
.pw input { padding-inline-end: 76px; }
.pw button {
  position: absolute; inset-block: 6px; inset-inline-end: 6px;
  padding: 0 12px; font: inherit; font-size: .88rem; color: var(--teal-dark);
  background: transparent; border: 0; border-radius: 4px; cursor: pointer;
}
.pw button:hover { background: var(--sand); }
.pw button:focus-visible { outline: 2px solid var(--teal); }

.submit {
  width: 100%; height: 50px; margin-top: 6px;
  font: inherit; font-weight: 600; font-size: 1.02rem; color: #fff;
  background: var(--teal); border: 0; border-radius: 6px; cursor: pointer;
  transition: background .15s;
}
.submit:hover { background: var(--teal-dark); }
.submit:focus-visible { outline: 3px solid rgba(27,117,128,.4); outline-offset: 2px; }

.alert {
  margin-bottom: 18px; padding: 12px 14px; font-size: .94rem;
  color: var(--danger); background: var(--danger-bg);
  border-inline-start: 4px solid var(--danger);
}
.help { margin: 20px 0 0; text-align: center; font-size: .9rem; color: var(--muted); }

/* Mobile and narrow screens: image banner on top, form below */
@media (max-width: 1000px) {
  .stage { grid-template-columns: 1fr; min-height: 0; }
  .hero { min-height: 0; aspect-ratio: 1376 / 768; }
  .panel { align-items: start; padding: 28px 22px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero img, .card { animation: none; }
}

/* ================= Dashboard pages ================= */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 28px; background: var(--slab); color: #fff; }
.topbar nav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.topbar a { color: #b9dde1; text-decoration: none; }
.topbar a:hover, .topbar a[aria-current="page"] { color: #fff; }
.topbar a[aria-current="page"] { border-bottom: 2px solid #8fd0d8; padding-bottom: 2px; }
.topbar .who { color: #aab1b8; }
.page { max-width: 880px; margin: 40px auto; padding: 0 24px; }
.page.wide { max-width: 1080px; }
.page h1 { margin: 0 0 8px; }
.page h2 { margin: 0 0 14px; font-size: 1.1rem; }

.tag { display: inline-block; padding: 2px 10px; font-size: .82rem; color: #fff; background: var(--teal); border-radius: 99px; white-space: nowrap; }
.tag.soft { background: #e1e4e6; color: #3b4147; }
.tag.ok   { background: #dcefe3; color: #1d6b3a; }
.tag.wait { background: #fdeccb; color: #8a5a00; }
.tag.off  { background: #ececec; color: #666; }

.stats { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 28px; }
.stat { display: block; min-width: 190px; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; }
.stat b { display: block; font-size: 2rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .92rem; }
.stat.attention { border-color: #e2b24a; background: #fff9ec; }
.stat:hover { border-color: var(--teal); }

.notice { margin: 16px 0; padding: 12px 14px; font-size: .94rem; color: var(--teal-dark); background: #e3f1f2; border-inline-start: 4px solid var(--teal); }
.page .alert { margin: 16px 0; }
.link { color: var(--teal-dark); font-weight: 500; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.addbox { margin: 20px 0 28px; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.addgrid { display: grid; grid-template-columns: 1.2fr 1.4fr 1fr 0.8fr auto; gap: 14px; align-items: end; }
.addgrid .field { margin: 0; }
.addgrid select { width: 100%; height: 48px; padding: 0 10px; font: inherit; background: #fff; border: 1.5px solid var(--line); border-radius: 6px; }
.addgrid .btn { height: 48px; }

.btn { padding: 7px 14px; font: inherit; font-size: .9rem; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--teal); color: var(--teal-dark); }
.btn.primary { color: #fff; background: var(--teal); border-color: var(--teal); }
.btn.primary:hover { background: var(--teal-dark); color: #fff; }

.tablewrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { padding: 12px 14px; text-align: start; border-bottom: 1px solid #ecebe7; vertical-align: middle; }
th { font-weight: 600; font-size: .85rem; color: var(--muted); background: #fafaf8; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); font-size: .9rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }

@media (max-width: 900px) {
  .addgrid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 12px 18px; }
}
@media (max-width: 560px) {
  .addgrid { grid-template-columns: 1fr; }
}

/* Setup page */
body:not(.login-page) > main.panel { min-height: 100vh; }
