:root {
  color-scheme: light;
  --ink: #172221;
  --muted: #687573;
  --line: #dce3e1;
  --paper: #ffffff;
  --wash: #f3f7f5;
  --green: #007f6d;
  --green-dark: #005c50;
  --blue: #164f73;
  --sky: #dff2f2;
  --amber: #a46612;
  --red: #a33a3a;
  --shadow: 0 18px 45px rgba(23, 34, 33, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #edf6f5 0, var(--wash) 18rem);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 8px;
  padding: 0.72rem 1rem;
  background: var(--green);
  color: white;
  font-weight: 650;
  cursor: pointer;
}
button:hover { background: var(--green-dark); }
button:disabled { opacity: 0.55; cursor: wait; }
.secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
.secondary:hover { background: var(--wash); }
.danger { background: var(--red); }
.danger:hover { background: #812d2d; }
.small { padding: 0.45rem 0.7rem; font-size: 0.88rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 18% 15%, rgba(23, 107, 83, 0.12), transparent 30rem),
    var(--wash);
}
.login-card {
  width: min(420px, 100%);
  padding: 2.5rem;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.windcare-logo { display: block; width: min(250px, 100%); height: auto; margin-bottom: 1.35rem; object-fit: contain; }
.windcare-logo.compact { width: 170px; margin: 0; }
.header-brand { display: flex; align-items: center; gap: 1rem; }
label {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
  color: #394642;
  font-size: 0.88rem;
  font-weight: 650;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd6d2;
  border-radius: 7px;
  padding: 0.72rem 0.8rem;
  background: white;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(23, 107, 83, 0.16);
  border-color: var(--green);
}
.login-card form button { width: 100%; margin-top: 0.25rem; }
.error { min-height: 1.2em; margin: 0.75rem 0 0; color: var(--red); font-size: 0.88rem; }
.app-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding-bottom: 4rem; }
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.7rem 0 1.2rem;
}
header::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: linear-gradient(90deg, var(--green), var(--blue)); }
header { position: relative; }
header h1 { margin: 0; font-size: 1.65rem; }
.user-area { display: flex; align-items: center; gap: 0.8rem; }
.profile-button {
  display: grid;
  gap: 0.05rem;
  padding: 0.35rem 0.55rem;
  background: transparent;
  color: var(--ink);
  text-align: right;
}
.profile-button:hover { background: white; }
.profile-button small { color: var(--green); font-weight: 650; }
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
}
.filters { display: flex; gap: 0.35rem; }
.upload-buttons { display: flex; gap: 0.55rem; }
.search-sort-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px 160px;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}
.search-sort-bar label { margin: 0; }
.filter { background: transparent; color: var(--muted); }
.filter:hover, .filter.active { background: white; color: var(--ink); box-shadow: 0 2px 9px rgba(23, 34, 33, 0.08); }
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin: 1.2rem 0;
}
.metric { padding: 1rem 1.1rem; border-radius: 12px; background: white; border: 1px solid var(--line); box-shadow: 0 5px 16px rgba(22, 79, 115, 0.05); }
.metric strong { display: block; margin-top: 0.25rem; font-size: 1.45rem; }
.invoice-list { display: grid; gap: 0.65rem; }
.invoice-card {
  display: grid;
  grid-template-columns: minmax(170px, 1.5fr) repeat(5, minmax(105px, 1fr)) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.invoice-card:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(23, 34, 33, 0.08); }
