@import url('fonts.css');

:root {
  --side: #12301f;
  --g: #2f8f5b;
  --gd: #1f6b42;
  --am: #e0a526;
  --rd: #c8452f;
  --bg: #eef2ee;
  --card: #fff;
  --tx: #14231a;
  --mu: #5f7266;
  --bd: #d9e1da;
  --hl: #e3f0e7;
  --in: #f2f5f2;
  --amb: #fbf1d6;
  --rdb: #fbe6e1;
  color-scheme: light;
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1712;
    --card: #16231b;
    --tx: #edf3ee;
    --mu: #9bb0a2;
    --bd: #27382d;
    --hl: #1c3626;
    --in: #1d2c23;
    --amb: #3a2f12;
    --rdb: #3d1d17;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1712;
  --card: #16231b;
  --tx: #edf3ee;
  --mu: #9bb0a2;
  --bd: #27382d;
  --hl: #1c3626;
  --in: #1d2c23;
  --amb: #3a2f12;
  --rdb: #3d1d17;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--tx);
  font: 14px/1.45 "Plus Jakarta Sans", system-ui, sans-serif;
}

.hide {
  display: none !important;
}

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

:focus-visible {
  outline: 3px solid var(--am);
  outline-offset: 2px;
}

/* Auth Layout */
#login {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100vh;
}

