/* =========================================================
   Material Design Inspired Pure CSS (Brand green #2d8f1e)
   ========================================================= */

/* Reset / base */
* { box-sizing: border-box; margin:0; padding:0; }
:root{
  --brand:#2d8f1e;
  --brand-dark:#1b5e20;
  --text:#212121;
  --muted:#666;
  --muted-2:#757575;
  --bg:#fafafa;
  --card:#ffffff;
  --border:#e0e0e0;
  --border-2:#cfd8dc;
  --shadow:0 1px 3px rgba(0,0,0,0.2);
  --ring: rgba(45,143,30,.15);
}
html, body { height:100%; }
body {
  font-family: 'Roboto', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
header {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
header .wrap {
  display:flex; justify-content:space-between; align-items:center;
  max-width:1900px; margin:0 auto; padding:12px 16px;
}
header .brand { font-weight:500; font-size:18px; letter-spacing:.5px; }
header nav a { color:#fff; margin:0 10px; font-weight:500; text-decoration:none; }
header nav a:hover { text-decoration:underline; }

/* Layout */
.wrap { max-width:1900px; margin:0 auto; padding:16px; }
main { padding: 16px 0; }

/* Card */
.card {
  background:var(--card);
  border-radius:6px;
  padding:20px;
  margin-bottom:20px;
  box-shadow:var(--shadow);
}

/* Typography */
h1 { font-size:20px; font-weight:500; margin-bottom:16px; color:var(--text); }
h2 { font-size:18px; font-weight:500; margin:12px 0; color:var(--text); }
.muted { color:var(--muted-2); font-size:12px; }

/* ------------ Buttons ------------ */
.btn {
  display:inline-block;
  padding:10px 16px;
  background:var(--brand);
  color:#fff;
  border:none;
  border-radius:6px;
  font-weight:500;
  cursor:pointer;
  transition: background .2s, box-shadow .2s, transform .06s;
  box-shadow:0 2px 2px rgba(0,0,0,0.15);
}
.btn:hover { background:var(--brand-dark); box-shadow:0 4px 6px rgba(0,0,0,0.2); }
.btn:active { transform: translateY(1px); }
.btn.outline {
  background:#fff; color:var(--brand);
  border:1px solid var(--brand);
  box-shadow:none;
}
.btn.outline:hover { background:#e8f5e9; }
.btn.ghost {
  background:transparent;
  border:1px dashed var(--border-2);
  color:#455a64;
}

/* ------------ Forms: layout ------------ */
form .grid { display:grid; grid-template-columns: repeat(2,1fr); gap:16px; }
@media (min-width: 1100px){ form .grid { grid-template-columns: repeat(4, 1fr); } }
label {
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
  display:block;
}

/* ------------ Form Controls (inputs/selects/textarea) ------------ */
/* Universal control look */
input[type="text"], input[type="date"], input[type="number"],
input[type="password"], input[type="email"],
select, textarea {
  width:100%;
  color:var(--text);
  background:#fff;
  border:1px solid #ccc;
  border-radius:6px;
  padding:10px 12px;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}

/* Focus ring */
input:focus, select:focus, textarea:focus {
  outline:none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--ring);
  background:#fff;
}

/* Placeholder */
::placeholder { color:#9e9e9e; }

/* Number spinners – nicer on WebKit */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"]{ -moz-appearance:textfield; }

/* Date inputs – keep readable in Safari/Chrome */
input[type="date"] {
  color-scheme: light;
}

/* Textarea */
textarea { min-height:110px; resize:vertical; }

/* Selects: custom arrow (pure CSS) */
select {
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--brand) 50%),
    linear-gradient(135deg, var(--brand) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 13px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px; /* arrow space */
}

/* Select hover */
select:hover { border-color: var(--brand); background-color:#f8fff8; }

/* Disabled */
input:disabled, select:disabled, textarea:disabled {
  background:#f2f2f2; color:#999; border-color:#ddd; cursor:not-allowed;
}

/* Multiple select */
select[multiple]{
  background-image:none;
  min-height:140px;
  padding-top:8px; padding-bottom:8px;
}

/* Compact select for table inline controls */
table select, .table-select {
  padding:6px 28px 6px 8px;
  border-radius:6px;
  min-width: 140px;
}

/* ------------ Toolbar / Filters grid (4 per row) ------------ */
.toolbar.grid-4 {
  display:grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: 12px 16px;
  align-items: end;
}
.toolbar.grid-4 > div { min-width:0; }
@media (max-width: 1024px) { .toolbar.grid-4 { grid-template-columns: repeat(2, minmax(200px, 1fr)); } }
@media (max-width: 600px)  { .toolbar.grid-4 { grid-template-columns: 1fr; } }

/* ------------ Section wrappers (nice grouping for forms) ------------ */
.form-section {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 14px;
  margin: 16px 0;
  background: #fff;
}
.section-title {
  font-size: 12px; font-weight:700; text-transform:uppercase;
  letter-spacing:.08em; color:var(--muted);
  display:inline-flex; align-items:center; gap:8px; margin:0 0 10px 0;
}
.section-title::before{
  content:""; width:6px; height:6px; border-radius:50%; background:var(--brand); display:inline-block;
}
.field { display:block; }
.field small.hint { color:var(--muted-2); font-size:12px; margin-top:6px; display:block; }

/* Sticky actions bar at bottom of long forms */
.form-actions {
  position: sticky; bottom: 0; z-index: 5;
  padding-top: 8px; margin-top: 12px;
  background: linear-gradient(180deg, rgba(250,250,250,0), rgba(250,250,250,1) 45%);
}
.form-actions .bar {
  background:#fff; border:1px solid var(--border); border-radius:6px;
  padding:10px; display:flex; gap:10px; justify-content:flex-end;
}

/* Tiny badges */
.badge {
  display:inline-block; font-size:12px; border:1px solid var(--border);
  border-radius:999px; padding:2px 10px; color:#424242; background:#fafafa;
}

/* Compact page header (title + actions) */
.page-head { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:10px; }

/* ------------ Tables ------------ */
table { width:100%; border-collapse:collapse; margin-top:16px; background:#fff; border-radius:6px; overflow:hidden; box-shadow:var(--shadow); }
th, td { padding:12px; text-align:left; }
th { background:#f5f5f5; font-weight:500; color:#424242; font-size:12px; text-transform:uppercase; letter-spacing:0.5px; }
tr:nth-child(even) { background:#fafafa; }
tr:hover { background:#f5f5f5; }

/* Make form elements inside table not break row height */
td .btn { padding:6px 10px; }
td input, td select { font-size: 14px; }

/* ------------ Status Chips ------------ */
.status { display:inline-block; padding:2px 10px; border-radius:12px; font-size:12px; font-weight:500; border:1px solid transparent; }
.status.green  { background:#e8f5e9; color:#2e7d32; border-color:#c8e6c9; }
.status.red    { background:#ffebee; color:#c62828; border-color:#ffcdd2; }
.status.amber  { background:#fff8e1; color:#f9a825; border-color:#ffecb3; }
.status.blue   { background:#e3f2fd; color:#1565c0; border-color:#bbdefb; }
.status.purple { background:#f3e5f5; color:#6a1b9a; border-color:#e1bee7; }
.status.gray   { background:#eeeeee; color:#424242; border-color:#e0e0e0; }
.status.teal   { background:#e0f2f1; color:#00695c; border-color:#b2dfdb; }

.status.active { background:#e8f5e9; color:#2e7d32; }
.status.cancelled { background:#ffebee; color:#c62828; }
.status.pending { background:#fff8e1; color:#f9a825; }
.status.paid { background:#e8f5e9; color:#2e7d32; }
.status.unpaid { background:#ffebee; color:#c62828; }

/* ------------ Pager ------------ */
nav.pager { margin-top:16px; display:flex; gap:8px; }
nav.pager a {
  padding:6px 12px;
  border-radius:4px;
  background:#fff;
  border:1px solid #ddd;
  transition: background .2s;
}
nav.pager a.active { background:var(--brand); color:#fff; border-color:var(--brand); }
nav.pager a:hover { background:#f5f5f5; }

/* ------------ Messages ------------ */
.flash { margin:12px 0; padding:12px; border-radius:4px; font-size:14px; }
.flash.error { background:#ffebee; color:#c62828; }
.flash.ok { background:#e8f5e9; color:#2e7d32; }

/* ------------ Utilities ------------ */
.row { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.danger { color:#c62828; }
.success { color:#2e7d32; }
.hr-light { border:0; height:1px; background:linear-gradient(90deg, transparent, #e6e6e6, transparent); margin:12px 0; }

/* ------------ Optional: Dark mode safety (if browser forces) ------------ */
@media (prefers-color-scheme: dark){
  /* Keep controls readable even in dark mode */
  input, select, textarea {
    color-scheme: light;
    background:#fff; color:#222; border-color:#ccc;
  }
}

/* ------------ Payment status Multi-select with chips ------------ */
.ms { position: relative; font-size: 12px; }
.ms-control{
  display:flex; align-items:center; gap:6px;
  background:#fff; border:1px solid #ccc; border-radius:6px; padding:7px 5px;
  cursor:pointer;
}
.ms-control:focus { outline:none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--ring); }
.ms-chips{ display:flex; flex-wrap:wrap; gap:6px; }
.ms-menu{
  position:absolute; left:0; right:0; top: calc(100% + 6px);
  background:#fff; border:1px solid var(--border); border-radius:8px;
  box-shadow: var(--shadow); padding:10px; z-index: 20; display:none;
}
.ms.open .ms-menu{ display:block; }
.ms-menu label{ display:flex; align-items:center; gap:8px; cursor:pointer; }
.ms-actions{ display:flex; justify-content:flex-end; gap:8px; margin-top:6px; }

#servicesTable tbody tr.bg-red   td { background: #fff5f5; }
#servicesTable tbody tr.bg-green td { background: #f1fff1; }
table#servicesTable tr.bg-red:nth-child(even)   td { background: #feecec; }
table#servicesTable tr.bg-green:nth-child(even) td { background: #eaffea; }