:root {
  --page: #edf0f3;
  --panel: #ffffff;
  --line: #d3d9e0;
  --text: #263442;
  --muted: #718093;
  --blue: #4872a8;
  --blue-dark: #3b5f91;
  --link: #1d5fa8;
  --danger: #b23a3a;
  --success: #347b4d;
}

* {
  box-sizing: border-box;
}

html {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--page);
  font-size: 13px;
}

body {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  align-items: center;
  background: linear-gradient(#f8fafc, #e6ebf0);
  border: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 54px;
  padding: 8px 12px;
}

.topbar h1 {
  font-size: 16px;
  line-height: 1.1;
  margin: 0;
}

.topbar p {
  color: var(--muted);
  font-size: 11px;
  margin: 3px 0 0;
}

.account-nav {
  align-items: center;
  display: flex;
  gap: 12px;
}

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

a:hover {
  text-decoration: underline;
}

.tabs {
  align-items: stretch;
  background: #f7f8fa;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: flex;
  gap: 18px;
  min-height: 35px;
  padding: 0 12px;
}

.tab-item {
  align-items: center;
  cursor: grab;
  display: flex;
  min-width: 0;
}

.tab-item.dragging {
  opacity: 0.45;
}

.tab-item.drag-over {
  outline: 1px dashed var(--blue);
  outline-offset: 2px;
}

.tab-item > a {
  align-items: center;
  color: #607083;
  display: flex;
  font-size: 12px;
  padding-top: 2px;
}

.tab-item.active > a {
  color: var(--link);
  font-weight: 700;
}

.toolbar {
  align-items: center;
  background: var(--panel);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, max-content) minmax(180px, 1fr);
  gap: 10px;
  padding: 10px 12px;
}

.toolbar-menu {
  position: relative;
}

.toolbar-menu summary {
  align-items: center;
  background: #f7f9fb;
  border: 1px solid #c5ced8;
  border-radius: 3px;
  color: var(--link);
  cursor: pointer;
  display: flex;
  height: 28px;
  justify-content: center;
  list-style: none;
  width: 30px;
}

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

.toolbar-menu form {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(38, 52, 66, 0.16);
  padding: 6px;
  position: absolute;
  right: 0;
  top: 34px;
  z-index: 4;
}

.toolbar button,
.dialog-form button,
.auth-panel button,
.user-form button {
  background: #f7f9fb;
  border: 1px solid #c5ced8;
  border-radius: 3px;
  color: var(--link);
  cursor: pointer;
  min-height: 28px;
  padding: 5px 9px;
}

.toolbar button:hover,
.dialog-form button:hover,
.auth-panel button:hover,
.user-form button:hover {
  background: #edf4fb;
}

.page-actions {
  margin-top: 14px;
}

.button-link {
  align-items: center;
  background: #f7f9fb;
  border: 1px solid #c5ced8;
  border-radius: 3px;
  color: var(--link);
  display: inline-flex;
  min-height: 28px;
  padding: 5px 9px;
}

.button-link:hover {
  background: #edf4fb;
  text-decoration: none;
}

.search {
  grid-column: -2 / -1;
  justify-self: end;
  width: min(320px, 100%);
}

.toolbar .toolbar-menu button {
  background: transparent;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  min-height: 0;
  padding: 2px 4px;
}

.search input,
label input,
label select,
label textarea {
  background: #fff;
  border: 1px solid #d9dee5;
  border-radius: 2px;
  min-height: 29px;
  padding: 6px 8px;
  width: 100%;
}

.board {
  background: var(--panel);
  border: 1px solid var(--line);
  column-count: 3;
  column-gap: 12px;
  padding: 0 10px 14px;
}

.category-card {
  background: #fff;
  border: 1px solid #d8dde4;
  break-inside: avoid;
  display: inline-block;
  margin-top: 12px;
  width: 100%;
}

.category-card > header {
  align-items: center;
  background: linear-gradient(var(--blue), var(--blue-dark));
  color: #fff;
  display: flex;
  justify-content: space-between;
  min-height: 29px;
  padding: 0 8px;
}

.category-card h2 {
  font-size: 12px;
  line-height: 1.2;
  margin: 0;
}

.category-card details {
  position: relative;
}

.category-card summary {
  cursor: pointer;
  list-style: none;
}

.category-card summary::-webkit-details-marker {
  display: none;
}

.category-card details form {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(38, 52, 66, 0.16);
  padding: 6px;
  position: absolute;
  right: 0;
  top: 20px;
  z-index: 3;
}

.category-card details button,
.bookmark-list form button {
  background: transparent;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  padding: 2px 4px;
}

.bookmark-list {
  list-style: none;
  margin: 0;
  min-height: 42px;
  padding: 7px 7px 9px;
}

.bookmark-list li {
  align-items: flex-start;
  display: grid;
  gap: 5px;
  grid-template-columns: 16px 1fr 16px;
  min-height: 22px;
  padding: 2px 0;
}

.bookmark-list img {
  margin-top: 1px;
}

.bookmark-list a {
  color: #314255;
  display: block;
  min-width: 0;
}

.bookmark-list span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-list small {
  color: var(--muted);
  display: block;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-list .empty {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

dialog {
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(38, 52, 66, 0.24);
  padding: 0;
  width: min(420px, calc(100vw - 30px));
}

dialog::backdrop {
  background: rgba(38, 52, 66, 0.28);
}

.dialog-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.dialog-form header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.dialog-form h2,
.auth-panel h2,
.user-form h2,
.user-list h2 {
  font-size: 16px;
  margin: 0;
}

.dialog-form header button {
  color: var(--danger);
  min-height: 24px;
  padding: 0 7px;
}

label {
  color: #445468;
  display: grid;
  gap: 5px;
}

.auth-screen .shell {
  max-width: 460px;
}

.auth-screen .topbar {
  margin-bottom: 12px;
}

.auth-panel,
.user-form,
.user-list {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
}

.auth-panel form,
.user-form form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.form-error,
.flash {
  border: 1px solid;
  margin: 12px 0;
  padding: 9px 10px;
}

.form-error,
.flash.error {
  background: #fff5f5;
  border-color: #e4b5b5;
  color: var(--danger);
}

.flash.success {
  background: #f0fff5;
  border-color: #abd5bb;
  color: var(--success);
}

.admin-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 320px 1fr;
  margin-top: 14px;
}

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

.check input {
  width: auto;
}

table {
  border-collapse: collapse;
  margin-top: 12px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
}

th {
  background: #f5f7f9;
  font-size: 11px;
  text-transform: uppercase;
}

@media (max-width: 820px) {
  .board {
    column-count: 2;
  }

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

@media (max-width: 620px) {
  .shell {
    padding: 10px;
  }

  .topbar,
  .account-nav,
  .toolbar {
    align-items: stretch;
    display: grid;
  }

  .tabs {
    gap: 14px;
    overflow-x: auto;
  }

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

  .search {
    grid-column: auto;
    justify-self: stretch;
    width: 100%;
  }

  .board {
    column-count: 1;
  }
}
