:root {
  --bg: #0b1220;
  --panel: #0d1426;
  --ink: #e6edf3;
  --muted: #94a3b8;
  --card: #111a2e;
  --accent: #0b3a5b;
  --border: #334155;
  --blue: #60a5fa;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.6;
  margin: 0;
}

#app { display: flex; height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Sidebar */
aside {
  width: 320px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  background: #1f2c47;
  color: var(--ink);
}

.brand h1 { margin: 8px 0 0; }
.brand p { margin: 0 0 12px; color: var(--muted); }
/* Navigation */
.nav {
  position: relative;
  display: flex;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 2px solid rgba(255, 255, 255, 0.461);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.nav::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  height: 100%; width: 50%;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform .5s ease-in-out;
  border-radius: 16px;
  z-index: 0;
}
.nav.dashboard-active::before { transform: translateX(0); }
.nav.clients-active::before { transform: translateX(100%); }

.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  transition: color 0.3s;
  position: relative;
  z-index: 1;

}
.nav-btn:hover { color: #fff; }
.nav-btn.active { color: #fff; }

/* Sidebar actions and list */
.side-actions {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

#sign-out-btn, #add-client-btn {

  flex: 1;
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  transition: color 0.3s;
  position: relative;
  z-index: 1;
}
#sign-out-btn:hover, #add-client-btn:hover { background: #334155; }
#sign-out-btn:active, #add-client-btn:active { transform: translateY(1px); }

.search-wrap { margin: 12px 0; }
.search-wrap input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--ink);
}

#client-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
#client-list li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 12px;
}
#client-list li:hover { background: #1f2937; }
#client-list li.active { background: var(--accent); font-weight: 700; }

/* Main */
main {
  flex: 1;
  padding: 24px;
  overflow: auto;
  background: var(--panel);
}

/* Cards and panels */
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.card-title { font-size: 14px; color: var(--muted); }
.metric { font-size: 34px; font-weight: 800; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.list a { color: #93c5fd; text-decoration: none; }
.list a:hover { text-decoration: underline; }

/* Form base */
label {
  display: block;
  font-weight: 700;
  margin-top: 12px;
  margin-bottom: 8px;
}
input, textarea, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.4;
  background: #0f172a;
  color: var(--ink);
  border: 2px solid #475569;
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--blue);
  outline: 3px solid rgba(96, 165, 250, 0.35);
  outline-offset: 2px;
}
textarea { height: 150px; resize: vertical; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}
.form-actions button {
  min-height: 44px;
  padding: 10px 16px;
  background: #1f2937;
  border: 2px solid #475569;
  color: var(--ink);
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.2s, transform 0.1s, border-color 0.2s;
}
.form-actions button:hover { background: #334155; border-color: #55657a; }
.form-actions button:active { transform: translateY(1px); }

/* Add Client Modal */
#client-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.7);
  padding: 16px;
}
#client-modal.flex { display: flex !important; }

#client-modal .modal-card {
  width: min(560px, 92vw);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  border-radius: 18px;
  background: #0f172a;
  border: 1em double var(--border);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.6);
}
#client-modal .modal-card h2 {
  margin: 0 0 6px;
}
#client-modal .modal-card form > div + div {
  margin-top: 8px;
}

/* Services checkboxes — chip grid */
#services-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

#services-checkboxes label {
  position: relative;
  display: grid;
  grid-template-rows: 20px auto;
  justify-items: center;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  min-height: 72px;
}

#services-checkboxes input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 2px solid var(--blue);
  border-radius: 4px;
  background: transparent;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
}
#services-checkboxes input[type="checkbox"]:hover { border-color: #93c5fd; }
#services-checkboxes input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(96, 165, 250, 0.35);
  outline-offset: 2px;
}
#services-checkboxes input[type="checkbox"]:checked {
  background: var(--blue);
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.45);
  border-color: var(--blue);
}

#services-checkboxes label span {
  font-size: 14px;
  text-align: center;
  color: var(--ink);
  line-height: 1.2;
}

#services-checkboxes label:has(input[type="checkbox"]:checked) {
  background: rgba(96, 165, 250, 0.18);
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.25);
}
#services-checkboxes label:hover {
  background: rgba(255, 255, 255, 0.08);
}

.doc-copy-group {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  margin-top: 8px;
}

.doc-copy-group label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  min-width: 84px;
}


input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  aspect-ratio: 1 / 1; 
  border-radius: 50%;
  margin: 0;
  flex-shrink: 0;
  border: 2px solid var(--blue);
  background: transparent;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}


input[type="radio"]:hover {
  border-color: #93c5fd;
}
input[type="radio"]:focus-visible {
  outline: 3px solid rgba(96, 165, 250, 0.35);
  outline-offset: 2px;
}

input[type="radio"]:checked::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 6px rgba(96, 165, 250, 0.5);
}

.doc-copy-group label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  cursor: crosshair;
  min-width: 84px;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.doc-copy-group label:has(input[type="radio"]:checked) {
  background: rgba(96, 165, 250, 0.18);
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.25);
}

.doc-copy-group label:hover {
  background: rgba(255, 255, 255, 0.08);
}

.doc-copy-group label:hover { background: rgba(255, 255, 255, 0.08); }

.doc-copy-group span {
  margin-top: 2px;
  text-align: center;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.2;
}

.detail-header .detail-meta span {
  display: inline-block;
  font-size: 14px;
  background: var(--accent);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 6px;
  border: 4px double #2e657d;
}

/* Auth and toast */
#auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  text-align: center;
}
#google-signin-btn {
  border: none;
  padding: 12px 24px;
  font-size: 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  background: #3b82f6;
  color: #fff;
}
#google-signin-btn:hover { background: #2563eb; }

#error-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #b91c1c;
  color: #fff;
  font-weight: 900;
  border: 2px solid #7f1d1d;
  border-radius: 10px;
  padding: 12px 16px;
  max-width: 420px;
  display: none;
}
#error-toast.show { display: block; }

/* Responsive tweaks */
@media (max-width: 1120px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  aside { width: 100%; height: auto; position: sticky; top: 0; z-index: 10; }
  #app { flex-direction: column; }
  .cards { grid-template-columns: 1fr; }
  #services-checkboxes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}