.lf {
  background: var(--side);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.lf h1 {
  font-size: 38px;
  line-height: 1.15;
  margin: 28px 0 14px;
  font-weight: 800;
  max-width: 460px;
}

.lf p {
  color: #b9cfc0;
  max-width: 400px;
  margin: 0;
}

.rows {
  position: absolute;
  right: -40px;
  bottom: -30px;
  opacity: 0.9;
}

.lr {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.box {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 400px;
}

.box h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.box > p {
  margin: 0 0 8px;
  color: var(--mu);
}

label {
  display: block;
  color: var(--mu);
  font-weight: 600;
  font-size: 13px;
  margin: 12px 0 5px;
}

input, select, textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: var(--card);
  box-sizing: border-box;
}

.roles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.rl {
  border: 1px solid var(--bd);
  background: var(--card);
  border-radius: 10px;
  padding: 10px 6px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.rl small {
  display: block;
  font-weight: 500;
  color: var(--mu);
  font-size: 11px;
}

.rl.on {
  border-color: var(--g);
  background: var(--hl);
  box-shadow: inset 0 0 0 1px var(--g);
}

.btn {
  background: var(--g);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn:hover {
  background: var(--gd);
}

.btn.o {
  background: var(--card);
  color: var(--tx);
  border: 1px solid var(--bd);
  font-weight: 600;
}

.btn.o:hover {
  background: var(--hl);
  border-color: var(--g);
}

.btn.danger {
  background: var(--rd);
}

.btn.danger:hover {
  background: #a5321f;
}

.btn.w {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
}

/* App Main Layout */
#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

aside {
  background: var(--side);
  color: #fff;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 8px 26px;
}

.brand b {
  font-size: 15px;
  line-height: 1.2;
  display: block;
}

.brand small {
  color: #9fbaa8;
  font-size: 12px;
}

.nav {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 4px;
  font-weight: 600;
  color: #d3e4d8;
  text-decoration: none;
}

.nav svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.nav.on {
  background: var(--g);
  color: #fff;
}

.nav:hover:not(.on) {
  background: #1d4630;
}

.who {
  margin-top: auto;
  padding: 12px;
  background: #1a3d29;
  border-radius: 12px;
  font-size: 12px;
  color: #a9c3b2;
}

.who b {
  display: block;
  color: #fff;
  font-size: 14px;
}

.who a, .who button {
  background: none;
  border: 0;
  color: #a9c3b2;
  text-decoration: underline;
  padding: 0;
  cursor: pointer;
  margin-top: 4px;
}

main {
  padding: 30px 36px 60px;
  min-width: 0;
}

.top {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.top h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.top p {
  margin: 2px 0 0;
  color: var(--mu);
}

.ctx {
  margin-left: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.ctx select {
  width: auto;
  padding: 9px 12px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--hl);
  color: var(--gd);
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 12px;
}

.badge.am {
  background: var(--amb);
  color: #8a6200;
}

.badge.rd {
  background: var(--rdb);
  color: var(--rd);
}

.badge.off {
  background: var(--in);
  color: var(--mu);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge,
  :root:not([data-theme="light"]) .alert b {
    color: #9be0b8;
  }
  :root:not([data-theme="light"]) .badge.am {
    color: #f2c75c;
  }
  :root:not([data-theme="light"]) .badge.rd {
    color: #ff9a86;
  }
}

.alerts {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.alert {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--amb);
  border-left: 5px solid var(--am);
}

.alert.rd {
  background: var(--rdb);
  border-color: var(--rd);
}

.alert span {
  flex: 1;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.k {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  padding: 14px 16px;
}

.k small {
  color: var(--mu);
  font-weight: 600;
}

.k b {
  display: block;
  font-size: 26px;
  font-weight: 800;
  margin: 2px 0;
}

.k i {
  font-style: normal;
  font-size: 12px;
  color: var(--mu);
}

.k.hero {
  background: var(--side);
  color: #fff;
  border: 0;
}

.k.hero small, .k.hero i {
  color: #b3ccbb;
}

.up {
  color: var(--g) !important;
  font-weight: 700;
}

.dn {
  color: var(--rd) !important;
  font-weight: 700;
}

.grid2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
}

.grid2 .panel {
  margin: 0;
}

.ph {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ph b {
  font-size: 16px;
}

.ph span {
  color: var(--mu);
  font-size: 13px;
}

.ph em {
  margin-left: auto;
  color: var(--mu);
  font-style: normal;
  font-size: 12px;
}

.leg {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--mu);
  margin-bottom: 6px;
}

.leg i {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

svg.ch {
  width: 100%;
  height: auto;
  display: block;
}

.ch text {
  fill: var(--mu);
  font-size: 11px;
  font-family: inherit;
}

.floors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.fl {
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 12px;
  background: var(--in);
}

.fl b {
  font-size: 15px;
}

.fl div {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--mu);
  margin-top: 4px;
}

.fl div span:last-child {
  color: var(--tx);
  font-weight: 700;
}

.bar {
  display: grid;
  grid-template-columns: 90px 1fr 110px;
  gap: 12px;
  align-items: center;
  margin: 11px 0;
}

.bar div {
  height: 10px;
  background: var(--in);
  border-radius: 9px;
  overflow: hidden;
  position: relative;
}

.bar div i {
  display: block;
  height: 100%;
  background: var(--g);
  border-radius: 9px;
}

.bar div i.am {
  background: var(--am);
}

.bar div i.rd {
  background: var(--rd);
}

.bar span:last-child {
  text-align: right;
  font-weight: 600;
}

.tw {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th {
  color: var(--mu);
  font-weight: 600;
  text-align: right;
  padding: 9px 10px;
  border-bottom: 1px solid var(--bd);
  font-size: 12.5px;
}

td {
  text-align: right;
  padding: 10px;
  border-bottom: 1px solid var(--bd);
}

th:first-child, td:first-child {
  text-align: left;
}

tr.ed td {
  background: var(--hl);
}

tr.t td {
  font-weight: 700;
  background: var(--in);
}

td input {
  width: 84px;
  text-align: right;
  padding: 8px 9px;
  border-color: var(--g);
}

.pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 10px 18px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: var(--card);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.pill.on {
  background: var(--g);
  color: #fff;
  border-color: var(--g);
}

.f {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.f label {
  margin-top: 0;
}

.f .big {
  font-size: 20px;
  font-weight: 700;
  padding: 14px;
}

.calc {
  background: var(--hl);
  border-radius: 12px;
  padding: 12px 14px;
}

.calc small {
  color: var(--mu);
  display: block;
  font-weight: 600;
}

.calc b {
  font-size: 20px;
}

.note {
  background: var(--hl);
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  background: var(--side);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 999;
}

.bn {
  display: none;
}

/* Print styling */
@media print {
  aside, .bn, .ctx, .top button, .btn {
    display: none !important;
  }
  #app {
    display: block !important;
  }
  main {
    padding: 0 !important;
  }
  .panel {
    border: 1px solid #000 !important;
    page-break-inside: avoid;
  }
}

@media (max-width: 860px) {
  #login {
    grid-template-columns: 1fr;
  }
  .lf {
    padding: 28px 24px;
    min-height: 0;
  }
  .lf h1 {
    font-size: 28px;
  }
  .rows {
    display: none;
  }
  #app {
    grid-template-columns: 1fr;
  }
  aside {
    display: none;
  }
  main {
    padding: 20px 16px 110px;
  }
  .top h1 {
    font-size: 23px;
  }
  .ctx {
    margin-left: 0;
    width: 100%;
  }
  .ctx select {
    flex: 1;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .floors {
    grid-template-columns: 1fr;
  }
  .bn {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--side);
    padding: 6px 6px;
    z-index: 100;
    justify-content: space-around;
  }
  .bn .nav {
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    padding: 8px 6px;
    margin: 0;
    width: auto;
    flex: 1;
    align-items: center;
    text-align: center;
  }
  .bar {
    grid-template-columns: 70px 1fr 80px;
    gap: 8px;
  }
  td input {
    width: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
