/* NPort2 - Light theme only */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #34a853;
  --error: #ea4335;
  --warning: #fbbc04;
  --info: #4285f4;
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --shadow: 0 1px 3px rgba(0,0,0,0.12);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
}

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

/* Layout */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

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

/* Nav */
.nav-title {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  font-size: 1.1rem;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-user {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: normal;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}

.nav-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  color: white;
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 4px;
}
.nav-home:hover { background: var(--primary-dark); text-decoration: none; }
.nav-home:focus-visible { outline: 2px solid white; outline-offset: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #c62828; }
.btn-secondary { background: var(--bg-secondary); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 4px 12px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: auto; }

.form-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 4px;
}

.form-inline {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-warning { background: var(--warning); color: var(--text); }
.toast-info { background: var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Lists */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child { border-bottom: none; }

.list-item a { flex: 1; }

/* Sections */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--primary);
}

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Utility */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-error { color: var(--error); }
.text-sm { font-size: 0.85rem; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.p-2 { padding: 8px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Calendar */
.calendar { width: 100%; border-collapse: collapse; }
.calendar th { padding: 8px 4px; text-align: center; font-size: 0.85rem; color: var(--text-secondary); }
.calendar td { padding: 4px; text-align: center; height: 48px; vertical-align: middle; }
.calendar td a { display: block; padding: 8px 4px; border-radius: var(--radius); }
.calendar td a:hover { background: var(--bg-secondary); text-decoration: none; }
.calendar .today { background: rgba(26,115,232,0.1); border-radius: var(--radius); }
.calendar .has-work a { font-weight: 600; color: var(--primary); }
.calendar .other-month { color: var(--border); }
.calendar .future { color: var(--border); }
.calendar .sunday { color: var(--error); }

/* Stars */
.stars { display: inline-flex; gap: 2px; cursor: pointer; }
.star { font-size: 1.2rem; color: var(--border); }
.star.filled { color: var(--warning); }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-warning { background: rgba(251,188,4,0.2); color: #7c5e00; }
.badge-info { background: rgba(66,133,244,0.2); color: #1a56db; }

/* Responsive */
@media (max-width: 600px) {
  .container { padding: 8px; }
  .card { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .form-inline { flex-direction: column; align-items: stretch; }
}

/* WpItemTree */
.tree-item {
  padding: 4px 0;
  cursor: pointer;
}

.tree-item:hover { background: var(--bg-secondary); }
.tree-group { font-weight: 600; }
.tree-search { margin-bottom: 12px; }
.tree-selected { background: rgba(26,115,232,0.08); border-radius: 4px; padding: 4px 8px; margin: 2px 0; }
.patient-selected-items { display: flex; flex-wrap: wrap; gap: 6px; }
.patient-selected-items .tree-selected { margin: 0; }

/* Aetherius layout */
.aeth-layout {
  display: flex;
  min-height: 100dvh;
}

.aeth-sidebar {
  position: sticky;
  top: 56px;
  align-self: flex-start;
  height: calc(100dvh - 56px);
  overflow-y: auto;
  width: 200px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.aeth-logout { margin-top: auto; }

.aeth-sidebar-title {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0 16px 12px;
  color: var(--primary);
}

.aeth-tab {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.aeth-tab:hover {
  background: var(--bg-secondary);
}

.aeth-tab-active {
  background: rgba(26,115,232,0.08);
  color: var(--primary);
  font-weight: 500;
  border-left: 3px solid var(--primary);
}

.aeth-content {
  flex: 1;
  padding: 16px 24px;
  overflow-y: auto;
}

@media (max-width: 600px) {
  .aeth-layout {
    flex-direction: column;
  }
  .aeth-sidebar {
    height: auto;
    max-height: 40dvh;
    z-index: 1;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    gap: 0;
  }
  .aeth-sidebar-title {
    padding: 0 12px;
    margin: 0;
  }
  .aeth-tab {
    width: auto;
    padding: 8px 12px;
  }
  .aeth-tab-active {
    border-left: none;
    border-bottom: 2px solid var(--primary);
  }
  .aeth-content {
    padding: 12px;
  }
}

/* Two-step work creation with full-row touch targets. */
.work-create-progress { color: var(--text-secondary); margin: 0 0 16px; }
.work-create-context { background: var(--bg-secondary); border-radius: var(--radius); padding: 16px; margin: 0 0 24px; }
.work-create-context dt { color: var(--text-secondary); font-size: .85rem; }
.work-create-context dd { margin: 4px 0 12px; font-weight: 600; overflow-wrap: anywhere; }
.work-create-context dd:last-child { margin-bottom: 0; }
.work-choice-list { border: 0; padding: 0; margin: 0; min-width: 0; }
.work-choice-list legend { font-weight: 600; margin-bottom: 12px; scroll-margin-top: 80px; }
.work-choice { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 14px 16px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; overflow-wrap: anywhere; }
.work-choice input { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--primary); }
.work-choice.is-selected { border-color: var(--primary); background: #edf4ff; }
.work-choice:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.work-create-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.work-create-actions .btn { flex: 1; min-height: 48px; }
@media (max-width: 640px) { .work-create-actions { flex-direction: column; } }

.work-create { scroll-margin-top: 64px; }

/* One-level-at-a-time patient item navigation. */
.item-picker-panel { scroll-margin-top: 68px; }
.answer-complete { color: #17653a; }
.answer-pending { color: #ac2525; }
.survey-rating-option { display: inline-flex; align-items: center; gap: 4px; padding: 6px; cursor: pointer; }
.survey-rating-option input { width: 20px; height: 20px; margin: 0; }
.survey-rating, .survey-rating-options { flex-wrap: wrap; }
.card[id] { scroll-margin-top: 68px; }
.item-picker-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.item-picker-header h4 { overflow-wrap: anywhere; }
.item-picker-count { white-space: nowrap; color: var(--primary); font-size: .85rem; }
.item-picker-search { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; }
.item-picker-search input { flex: 1; min-width: 160px; }
.item-picker-path { overflow-wrap: anywhere; margin-bottom: 8px; }
.item-picker-path button { padding: 10px 4px; border: 0; background: none; color: var(--primary); font: inherit; cursor: pointer; }
.item-picker-path button:disabled { color: var(--text-secondary); cursor: default; }
.item-picker-list { display: grid; gap: 8px; }
.item-picker-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); text-align: left; font: inherit; cursor: pointer; overflow-wrap: anywhere; }
.item-picker-row > span:first-child { min-width: 0; }
.item-picker-row small { display: block; color: var(--text-secondary); margin-top: 4px; }
.item-picker-row.is-selected { background: #edf4ff; border-color: var(--primary); }
.item-picker-check { color: var(--primary); flex-shrink: 0; }
.item-picker-row:focus-visible, .item-picker-path button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.item-picker-selected { margin: 16px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.item-picker-tag { border: 1px solid var(--primary); border-radius: 16px; padding: 6px 12px; color: var(--primary); background: #eef4ff; cursor: pointer; }
.item-picker-actions { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.item-picker-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.item-picker-buttons .btn { flex: 1; min-height: 48px; }
@media (max-width: 640px) { .item-picker-buttons { flex-direction: column-reverse; } }

/* One save indicator for all forms on the page. */
.autosave-indicator { display:inline-flex; align-items:center; justify-content:center; margin-left:auto; flex:none; width:40px; height:40px; border:0; border-radius:50%; background:transparent; color:white; font-size:1.5rem; line-height:1; cursor:pointer; }
button.autosave-indicator:hover, button.autosave-indicator:focus-visible { background:var(--primary-dark); }
span.autosave-indicator { cursor:default; }
.autosave-indicator.error { color:#fff0b3; }
.autosave-detail { position:absolute; right:16px; top:calc(100% + 6px); width:min(22rem, calc(100vw - 32px)); padding:12px 16px; background:white; color:var(--text); font-size:.9rem; font-weight:400; border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); }
.autosave-detail[hidden] { display:none; }
.visually-hidden { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.autosave-navigation { position:fixed; bottom:1rem; left:1rem; right:1rem; margin:auto; max-width:38rem; padding:1rem; background:#fff3bf; color:#704e00; border:1px solid #d4b252; border-radius:8px; z-index:1000; }

.aeth-user-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.aeth-user-toggle:hover { text-decoration: underline; }
.aeth-user-tools { padding: 0.5rem; }
.aeth-user-url {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.aeth-user-url input {
  flex: 1 1 16rem;
  min-width: 0;
  font-family: monospace;
  font-size: 13px;
}

.feedback-launch { position: fixed; bottom: 1rem; right: 1rem; z-index: 90; padding: .55rem .8rem; background: #384a60; color: white; border: 0; border-radius: .4rem; cursor: pointer; }
.feedback-dialog { width: min(92vw, 36rem); max-height: 90vh; border: 1px solid #bbb; border-radius: .5rem; padding: 1.25rem; }
.feedback-dialog::backdrop { background: rgba(0,0,0,.5); }
.feedback-dialog h2 { margin: 0 0 .5rem; }
.feedback-dialog label { display: block; margin: .8rem 0 .3rem; }
.feedback-dialog textarea { width: 100%; box-sizing: border-box; }
.feedback-dialog ul { padding-left: 1.5rem; }
.feedback-location { overflow-wrap: anywhere; font-size: .85rem; }
.feedback-actions { display: flex; justify-content: flex-end; gap: .5rem; }
