:root {
  --bg: #edf3f7;
  --panel: #ffffff;
  --text: #13212d;
  --muted: #5e7387;
  --line: #c8d6e4;
  --accent: #0a6d90;
  --accent-2: #064e67;
  --danger: #b83333;
  --ok: #216b3f;
  --shadow: 0 24px 42px rgba(17, 34, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 12%, #d5e9f5 0, transparent 34%),
    radial-gradient(circle at 93% 10%, #d5eee6 0, transparent 28%),
    var(--bg);
}

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

.auth-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2rem 2rem 1.8rem;
  box-shadow: var(--shadow);
  animation: fade-slide .4s ease-out;
}

.auth-card h1 {
  margin: 0 0 0.2rem;
  font-family: "Merriweather", Georgia, serif;
  font-size: 1.8rem;
}

.auth-card p {
  margin: 0.6rem 0 1.2rem;
  color: var(--muted);
}

.stack-form {
  display: grid;
  gap: 0.65rem;
}

label {
  font-weight: 600;
}

input,
select,
button,
.link-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: 2px solid rgba(10, 109, 144, 0.25);
  border-color: var(--accent);
}

button,
.link-btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button:hover,
.link-btn:hover {
  background: var(--accent-2);
}

button.secondary {
  background: #415a6b;
}

button.danger {
  background: var(--danger);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto auto auto;
  gap: 0.75rem;
  align-items: center;
  background: linear-gradient(135deg, #0e4f67, #0d3d52);
  color: #f8fdff;
  padding: 0.9rem 1rem;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 8px 20px rgba(8, 37, 52, 0.25);
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.toolbar-form {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.search-form {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.search-form input {
  min-width: 220px;
}

.search-form button {
  min-width: 42px;
  padding: 0.55rem 0.7rem;
}

.toolbar select {
  min-width: 220px;
}

.panel {
  padding: 1rem;
  animation: fade-slide .35s ease-out;
}

.pager {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.hidden-columns-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.52rem;
  border-radius: 999px;
  border: 1px solid #adc0d1;
  background: #eef5fb;
  color: #17445d;
  text-decoration: none;
  font-size: 0.85rem;
}

.chip:hover {
  background: #dceaf6;
}

.pager .link-btn {
  padding: 0.45rem 0.85rem;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: auto;
  max-height: calc(100vh - 200px);
  box-shadow: 0 10px 25px rgba(23, 41, 59, 0.08);
}

.actions-col {
  width: 76px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border: 1px solid var(--line);
  padding: 0.45rem;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #eaf3f9;
  z-index: 8;
  overflow: visible;
}

td {
  overflow: hidden;
}

.resizable-header {
  position: relative;
  user-select: none;
  min-width: 80px;
  overflow: visible;
}

.col-label {
  display: block;
  padding-right: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sort-indicator {
  position: absolute;
  right: 24px;
  top: 8px;
  color: #0f5f7e;
  font-size: 0.78rem;
}

.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
  touch-action: none;
}

.resize-handle::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 25%;
  height: 50%;
  width: 2px;
  background: #9db2c4;
}

tbody tr:nth-child(odd) {
  background: #f9fcfe;
}

tbody tr:hover {
  background: #edf6fb;
}

td input {
  width: 100%;
  min-width: 0;
}

body.resizing-cols,
body.resizing-cols * {
  cursor: col-resize !important;
  user-select: none !important;
}

.action-col {
  min-width: 72px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.icon-btn {
  border: 0;
  border-radius: 8px;
  background: #d9e8f3;
  color: #0d4359;
  cursor: pointer;
  padding: 0.38rem 0.54rem;
  min-width: 30px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.icon-btn:hover {
  background: #c4dded;
}

.row-action-menu {
  position: relative;
}

.row-action-menu summary {
  list-style: none;
}

.row-action-menu summary::-webkit-details-marker {
  display: none;
}

.row-action-popover {
  position: absolute;
  z-index: 6;
  left: 0;
  right: auto;
  top: 1.9rem;
  display: grid;
  gap: 0.35rem;
  min-width: 120px;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: 0 10px 18px rgba(18, 33, 48, 0.15);
}

.col-menu {
  position: absolute;
  right: 8px;
  top: 6px;
  z-index: 40;
}

.col-menu summary {
  list-style: none;
}

.col-menu summary::-webkit-details-marker {
  display: none;
}

.col-popover {
  position: absolute;
  right: 0;
  top: 1.7rem;
  min-width: 150px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 18px rgba(18, 33, 48, 0.15);
  padding: 0.35rem;
  display: grid;
  gap: 0.25rem;
  z-index: 50;
}

.col-popover a {
  color: #123648;
  text-decoration: none;
  padding: 0.36rem 0.48rem;
  border-radius: 6px;
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.col-popover a:hover {
  background: #ecf4fb;
}

.hidden-col {
  background: #dfe6ee !important;
  color: #6f7f8e;
}

th.hidden-col .col-label {
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

th.hidden-col .resize-handle {
  display: none;
}

td.hidden-col input {
  opacity: 0;
  pointer-events: none;
  width: 8px;
  padding: 0;
  border: 0;
}

.row-action-popover button {
  width: 100%;
  justify-content: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 0.9rem;
}

.messages li {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.35rem;
  border: 1px solid transparent;
}

.messages .error {
  background: #ffe9e9;
  border-color: #efb9b9;
}

.messages .success {
  background: #e9f7ee;
  border-color: #badfc8;
}

.messages .info {
  background: #e7f2fb;
  border-color: #bbd8f1;
}

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

  .toolbar select {
    min-width: 0;
    width: 100%;
  }

  .search-form input {
    min-width: 0;
    width: 100%;
  }
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