.invoice-card p { margin: 0.22rem 0 0; }
.cell-label { display: block; margin-bottom: 0.18rem; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.status { display: inline-block; border-radius: 999px; padding: 0.34rem 0.62rem; font-size: 0.78rem; font-weight: 750; }
.status-Pending { background: #fff3dc; color: #805313; }
.status-Approved { background: #daf2e7; color: #126047; }
.status-Rejected { background: #f7dddd; color: #8e2d2d; }
.status-Query { background: #e5e8f7; color: #414b8d; }
.status-In-Query { background: #e5e8f7; color: #414b8d; }
.filter-panel, .report-panel { margin: 1rem 0; padding: 1.1rem; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 5px 16px rgba(22, 79, 115, 0.05); }
.filter-panel-heading, .report-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.filter-panel h2, .report-panel h2 { margin-bottom: 0.8rem; font-size: 1.15rem; }
.filter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 0.8rem; }
.filter-grid label { margin-bottom: 0.65rem; }
.report-table { border-top: 1px solid var(--line); }
.report-row { display: grid; grid-template-columns: minmax(180px, 1fr) 100px 150px; gap: 1rem; padding: 0.75rem 0.25rem; border-bottom: 1px solid var(--line); align-items: center; }
.report-row > :last-child { text-align: right; }
.report-header { color: var(--muted); font-size: 0.72rem; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
.report-empty { margin: 0; padding: 0.6rem 0; }
.empty { padding: 5rem 1rem; text-align: center; }
dialog {
  width: min(720px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(13, 29, 25, 0.55); backdrop-filter: blur(2px); }
dialog form, #detailContent { padding: 1.5rem; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; }
.icon-button { padding: 0.2rem 0.55rem; background: transparent; color: var(--muted); font-size: 1.7rem; }
.icon-button:hover { background: var(--wash); color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.full { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.8rem; margin: 1.2rem 0; }
.detail-box { padding: 0.8rem; border-radius: 8px; background: var(--wash); }
.detail-box strong { display: block; margin-top: 0.2rem; }
.action-panel { margin: 1.3rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; }
.admin-actions { display: flex; gap: 0.55rem; margin: 1.2rem 0; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.password-panel { margin-top: 0.5rem; padding: 1rem; border-radius: 10px; background: var(--wash); }
.password-panel h3 { margin-bottom: 0.3rem; }
.user-management { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: #f7fbfa; }
.management-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; }
.management-heading h3, .management-heading p { margin-bottom: 0.2rem; }
.managed-user { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 0.45rem; padding: 0.7rem; background: white; color: var(--ink); border: 1px solid var(--line); text-align: left; }
.managed-user:hover { background: var(--wash); }
.managed-user span:first-child { display: grid; gap: 0.15rem; }
.managed-user small { color: var(--muted); }
.managed-user.inactive { opacity: 0.62; }
.department-checks { margin: 0 0 1rem; padding: 0.8rem; border: 1px solid var(--line); border-radius: 8px; }
.department-checks legend { padding: 0 0.3rem; color: #394642; font-size: 0.88rem; font-weight: 650; }
.department-checks .check-label { margin-bottom: 0.45rem; }
.check-label { display: flex; grid-column: auto; align-items: center; gap: 0.55rem; }
.check-label input { width: auto; }
.profile-message { min-height: 1.2em; margin: 0.75rem 0 0; color: var(--green); font-size: 0.88rem; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.reason-area { margin-top: 0.8rem; }
.decision-section { margin-top: 0.8rem; padding: 0.9rem; border: 1px solid var(--line); border-radius: 9px; background: var(--wash); }
.decision-section h4 { margin: 0 0 0.7rem; }
.project-editor { margin: 1rem 0; padding: 1rem; border: 1px solid #b8dddd; border-radius: 10px; background: var(--sky); }
.project-editor h3 { margin-bottom: 0.2rem; }
.project-allocation-row { display: grid; grid-template-columns: minmax(160px, 1fr) 150px auto; gap: 0.55rem; margin-bottom: 0.55rem; }
.project-required { padding: 0.8rem; border-radius: 8px; background: #fff3dc; color: #805313; }
.linked-credits { margin: 1rem 0; padding: 1rem; border-radius: 10px; background: var(--sky); border: 1px solid #b8dddd; }
.linked-credits h3 { margin-bottom: 0.6rem; }
.linked-credits p { margin: 0.3rem 0; }
.credit-allocation-panel { margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--wash); }
.allocation-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; }
.allocation-heading p { margin: 0.2rem 0 0; }
.allocation-row { display: grid; grid-template-columns: minmax(150px, 1fr) 150px auto; gap: 0.55rem; margin-bottom: 0.55rem; }
.allocation-row input { margin: 0; }
.allocation-balance { margin: 0.7rem 0 0; color: var(--green); font-weight: 700; }
.allocation-balance.over-allocated { color: var(--red); }
.timeline { margin: 1rem 0 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 1rem 1.2rem; border-left: 2px solid var(--line); }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.timeline li:last-child { border-left-color: transparent; }
.timeline p { margin: 0.2rem 0; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 1rem, 1180px); }
  .toolbar, header { align-items: flex-start; }
  .toolbar { flex-direction: column-reverse; }
  .invoice-card { grid-template-columns: 1fr 1fr; }
  .invoice-card > :first-child { grid-column: 1 / -1; }
  .summary { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .search-sort-bar { grid-template-columns: 1fr; }
  .filter-panel-heading, .report-heading { align-items: flex-start; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .allocation-row, .project-allocation-row { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .user-area { flex-direction: column; align-items: flex-end; }
}

@media (max-width: 1100px) {
  .invoice-card { grid-template-columns: repeat(3, 1fr); }
  .invoice-card > :first-child { grid-column: 1 / -1; }
}
