:root {
  --violet: #7a17f8;
  --violet-dark: #5f0fc8;
  --violet-soft: #efe4ff;
  --violet-rgb: 122, 23, 248;
  --terracotta: #bd574e;
  --terracotta-dark: #9e443c;
  --rose: #fa877f;
  --tan: #ffad87;
  --green: #17866f;
  --orange: #d87933;
  --red: #bd574e;
  --nav: #22152f;
  --bg: #f8f5fb;
  --card: #fff;
  --text: #2c2134;
  --muted: #756a7d;
  --border: #e9e0ef;
  --radius-sm: 10px;
  --radius: 18px;
  --radius-lg: 26px;
  --shadow: 0 14px 38px rgba(49, 25, 70, .08);
  --shadow-hover: 0 18px 44px rgba(49, 25, 70, .13);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, rgba(var(--violet-rgb), .09), transparent 30rem),
    linear-gradient(180deg, #fbf9fd 0%, var(--bg) 100%);
  color: var(--text);
  font: 15px/1.5 "Century Gothic", "Avenir Next", Avenir, Arial, sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--violet) 0 52%, var(--rose) 52% 70%, var(--tan) 70% 86%, var(--terracotta) 86%);
  z-index: 200;
}

a { color: var(--violet-dark); text-underline-offset: 2px; }
a:hover { color: var(--violet); }

header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  min-height: 72px;
  padding: 14px clamp(16px, 3vw, 34px);
  color: #fff;
  background: rgba(34, 21, 47, .96);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 10px 30px rgba(34,21,47,.15);
  backdrop-filter: blur(16px);
}
header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
header nav > span { color: rgba(255,255,255,.68); margin-right: 8px; font-size: 13px; }
header a { color: rgba(255,255,255,.86); text-decoration: none; }
header nav a { padding: 8px 10px; border-radius: 10px; font-weight: 700; font-size: 13px; transition: .18s ease; }
header nav a:hover { color: #fff; background: rgba(255,255,255,.10); }

.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; color: #fff; text-decoration: none; }
.brand img { width: 38px; height: 38px; object-fit: contain; flex: 0 0 auto; filter: drop-shadow(0 4px 12px rgba(0,0,0,.2)); }
.brand span { color: #fff; font-size: 19px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; }
.brand span::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--rose); vertical-align: middle; }

