* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2937;
  background: #f7f7f8;
  font-size: 14px;
  line-height: 1.45;
}

header {
  background: #1f2937;
  color: #fff;
  padding: .75rem 1.5rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
header a { color: #fff; text-decoration: none; font-weight: 600; }
header a:hover { text-decoration: underline; }
header .spacer { flex: 1; }
header .who { color: #cbd5e1; font-size: .85rem; }
header .who strong { color: #fff; }
header .logout { margin: 0; }
header .logout button {
  background: transparent;
  color: #fff;
  border: 1px solid #4b5563;
  padding: .25rem .65rem;
  font-size: .85rem;
  border-radius: 4px;
  cursor: pointer;
}
header .logout button:hover { background: #374151; }

/* --- Header dropdown menu (hamburger) --- */
header details.nav-menu { position: relative; }
header details.nav-menu summary {
  cursor: pointer;
  color: #fff;
  font-weight: 600;
  list-style: none;
  padding: 0;
  user-select: none;
}
header details.nav-menu summary::-webkit-details-marker { display: none; }
header details.nav-menu summary::marker { content: ""; }
header details.nav-menu summary:hover { text-decoration: underline; }
header details.nav-menu[open] summary { text-decoration: underline; }
header details.nav-menu .menu-content {
  position: absolute;
  top: calc(100% + .6rem);
  left: 0;
  background: #fff;
  color: #1f2937;
  min-width: 220px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  padding: .35rem 0;
  z-index: 20;
}
header details.nav-menu .menu-content a {
  display: block;
  color: #1f2937;
  padding: .55rem 1rem;
  text-decoration: none;
  font-weight: 500;
  font-size: .9rem;
}
header details.nav-menu .menu-content a:hover {
  background: #f3f4f6;
  text-decoration: none;
}

main {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .5rem; }

p.back a { color: #4b5563; text-decoration: none; }
p.back a:hover { text-decoration: underline; }

form.stacked label,
form.comment-form label {
  display: block;
  margin: .65rem 0;
  font-weight: 600;
  color: #374151;
}
form.stacked label.inline,
form.comment-form label.inline {
  font-weight: 400;
}
form input[type=text],
form input[type=email],
form input:not([type]),
form textarea,
form select {
  display: block;
  width: 100%;
  max-width: 520px;
  padding: .4rem .55rem;
  margin-top: .25rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
form textarea { max-width: 100%; }
form button {
  padding: .5rem 1.1rem;
  background: #2563eb;
  color: #fff;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
form button:hover { background: #1d4ed8; }

.errors {
  background: #fee2e2;
  color: #991b1b;
  padding: .75rem 1rem;
  border-radius: 4px;
  list-style: none;
  margin: 0 0 1rem;
}
.errors li { margin: .1rem 0; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
th, td {
  padding: .55rem .8rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}
th {
  background: #f3f4f6;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #4b5563;
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f9fafb; }
tbody tr:last-child td { border-bottom: 0; }

.prio { font-weight: 600; }
.prio-urgent { color: #b91c1c; }
.prio-high   { color: #c2410c; }
.prio-normal { color: #374151; }
.prio-low    { color: #6b7280; }

nav.filters { margin: 1rem 0; display: flex; gap: .25rem; flex-wrap: wrap; }
nav.filters a {
  padding: .3rem .65rem;
  text-decoration: none;
  color: #2563eb;
  border-radius: 4px;
  font-weight: 500;
}
nav.filters a:hover { background: #eff6ff; }
nav.filters a.active { background: #2563eb; color: #fff; }

dl.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .25rem 1.25rem;
  max-width: 600px;
  margin: 1rem 0;
}
dl.meta dt { font-weight: 600; color: #6b7280; }
dl.meta dd { margin: 0; }

.description pre,
.comment pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: #fff;
  padding: .75rem .9rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font: inherit;
  margin: 0;
}

.comment { margin: .75rem 0; }
.comment header { font-size: .8rem; color: #6b7280; margin-bottom: .25rem; }
.comment.internal pre { background: #fffbeb; border-color: #fde68a; }

.update-form {
  background: #fff;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}
.update-form label { margin: 0; }
.update-form input,
.update-form select { width: 180px; }

.comment-form {
  background: #fff;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  margin-top: 1rem;
}

.empty { color: #6b7280; }

/* --- Dashboard --- */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.stat-card {
  display: block;
  background: #fff;
  padding: 1rem 1.1rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, transform .05s;
}
.stat-card:hover { border-color: #2563eb; }
.stat-card:active { transform: translateY(1px); }
.stat-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  font-weight: 600;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #111827;
  margin-top: .25rem;
}
.stat-value.warn { color: #b91c1c; }

.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1rem 1.1rem;
  margin-top: 1rem;
}
.panel h2 { margin-top: 0; display: flex; align-items: center; gap: .5rem; }
.panel table {
  border: 0;
  border-radius: 0;
}
.panel table th { background: transparent; padding-left: 0; padding-right: 0; }
.panel table td { padding-left: 0; padding-right: 0; }
.panel table th.num, .panel table td.num { text-align: right; padding-right: .5rem; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}
@media (max-width: 800px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.badge {
  display: inline-block;
  background: #e5e7eb;
  color: #374151;
  font-size: .75rem;
  font-weight: 600;
  padding: .1rem .5rem;
  border-radius: 999px;
}
.badge.warn { background: #fee2e2; color: #991b1b; }

.priority-list { list-style: none; padding: 0; margin: 0; }
.priority-list li { border-bottom: 1px solid #f3f4f6; }
.priority-list li:last-child { border-bottom: 0; }
.priority-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .55rem .2rem;
  text-decoration: none;
}
.priority-list a:hover { background: #f9fafb; }
.priority-list .prio { text-transform: capitalize; }
.priority-list .prio-count { font-weight: 700; color: #111827; font-variant-numeric: tabular-nums; }

.active-filters { margin: .5rem 0 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.active-filters .chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .8rem;
}
.active-filters .chip a {
  color: #1e40af;
  text-decoration: none;
  font-weight: 700;
  padding: 0 .2rem;
}
.active-filters .chip a:hover { color: #b91c1c; }

/* --- Calendar --- */

.calendar-section { margin-top: 1.5rem; }
.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .75rem;
}
.cal-header h1,
.cal-header h2 { margin: 0; }
.cal-nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.cal-nav .btn {
  display: inline-block;
  padding: .35rem .8rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1f2937;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  font-size: .85rem;
}
.cal-nav .btn:hover { background: #f3f4f6; }
.cal-nav .btn.primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.cal-nav .btn.primary:hover { background: #1d4ed8; }

table.calendar {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
table.calendar th {
  background: #f3f4f6;
  font-size: .7rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #4b5563;
  padding: .4rem .5rem;
  text-align: left;
}
.cal-cell {
  vertical-align: top;
  height: 110px;
  padding: .3rem .4rem;
  border-top: 1px solid #e5e7eb;
  border-left: 1px solid #e5e7eb;
  position: relative;
  background: #fff;
}
.cal-cell:first-child { border-left: 0; }
.cal-cell.other-month { background: #fafafa; color: #9ca3af; }
.cal-cell.today { background: #eff6ff; }
.cal-cell.today .cal-day-num { color: #1e40af; font-weight: 700; }

.cal-day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .25rem;
}
.cal-day-num { font-size: .85rem; font-weight: 600; color: #374151; }
.cal-cell.other-month .cal-day-num { color: #9ca3af; font-weight: 400; }
.cal-add {
  visibility: hidden;
  color: #6b7280;
  text-decoration: none;
  font-weight: 700;
  font-size: .9rem;
  line-height: 1;
  padding: 0 .25rem;
  border-radius: 3px;
}
.cal-add:hover { background: #2563eb; color: #fff; }
.cal-cell:hover .cal-add { visibility: visible; }

.cal-events { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.cal-events li a {
  display: block;
  background: #dbeafe;
  border-left: 3px solid #2563eb;
  color: #1e3a8a;
  padding: .12rem .35rem;
  font-size: .75rem;
  border-radius: 3px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-events li a:hover { background: #bfdbfe; }
.cal-events .event-time {
  display: inline-block;
  font-weight: 600;
  margin-right: .25rem;
  font-variant-numeric: tabular-nums;
}
.cal-events li.recurring a {
  background: #fef3c7;
  border-left-color: #f59e0b;
  color: #78350f;
}
.cal-events li.recurring a:hover { background: #fde68a; }

/* --- Recurring schedules --- */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .5rem;
}
.page-header h1 { margin: 0; }

table.recurring-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  margin-top: 1rem;
}
table.recurring-table th,
table.recurring-table td {
  padding: .6rem .8rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}
table.recurring-table th {
  background: #f3f4f6;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #4b5563;
}
table.recurring-table tr:last-child td { border-bottom: 0; }
table.recurring-table tr.inactive { color: #9ca3af; background: #fafafa; }
table.recurring-table tr.inactive a { color: #6b7280; }
.recurring-meta { font-size: .8rem; color: #6b7280; margin-top: .15rem; }
.badge.active { background: #d1fae5; color: #065f46; }

.actions { white-space: nowrap; }
.actions form.inline { display: inline; margin: 0; }
.actions button.link {
  background: none;
  border: 0;
  color: #2563eb;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0 .35rem;
}
.actions button.link:hover { color: #1d4ed8; }

fieldset.interval-fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: .5rem 1rem;
  display: flex;
  gap: .5rem;
  align-items: center;
  max-width: 520px;
  margin: .65rem 0;
}
fieldset.interval-fieldset legend {
  font-weight: 600;
  color: #374151;
  padding: 0 .3rem;
  font-size: .85rem;
}
fieldset.interval-fieldset input[type=number] {
  width: 5em;
  margin: 0;
}
fieldset.interval-fieldset select { width: auto; margin: 0; }
fieldset.interval-fieldset span { color: #4b5563; }

/* --- Software licenses --- */

table.licenses-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  margin-top: 1rem;
}
table.licenses-table th,
table.licenses-table td {
  padding: .6rem .8rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: middle;
}
table.licenses-table th {
  background: #f3f4f6;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #4b5563;
}
table.licenses-table tr:last-child td { border-bottom: 0; }
table.licenses-table tbody tr { cursor: pointer; }
table.licenses-table tbody tr:hover { background: #f9fafb; }
table.licenses-table th.num, table.licenses-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.badge.expired   { background: #fee2e2; color: #991b1b; margin-left: .5rem; }
.badge.expiring  { background: #fef3c7; color: #78350f; margin-left: .5rem; }

.seats.full { color: #c2410c; font-weight: 600; }
.seats.over { color: #b91c1c; font-weight: 700; }

.key-masked {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
  color: #4b5563;
  background: #f3f4f6;
  padding: .1rem .4rem;
  border-radius: 3px;
}

/* --- License form --- */

.license-form { max-width: 640px; }
.license-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.license-form .row label { margin: .55rem 0 0; }
.license-form .key-field {
  display: flex;
  gap: .5rem;
  align-items: stretch;
  margin-top: .25rem;
}
.license-form .key-field input { flex: 1; margin-top: 0; }
.license-form .key-field button.link {
  background: #fff;
  border: 1px solid #cbd5e1;
  color: #1f2937;
  padding: 0 .9rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  font-size: .85rem;
}
.license-form .key-field button.link:hover { background: #f3f4f6; }

/* --- Event form --- */

.event-form { max-width: 520px; }
.event-form .hint { font-weight: 400; color: #6b7280; font-size: .8rem; }

/* --- Modal dialogs --- */

dialog.modal {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25), 0 4px 12px rgba(0,0,0,.1);
  padding: 1.25rem 1.5rem 1.1rem;
  max-width: 520px;
  width: calc(100% - 2rem);
  color: inherit;
  font: inherit;
}
dialog.modal::backdrop {
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
}
dialog.modal h2 {
  margin: 0 0 .75rem;
  font-size: 1.1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid #e5e7eb;
}
dialog.modal .event-form { max-width: 100%; }
dialog.modal .event-form label { margin: .55rem 0; }
dialog.modal .event-form input,
dialog.modal .event-form textarea { max-width: 100%; }
dialog.modal .created-meta {
  font-size: .8rem;
  color: #6b7280;
  margin: .75rem 0 0;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid #e5e7eb;
}
.modal-actions button.link {
  background: transparent;
  border: 0;
  color: #4b5563;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  padding: .4rem .5rem;
}
.modal-actions button.link:hover { color: #111827; text-decoration: underline; }
.modal-actions button.danger {
  margin-left: auto; /* push delete to the far right */
  background: #fff;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  padding: .45rem .9rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.modal-actions button.danger:hover { background: #fee2e2; }

.delete-form {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.delete-form button.danger {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}
.delete-form button.danger:hover { background: #fee2e2; }
.delete-form .created-meta { color: #6b7280; font-size: .85rem; }
