:root {
  /* --brand-primary/--brand-secondary are set per-request in base.html/login.html
     from portal_branding, falling back to Hive's own colors when unset. */
  --neutral-black: #111111;
  --neutral-slate: #475569;
  --neutral-slate-light: #e2e8f0;
  --neutral-slate-lighter: #f1f5f9;
  --neutral-white: #ffffff;
  --neutral-red: #c0392b;
  --neutral-green: #1e8e3e;

  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--neutral-black);
  background: var(--neutral-slate-lighter);
}

a {
  color: var(--brand-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---- header ---- */

.site-header {
  background: var(--neutral-black);
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 1.5rem;
  height: 60px;
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.site-header .brand img {
  height: 32px;
  display: block;
}
.brand-name {
  color: var(--neutral-white);
  font-weight: 700;
  font-size: 1.1rem;
}

.site-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}
.site-nav a {
  color: var(--neutral-slate-light);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  font-weight: 500;
}
.site-nav a:hover {
  color: var(--neutral-white);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
}
.site-nav a.active {
  color: var(--neutral-white);
  background: var(--brand-primary);
}

.site-header .user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--neutral-slate-light);
  font-size: 0.9rem;
}
.site-header form {
  margin: 0;
}
.site-header .btn {
  background: transparent;
  border: 1px solid var(--neutral-slate);
  color: var(--neutral-slate-light);
}
.site-header .btn:hover {
  border-color: var(--brand-primary);
  color: var(--neutral-white);
}

@media (max-width: 480px) {
  .site-header {
    padding: 0 0.75rem;
    gap: 0.75rem;
  }
  .site-header .brand img {
    height: 22px;
  }
  .brand-name {
    font-size: 0.9rem;
  }
  .site-nav {
    gap: 0.1rem;
  }
  .site-nav a {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
  }
  .site-header .user-menu {
    gap: 0.4rem;
    font-size: 0.75rem;
  }
  .site-header .btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }
}

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

main.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash.error {
  background: #fdecea;
  color: var(--neutral-red);
  border: 1px solid #f5c6c0;
}
.flash.success {
  background: #e6f4ea;
  color: var(--neutral-green);
  border: 1px solid #b7e1c1;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--neutral-slate-light);
  color: var(--neutral-black);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover {
  filter: brightness(0.96);
}
.btn-primary {
  background: var(--brand-primary);
  color: var(--neutral-white);
}
.btn-primary:hover {
  filter: brightness(0.9);
}
.btn-danger {
  background: var(--neutral-white);
  color: var(--neutral-red);
  border-color: var(--neutral-red);
}
.btn-danger:hover {
  background: #fdecea;
}
.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

/* A row of buttons/forms that may wrap onto multiple lines on a narrow screen -
   plain inline flow has no row-gap, so wrapped buttons sit flush against the
   ones above them; a flex-wrap container with `gap` gives spacing both between
   and within rows. */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

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

.card {
  background: var(--neutral-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--neutral-slate-light);
  font-size: 0.9rem;
}
th {
  color: var(--neutral-slate);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  background: var(--neutral-slate-lighter);
}
tbody tr:hover {
  background: var(--neutral-slate-lighter);
}
td.actions {
  white-space: nowrap;
  text-align: right;
}

/* ---- invoice list (stacked, actions below info - not squeezed into a
   table cell alongside it, which wrapped badly for 2-3 buttons at once) ---- */

.invoice-list {
  display: flex;
  flex-direction: column;
}
.invoice-row {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--neutral-slate-light);
}
.invoice-row:last-child {
  border-bottom: none;
}
.invoice-row:hover {
  background: var(--neutral-slate-lighter);
}
.invoice-info-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.invoice-number {
  font-weight: 600;
}
.invoice-total {
  margin-left: auto;
  font-size: 1.05rem;
  font-weight: 700;
}
.invoice-info-details {
  margin-top: 0.3rem;
  font-size: 0.85rem;
}
.invoice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

/* ---- service list (mirrors .invoice-list - stacked, whole row clickable,
   status/online wrap onto their own line once the row runs out of width,
   e.g. on a phone) ---- */

.service-list {
  display: flex;
  flex-direction: column;
}
.service-row {
  display: block;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--neutral-slate-light);
  color: inherit;
  text-decoration: none;
}
.service-row:last-child {
  border-bottom: none;
}
.service-row:hover {
  background: var(--neutral-slate-lighter);
  text-decoration: none;
}
.service-info-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}
.service-name {
  font-weight: 600;
}
.service-status-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.service-info-details {
  margin-top: 0.3rem;
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-active {
  background: #e6f4ea;
  color: var(--neutral-green);
}
.badge-inactive {
  background: #f1f1f1;
  color: var(--neutral-slate);
}
.badge-pending {
  background: #fff3cd;
  color: #8a6100;
}
.badge-overdue {
  background: #fdecea;
  color: var(--neutral-red);
}

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

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--neutral-slate);
}
input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--neutral-slate-light);
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

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

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-black);
}
.login-card {
  background: var(--neutral-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: min(360px, 90vw);
}
.login-card .brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.login-card .brand img {
  height: 40px;
}
.login-card .brand-name {
  color: var(--neutral-black);
  font-size: 1.4rem;
}
.login-card .btn-primary {
  width: 100%;
  justify-content: center;
}

.muted {
  color: var(--neutral-slate);
  font-size: 0.85rem;
}

dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  width: min(420px, 92vw);
}
dialog::backdrop {
  background: rgba(17, 17, 17, 0.55);
}
dialog .dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--neutral-slate-light);
}
dialog .dialog-header h2 {
  margin: 0;
  font-size: 1.1rem;
}
dialog .dialog-body {
  padding: 1.25rem;
}
dialog .dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--neutral-slate-light);
}
.dialog-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--neutral-slate);
}