main { width: min(1180px, 100%); margin: 30px auto 48px; padding: 0 clamp(12px, 2.5vw, 22px); }
h1, h2, h3 { line-height: 1.22; letter-spacing: -.025em; }
h2 { margin-top: 0; font-size: clamp(1.45rem, 2.5vw, 2rem); }
h3 { margin-top: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

.card {
  position: relative;
  margin-bottom: 18px;
  padding: clamp(16px, 2.4vw, 24px);
  overflow: hidden;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(122,23,248,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.card:hover { border-color: rgba(var(--violet-rgb), .15); box-shadow: var(--shadow-hover); }
.card > h2:first-child::before, .card > h3:first-child::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: .9em;
  margin-right: 9px;
  border-radius: 99px;
  background: var(--violet);
  vertical-align: -.04em;
}

input, select, textarea {
  width: 100%;
  min-height: 47px;
  margin: 6px 0 15px;
  padding: 11px 13px;
  border: 1px solid #ded4e5;
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:hover, select:hover, textarea:hover { border-color: #cbb9d7; }
input:focus, select:focus, textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(var(--violet-rgb), .11);
}
textarea { min-height: 116px; resize: vertical; }
label { display: block; margin-top: 2px; color: #43354b; font-weight: 800; font-size: 13px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--violet); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 11px 16px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--violet), #8a38f8);
  box-shadow: 0 8px 20px rgba(var(--violet-rgb), .19);
  color: #fff;
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
button:hover, .btn:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 11px 25px rgba(var(--violet-rgb), .28); filter: saturate(1.05); }
button:active, .btn:active { transform: translateY(0); }
button:disabled, .btn:disabled { opacity: .58; cursor: not-allowed; transform: none; }
.btn.secondary, button.secondary { background: #44364d; box-shadow: none; color: #fff; }
.btn.green, button.green { background: var(--green); box-shadow: none; color: #fff; }
.btn.orange, button.orange { background: var(--tan); box-shadow: none; color: #552f22; }
.btn.red, button.red, .red { background: var(--terracotta); box-shadow: none; color: #fff; }
.btn.light, button.light { background: var(--violet-soft); box-shadow: none; color: var(--violet-dark); }
.btn.small, button.small { min-height: 36px; padding: 7px 11px; border-radius: 10px; font-size: 13px; }
.btn.active { color: #fff; background: var(--violet); box-shadow: 0 0 0 4px rgba(var(--violet-rgb), .14); }
.btn.full { width: 100%; }

.actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.actions-row.space { justify-content: space-between; }
.quick-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.filters { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 13px; align-items: end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.meta { color: var(--muted); font-size: 13px; }
.mobile-only { display: none; }

.flash {
  margin-bottom: 14px;
  padding: 12px 15px;
  border: 1px solid rgba(var(--violet-rgb), .16);
  border-left: 5px solid var(--violet);
  border-radius: 12px;
  background: var(--violet-soft);
  color: #4b2475;
  box-shadow: var(--shadow);
}
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: 11px; font-weight: 900; letter-spacing: .02em; white-space: nowrap; }
.badge-blue { background: #e7e4ff; color: #4d3dba; }
.badge-orange { background: #fff0e6; color: #9d4d20; }
.badge-purple { background: var(--violet-soft); color: var(--violet-dark); }
.badge-green { background: #dff5ee; color: #116f5b; }
.badge-gray { background: #eee9f1; color: #5e5365; }
.badge-red { background: #f9dfdc; color: #923c35; }

.desktop-table { display: block; overflow-x: auto; }
.mobile-list { display: none; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: transparent; }
th { padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; text-align: left; }
td { padding: 13px 12px; border-bottom: 1px solid #f0eaf3; font-size: 14px; vertical-align: top; text-align: left; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #fbf8fd; }
tbody tr:last-child td { border-bottom: 0; }

.mobile-card {
  margin-bottom: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: linear-gradient(145deg, #fff, #fdfaff);
  box-shadow: 0 7px 22px rgba(48,25,65,.06);
}
.mobile-card-title { margin-bottom: 5px; font-size: 16px; font-weight: 900; }
.mobile-card-row { margin: 7px 0; }
.mobile-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }

.form-section {
  margin: 15px 0;
  padding: 16px;
  border: 1px solid rgba(var(--violet-rgb), .12);
  border-radius: 16px;
  background: linear-gradient(135deg, #fbf8ff, #fffaf8);
}
.form-section h3 { color: var(--violet-dark); }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.thumb { padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.thumb img { display: block; width: 100%; height: 120px; object-fit: cover; border-radius: 10px; }
.signature-pad { width: 100%; height: 180px; border: 1px solid #ded4e5; border-radius: 13px; background: #fff; touch-action: none; }
.voice-btn { min-height: 36px; margin: -8px 0 12px; padding: 7px 11px; background: #44364d; box-shadow: none; }
.voice-btn.recording { background: var(--terracotta); }
.gps-note { margin-top: 6px; color: var(--muted); font-size: 12px; }

.ts-wrapper { margin: 6px 0 14px; }
.ts-control { min-height: 47px; border-color: #ded4e5; border-radius: 12px; font-size: 16px; box-shadow: none; }
.ts-wrapper.focus .ts-control { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(var(--violet-rgb), .11); }

/* FullCalendar */
#calendar { min-height: 520px; }
.fc { --fc-border-color: var(--border); --fc-button-bg-color: var(--violet); --fc-button-border-color: var(--violet); --fc-button-hover-bg-color: var(--violet-dark); --fc-button-hover-border-color: var(--violet-dark); --fc-button-active-bg-color: var(--violet-dark); --fc-button-active-border-color: var(--violet-dark); --fc-today-bg-color: rgba(var(--violet-rgb), .06); }
.fc .fc-button { border-radius: 10px !important; box-shadow: none !important; font-family: inherit; font-weight: 800; }
.fc .fc-toolbar-title { color: var(--text); font-weight: 900; }
.fc .fc-event { border: 0; border-radius: 8px; padding: 2px 4px; box-shadow: 0 4px 12px rgba(34,21,47,.12); }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--border); }

/* Login / security cards */
main > .card[style*="max-width:420px"], main > .card[style*="max-width:620px"] { margin-top: clamp(24px, 8vh, 80px) !important; }
main > .card[style*="max-width:420px"] { border-top: 5px solid var(--violet); }

.mobile-bottom-nav, .sticky-mobile-actions { display: none; }

@media (max-width: 800px) {
  body { padding-bottom: calc(78px + var(--safe-bottom)); font-size: 16px; }
  header { min-height: 64px; padding: 11px 14px; }
  header nav { display: none; }
  .brand img { width: 32px; height: 32px; }
  .brand span { font-size: 17px; }
  main { margin: 14px auto 24px; padding: 0 10px; }
  .card { padding: 15px; border-radius: 16px; margin-bottom: 12px; }
  .filters, .form-grid { grid-template-columns: 1fr; gap: 7px; }
  .actions-row { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; }
  .actions-row .btn, .actions-row button, .actions-row form, .actions-row form button { width: 100%; }
  .quick-filters { flex-wrap: nowrap; overflow-x: auto; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; }
  .quick-filters .btn { width: auto; min-width: max-content; }
  button, .btn { width: 100%; min-height: 48px; padding: 13px 14px; }
  .btn.small, button.small { min-height: 42px; }
  .desktop-only { display: none !important; }
  .mobile-only { display: block; }
  .desktop-table { display: none; }
  .mobile-list { display: block; }
  table, thead, tbody, th, td, tr { display: block; }
  th { display: none; }
  td { padding: 6px 0; border: 0; }
  tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .thumb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .thumb img { height: 115px; }
  .signature-pad { height: 220px; }
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 150;
    padding: 7px 8px calc(7px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,.96);
    box-shadow: 0 -8px 28px rgba(45,25,58,.11);
    backdrop-filter: blur(18px);
  }
  .mobile-bottom-nav a { padding: 6px 2px; border-radius: 10px; color: #5b4e63; text-decoration: none; text-align: center; font-size: 11px; font-weight: 900; }
  .mobile-bottom-nav a:hover, .mobile-bottom-nav a:active { background: var(--violet-soft); color: var(--violet-dark); }
  .sticky-mobile-actions { display: block; position: sticky; top: 65px; z-index: 90; margin: -3px 0 10px; padding: 8px 0; background: rgba(248,245,251,.94); backdrop-filter: blur(10px); }
  .sticky-mobile-actions .card { margin-bottom: 0; }
  #calendar { min-height: 420px; }
  .fc .fc-toolbar { flex-direction: column; gap: 8px; }
  .fc .fc-toolbar-title { font-size: 1.08rem; text-align: center; }
  .fc .fc-button { padding: .55rem .7rem; font-size: .9rem; }
  .fc-list-event-title, .fc-list-event-time { font-size: .95rem; }
}

/* =========================================================
   Refined action hierarchy — one strong primary action
   ========================================================= */

/* Secondary actions stay calm and do not compete with the main CTA. */
.btn.secondary,
button.secondary,
.btn.green,
button.green,
.btn.orange,
button.orange {
  background: #fff;
  color: var(--violet-dark);
  border: 1.5px solid rgba(var(--violet-rgb), .28);
  box-shadow: 0 5px 16px rgba(49, 25, 70, .06);
}

.btn.secondary:hover,
button.secondary:hover,
.btn.green:hover,
button.green:hover,
.btn.orange:hover,
button.orange:hover {
  background: var(--violet-soft);
  color: var(--violet-dark);
  border-color: rgba(var(--violet-rgb), .55);
  box-shadow: 0 8px 20px rgba(var(--violet-rgb), .12);
}

/* Keep destructive actions clearly separate. */
.btn.red,
button.red,
.red {
  background: var(--terracotta);
  color: #fff;
  border-color: transparent;
}

.btn.red:hover,
button.red:hover {
  background: var(--terracotta-dark);
  color: #fff;
}

/* Dashboard action card: first action is the clear primary CTA. */
main > .card:first-child > .actions-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

main > .card:first-child > .actions-row > .btn:first-child {
  grid-column: 1 / -1;
  min-height: 54px;
  font-size: 1.05rem;
}

main > .card:first-child > .actions-row > .btn:not(:first-child) {
  min-height: 48px;
  background: #fff;
  color: var(--violet-dark);
  border: 1.5px solid rgba(var(--violet-rgb), .25);
  box-shadow: 0 5px 16px rgba(49, 25, 70, .05);
}

main > .card:first-child > .actions-row > .btn:not(:first-child):hover {
  background: var(--violet-soft);
  border-color: rgba(var(--violet-rgb), .5);
  color: var(--violet-dark);
}

/* Filter pills: calmer inactive state and a clearer selected state. */
.quick-filters .btn.light {
  background: #f2eaff;
  color: #6720bd;
  border: 1px solid transparent;
  box-shadow: none;
}

.quick-filters .btn.light:hover {
  background: #e8d9ff;
  color: var(--violet-dark);
  box-shadow: none;
}

.quick-filters .btn.active {
  background: var(--violet);
  color: #fff;
  border: 1px solid var(--violet);
  box-shadow: 0 7px 18px rgba(var(--violet-rgb), .24);
}

/* Cleaner brand lockup; prevents the logo and text from colliding. */
.brand {
  gap: 12px;
  flex: 0 1 auto;
  max-width: min(55vw, 330px);
}

.brand img {
  width: auto;
  height: 36px;
  max-width: 126px;
  object-fit: contain;
}

.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile bottom navigation feels like a control bar rather than plain links. */
@media (max-width: 800px) {
  main > .card:first-child > .actions-row {
    grid-template-columns: 1fr 1fr;
  }

  main > .card:first-child > .actions-row > .btn:first-child {
    grid-column: 1 / -1;
  }

  main > .card:first-child > .actions-row > .btn:not(:first-child) {
    width: 100%;
  }

  .brand {
    gap: 8px;
    max-width: calc(100vw - 28px);
  }

  .brand img {
    height: 31px;
    max-width: 105px;
  }

  .brand span {
    font-size: 16px;
  }

  .mobile-bottom-nav {
    gap: 5px;
    padding-left: 9px;
    padding-right: 9px;
  }

  .mobile-bottom-nav a {
    padding: 7px 3px;
    border-radius: 12px;
    transition: background .16s ease, color .16s ease, transform .16s ease;
  }

  .mobile-bottom-nav a:hover,
  .mobile-bottom-nav a:active,
  .mobile-bottom-nav a:focus-visible {
    background: var(--violet-soft);
    color: var(--violet-dark);
    transform: translateY(-1px);
    outline: none;
  }
}

@media (max-width: 430px) {
  main > .card:first-child > .actions-row {
    grid-template-columns: 1fr 1fr;
  }

  main > .card:first-child > .actions-row > .btn:nth-child(4) {
    grid-column: 1 / -1;
  }
}

