:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9bb4;
  --accent: #3d8bfd;
  --accent-dim: #2563c4;
  --danger: #f87171;
  --success: #4ade80;
  --radius: 10px;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.calendar-wrap {
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* FullCalendar theme overrides */
#calendar {
  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--bg);
  --fc-neutral-bg-color: #151c28;
  --fc-list-event-hover-bg-color: #1e2838;
  --fc-today-bg-color: rgba(61, 139, 253, 0.12);
  --fc-button-bg-color: var(--surface);
  --fc-button-border-color: var(--border);
  --fc-button-text-color: var(--text);
  --fc-button-hover-bg-color: #243044;
  --fc-button-active-bg-color: var(--accent-dim);
}

.fc .fc-toolbar-title {
  font-size: 1.25rem !important;
}

.fc .fc-button {
  border-radius: var(--radius);
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.auth-card h1 {
  margin-top: 0;
  font-size: 1.35rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.stack label,
.grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

input,
textarea,
select {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-dim);
}

.btn.secondary {
  background: #243044;
}

.btn.ghost {
  background: transparent;
}

.btn.link {
  border: none;
  background: none;
  color: var(--accent);
  padding: 0.25rem;
  font-size: 0.85rem;
}

.error {
  color: var(--danger);
  margin: 0 0 0.5rem;
}

.success {
  color: var(--success);
  margin: 0 0 0.5rem;
}

.page {
  padding: 1.25rem;
  max-width: 720px;
  margin: 0 auto;
}

.page.narrow h1 {
  margin-top: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.grid {
  display: grid;
  gap: 0.75rem;
}

.grid.two {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 600px) {
  .grid.two {
    grid-template-columns: 1fr;
  }
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.user-edit {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

label.checkbox {
  flex-direction: row !important;
  align-items: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
}

.modal-card h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.notif-wrap {
  position: relative;
}

.notif-panel {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.35rem;
  width: min(340px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.notif-panel.hidden {
  display: none;
}

.notif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

#notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}

.notif-item {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  cursor: pointer;
}

.notif-item.read {
  opacity: 0.65;
  cursor: default;
}

.notif-item:hover:not(.read) {
  background: #243044;
}

.badge {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.25rem;
  text-align: center;
}

.badge.hidden {
  display: none;
}

/* App layout: stores + calendar + todos */
.app-main {
  padding: 0 1rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

.store-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1.25rem;
  background: #151c28;
  border-bottom: 1px solid var(--border);
}

.store-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.store-label select {
  min-width: 200px;
}

.store-hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.85rem;
}

.btn.danger-outline {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn.danger-outline:hover {
  background: rgba(248, 113, 113, 0.12);
}

.app-grid {
  display: grid;
  grid-template-columns: 1fr min(380px, 100%);
  gap: 1.25rem;
  align-items: start;
  margin-top: 1rem;
}

@media (max-width: 960px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.panel-title,
.todo-heading {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.small {
  font-size: 0.85rem;
  font-weight: normal;
}

.calendar-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

#calendar.hidden {
  display: none;
}

.todo-section {
  margin-bottom: 1.5rem;
}

.todo-section:last-child {
  margin-bottom: 0;
}

.todo-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.todo-add input[type='text'] {
  flex: 1 1 160px;
  min-width: 0;
}

.todo-add select {
  width: auto;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.todo-row {
  border-radius: 8px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--bg);
  padding: 0.6rem 0.75rem;
}

.todo-row.sev-low {
  border-left-color: #22c55e;
}

.todo-row.sev-normal {
  border-left-color: #3d8bfd;
}

.todo-row.sev-high {
  border-left-color: #f59e0b;
}

.todo-row.sev-critical {
  border-left-color: #ef4444;
}

.todo-row.todo-completed {
  opacity: 0.82;
}

.todo-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.todo-title-input {
  font-weight: 600;
  width: 100%;
}

.todo-notes-input {
  width: 100%;
  resize: vertical;
  min-height: 2.5rem;
}

.todo-row.todo-completed .todo-title-input {
  text-decoration: line-through;
}

.todo-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.todo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.todo-severity {
  font-size: 0.85rem;
}

.todo-done {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Inventory page */
.inv-page .inv-main {
  padding: 0 1rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.inv-intro {
  max-width: 52rem;
  margin: 0.5rem 0 1rem;
  line-height: 1.45;
}

.inv-layout {
  display: grid;
  grid-template-columns: 1fr min(340px, 100%);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .inv-layout {
    grid-template-columns: 1fr;
  }
}

.inv-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.inv-add-form input[type='text'],
.inv-add-form input[type='number'] {
  flex: 1 1 140px;
  min-width: 0;
}

.inv-table-wrap {
  overflow-x: auto;
}

.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.inv-table th,
.inv-table td {
  text-align: left;
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.inv-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.inv-row-low {
  background: rgba(245, 158, 11, 0.08);
}

.inv-name {
  font-weight: 600;
}

.inv-notes {
  margin-top: 0.2rem;
}

.inv-actions {
  min-width: 12rem;
}

.inv-action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}

.inv-take-input {
  width: 3.25rem;
}

.inv-activity-link {
  margin: 0.5rem 0 0;
}

.inv-activity-main {
  max-width: 1100px;
}

.activity-table-wrap {
  margin-top: 0.5rem;
}

.inv-activity-table .inv-act-time {
  white-space: nowrap;
  font-size: 0.85rem;
}

.inv-activity-table .inv-act-note {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 14rem;
  word-break: break-word;
}

.inv-delta-pos {
  color: var(--success);
  font-weight: 600;
}

.inv-delta-neg {
  color: var(--danger);
  font-weight: 600;
}

.inv-cart {
  position: sticky;
  top: 0.5rem;
}

.inv-cart-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.inv-cart-line {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
}

.inv-cart-line > div:first-child {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.inv-cart-note {
  width: 100%;
  margin-bottom: 0.35rem;
}

.wide {
  width: 100%;
}

.inv-table-empty {
  padding: 1rem 0 !important;
  text-align: center;
}
