:root {
  --skud-sidebar: 240px;
  --skud-border: #dee2e6;
  --skud-muted: #6c757d;
  --skud-accent: #0d6efd;
}

html, body {
  height: 100%;
}

body {
  background: #fff;
  color: #212529;
  font-size: 14px;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--skud-border);
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--skud-sidebar);
  background: #fff;
  border-right: 1px solid var(--skud-border);
  display: flex;
  flex-direction: column;
  z-index: 1030;
}

.sidebar-brand {
  padding: 18px 20px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--skud-border);
}

.sidebar-brand .sidebar-logo {
  display: block;
  width: 132px;
  max-width: 100%;
  height: auto;
  margin: 0 0 10px;
}

.sidebar-brand .sidebar-brand-text {
  padding-left: 10px;
}

.sidebar-brand small {
  display: block;
  color: var(--skud-muted);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
}

.sidebar-brand .sidebar-version {
  margin-top: 3px;
  font-size: 10px;
  opacity: 0.8;
  font-family: var(--bs-font-monospace);
}

.sidebar-nav {
  padding: 10px 8px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-nav .nav-link {
  color: #343a40;
  border-radius: 6px;
  padding: 9px 12px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav .nav-link:hover {
  background: #f1f3f5;
}

.sidebar-nav .nav-link.active {
  background: #e7f1ff;
  color: #0a58ca;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid var(--skud-border);
  padding: 10px 12px;
}

.main {
  margin-left: var(--skud-sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: #fff;
  border-bottom: 1px solid var(--skud-border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.content {
  padding: 18px 20px 40px;
  flex: 1;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 22px;
  margin: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-wrap {
  border: 1px solid var(--skud-border);
  border-radius: 6px;
  overflow: auto;
  max-height: calc(100vh - 210px);
  background: #fff;
}

.skud-table {
  margin: 0;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
}

.skud-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f8f9fa;
  border-bottom: 1px solid var(--skud-border);
  white-space: nowrap;
  vertical-align: middle;
  padding: 6px 8px;
  font-weight: 600;
}

.skud-table td {
  padding: 5px 8px;
  vertical-align: middle;
  border-color: var(--skud-border);
  white-space: nowrap;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skud-table td.cell-comment,
.skud-table td.cell-text {
  white-space: normal;
  min-width: 220px;
}

.skud-table tbody tr {
  cursor: default;
}

.skud-table tbody tr.row-active {
  background: #e7f1ff;
}

.skud-table tbody tr.row-deleted td {
  text-decoration: line-through;
  color: var(--skud-muted);
  opacity: 0.7;
}

.skud-table tbody tr.row-due-warning > td {
  background-color: #f08c00 !important;
  color: #212529;
}

.skud-table tbody tr.row-due-danger > td {
  background-color: #ec6f6f !important;
  color: #212529;
}

.skud-table tbody tr.row-due-warning.row-active > td,
.skud-table tbody tr.row-due-danger.row-active > td {
  color: #212529;
}

.skud-table td.has-note {
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.skud-table tbody tr.row-draft {
  background: #fff8e1;
}

.skud-table td.cell-active {
  outline: 2px solid var(--skud-accent);
  outline-offset: -2px;
}

.th-inner {
  display: flex;
  align-items: center;
  gap: 4px;
}

.th-inner .th-label {
  flex: 1;
}

.th-btn {
  border: 0;
  background: transparent;
  color: var(--skud-muted);
  padding: 2px 4px;
  line-height: 1;
  border-radius: 3px;
}

.th-btn:hover,
.th-btn.active {
  color: var(--skud-accent);
  background: #e7f1ff;
}

.th-btn .filter-count {
  font-size: 9px;
  vertical-align: super;
}

.action-col {
  position: sticky;
  right: 0;
  background: inherit;
  z-index: 4;
  box-shadow: -1px 0 0 var(--skud-border);
}

.skud-table thead .action-col {
  background: #f8f9fa;
  z-index: 6;
}

.row-actions {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
}

.row-actions .btn {
  --bs-btn-padding-y: 0.12rem;
  --bs-btn-padding-x: 0.35rem;
  --bs-btn-font-size: 0.78rem;
}

.cell-editor {
  width: 100%;
  min-width: 90px;
  border: 1px solid var(--skud-accent);
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 13px;
  background: #fff;
}

textarea.cell-editor {
  min-height: 64px;
}

.fk-editor {
  position: relative;
  min-width: 180px;
}

.fk-editor input {
  width: 100%;
}

.fk-options {
  position: fixed;
  z-index: 2500;
  min-width: 240px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--skud-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.fk-option {
  padding: 4px 8px;
  cursor: pointer;
}

.fk-option:hover,
.fk-option.active {
  background: #e7f1ff;
}

.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid #adb5bd;
  border-radius: 3px;
  vertical-align: -2px;
  margin-right: 5px;
}

.deleted-mark {
  font-size: 10px;
  color: var(--skud-muted);
  margin-left: 3px;
}

.load-sentinel {
  height: 1px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--skud-muted);
  font-size: 12px;
  padding: 8px 2px;
}

.filter-popover {
  position: fixed;
  z-index: 2000;
  width: 300px;
  background: #fff;
  border: 1px solid var(--skud-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  padding: 10px;
}

.filter-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 4px;
}

.filter-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  margin: 0;
  border-radius: 3px;
  cursor: pointer;
}

.filter-list label:hover {
  background: #f8f9fa;
}

.filter-list .count {
  margin-left: auto;
  color: var(--skud-muted);
  font-size: 11px;
}

.skud-dialog {
  border: 0;
  border-radius: 8px;
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.skud-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.toast-container {
  z-index: 3000;
}

.sidebar-backdrop {
  display: none;
}

.muted {
  color: var(--skud-muted);
}

.nowrap {
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1025;
  }

  .table-wrap {
    max-height: none;
  }
}
