@import url("/assets/fonts.css");

:root {
  --background: #f4f4f5;
  --foreground: #1e293b;
  --card: #ffffff;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e5e7eb;
  --input: #e5e7eb;
  --ring: #e5e7eb;
  --primary: #111827;
  --primary-hover: #1f2937;
  --destructive: #dc2626;
  --radius: 0.5rem;
  --radius-xl: 0.75rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Ubuntu Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 400;
  line-height: 1rem;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }

.brand {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.25;
  color: #111827;
  letter-spacing: 0;
}
.page-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.25;
  color: #111827;
  margin: 0;
}
.caption { font-size: 11px; font-weight: 200; line-height: 1rem; color: #6b7280; }
.muted { color: var(--muted-foreground); font-size: 12px; line-height: 1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #111827;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s, color .15s, opacity .15s;
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn:focus-visible { outline: 3px solid rgb(229 231 235 / 0.9); outline-offset: 1px; }
.btn-primary {
  height: 32px;
  background: #111827;
  color: #fff;
}
.btn-primary:hover { background: #1f2937; color: #fff; }
.login-card .btn-primary { width: 100%; }
.btn-ghost { color: #4b5563; }
.btn-ghost:hover { background: #f3f4f6; color: #111827; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

.grid { display: grid; gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }

.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  color: inherit;
  min-height: 132px;
}
a.card:hover { background: #fafafa; }
.card h2, .card .card-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1rem;
  color: #111827;
}
.card p { margin: 0; color: #6b7280; font-size: 12px; line-height: 1rem; flex: 1; }
.card.is-soon { pointer-events: none; opacity: .55; }
.kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: none;
  color: #6b7280;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.login {
  width: 100%;
  max-width: 24rem;
}
.login-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.login-card h1 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1rem;
  color: #111827;
  text-align: center;
}
.login-card .lead {
  margin: 4px 0 0;
  text-align: center;
  font-size: 11px;
  font-weight: 200;
  line-height: 1rem;
  color: #6b7280;
}
.form-group { margin: 1rem 0 0; }
.form-group label, label {
  display: block;
  margin-bottom: 4px;
  color: #4b5563;
  font-size: 11px;
  font-weight: 200;
  line-height: 1rem;
}
input, textarea, select {
  width: 100%;
  height: 32px;
  padding: 4px 8px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  background: #fff;
  color: #374151;
  font-size: 12px;
  line-height: 1rem;
  box-shadow: none;
}
textarea { height: auto; min-height: 72px; padding: 8px; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #e5e7eb;
  box-shadow: 0 0 0 3px rgb(229 231 235 / 0.9);
}
.err {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid #fee2e2;
  background: #fef2f2;
  color: #dc2626;
  font-size: 12px;
  line-height: 1rem;
}

/* Pays */
header.appbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}
header.appbar .brand-block { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.empty {
  padding: 48px 24px;
  text-align: center;
  background: #fff;
  border: 1px dashed #e5e7eb;
  border-radius: var(--radius-xl);
  color: #6b7280;
  box-shadow: var(--shadow-sm);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.table-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  width: 100%;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  line-height: 1rem;
}
th, td { padding: 8px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th {
  height: 40px;
  background: #fff;
  font-weight: 500;
  color: #111827;
  white-space: nowrap;
}
tbody tr:hover { background: rgb(241 245 249 / 0.5); }
.col-date { white-space: nowrap; }
.col-svc, .col-total { text-align: right; font-variant-numeric: tabular-nums; }
.col-actions { text-align: center; }
td.actions { display: flex; justify-content: center; gap: 2px; align-items: center; }
.total { font-weight: 700; }
.filters { margin: 12px 0; display: flex; gap: 8px; align-items: center; }
.filters select { width: auto; }
.del { color: #dc2626; }
.th-account { font-size: 11px; font-weight: 400; color: #6b7280; }
.cell-amount { display: block; }
.cell-diff { display: block; font-size: 11px; font-weight: 400; margin-top: 2px; }
.diff-up { color: #dc2626; }
.diff-down { color: #16a34a; }
.obj-link { color: inherit; text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.obj-link:hover { color: #111827; text-decoration: underline; text-underline-offset: 2px; }
.obj-icon { display: inline-flex; color: #6b7280; }
.prop-title { display: flex; align-items: center; gap: 8px; font-size: 1.125rem; font-weight: 600; margin: 0; color: #111827; }
.icon-pick { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.icon-pick label {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 10px; border: 1px solid #e5e7eb; border-radius: var(--radius);
  font-size: 12px; font-weight: 400; color: #374151; margin: 0;
}
.icon-pick input { display: none; width: auto; height: auto; }
.icon-pick label:has(input:checked) { background: #111827; color: #fff; border-color: #111827; }
.icon-pick label:has(input:checked) .obj-icon { color: #fff; }
.ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius);
  color: #6b7280; background: transparent; border: none; cursor: pointer; padding: 0;
  text-decoration: none; font: inherit;
}
.ico:hover { background: #f3f4f6; color: #111827; }
.ico.del:hover { color: #dc2626; }
.readings-dropdown.show { display: block !important; }
.readings-dropdown a:hover { background: #f3f4f6; }
.readings-select {
  appearance: none; -webkit-appearance: none;
  width: auto; min-width: 180px;
  padding: 4px 28px 4px 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 8px center;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.4); z-index: 100;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border: 1px solid #e5e7eb; border-radius: var(--radius-xl);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
  max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; padding: 20px;
}
.modal h2 { margin: 0 0 12px; font-size: 1.125rem; font-weight: 600; color: #111827; }
.modal .form-actions { margin-top: 20px; display: flex; gap: 8px; }
.modal .form-actions .btn-primary { width: auto; padding: 0 16px; }
.svc-rows { margin: 8px 0; }
.svc-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.svc-row input[name*="name"] { flex: 1; min-width: 120px; width: auto; }
.svc-row input[name*="account"] { width: 140px; }
.svc-row input[name*="meter_url"] { flex: 1; min-width: 180px; width: auto; }
.pay-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.pay-row { display: flex; align-items: center; gap: 8px; overflow: visible; }
.pay-row label { flex: 1; min-width: 0; margin: 0; color: #6b7280; font-size: 12px; font-weight: 400; }
.pay-row input { width: 130px; flex-shrink: 0; }
.pay-row input[type=number]::-webkit-inner-spin-button,
.pay-row input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pay-row input[type=number] { -moz-appearance: textfield; }
.pay-row-info {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 6px; color: #6b7280; cursor: help; margin-left: 4px;
}
.pay-row-info:hover { background: #f3f4f6; color: #111827; }
body.pays { padding: 0 24px 32px; }
@media (max-width: 500px) {
  .pay-fields { grid-template-columns: 1fr; }
  body.pays { padding: 0 16px 32px; }
}
