/* Buttons, chips, inputs, panels, tables, sheets. */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-hi);
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .1s var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--mint); background: #1d212c; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.primary { background: linear-gradient(135deg, rgb(159 216 203 / .22), rgb(183 168 224 / .18)); border-color: rgb(159 216 203 / .6); box-shadow: 0 0 18px rgb(159 216 203 / .12); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 0 22px rgb(159 216 203 / .25); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { color: var(--pink); border-color: rgb(227 179 200 / .4); }
.btn.wide { width: 100%; justify-content: center; height: 40px; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 18px; line-height: 1;
  transition: color .15s, border-color .15s;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--mint); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  border: 1px solid var(--line-hi);
  font: 500 10.5px/1 var(--mono);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}
button.chip { cursor: pointer; transition: border-color .15s, color .15s; }
button.chip:hover { border-color: var(--text); color: var(--text); }
.chip.ok { color: var(--sage); border-color: rgb(184 207 160 / .45); }
.chip.warn { color: var(--peach); border-color: rgb(232 184 154 / .5); background: rgb(232 184 154 / .06); }
.chip.bad { color: var(--pink); border-color: rgb(227 179 200 / .5); }
.chip.info { color: var(--mint); border-color: rgb(159 216 203 / .45); }
.chip.live { color: var(--mint); border-color: rgb(159 216 203 / .6); box-shadow: 0 0 12px rgb(159 216 203 / .15); }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px var(--mint); animation: pulse 1.6s ease-in-out infinite; }

.sw { display: inline-block; width: 9px; height: 9px; background: var(--c); transform: rotate(45deg); flex: none; }

.delta { font: 500 11px var(--mono); padding: 1px 5px; border: 1px solid currentColor; opacity: .85; }
.delta.up { color: var(--sage); }
.delta.down { color: var(--pink); }
.delta.flat { color: var(--muted); }

/* Panels with a corner code. */
.panel {
  position: relative;
  background: linear-gradient(180deg, rgb(24 27 36 / .7), rgb(18 20 27 / .92));
  border: 1px solid var(--line);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 13px; font-weight: 600; letter-spacing: .02em; flex: 1; min-width: 0; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row-actions { display: flex; gap: 8px; }
.empty { padding: 22px 16px; color: var(--dim); font-size: 13px; }

.corner { position: absolute; width: 10px; height: 10px; pointer-events: none; }
.corner.tl { top: 6px; left: 6px; border-top: 1px solid var(--mint); border-left: 1px solid var(--mint); opacity: .7; }
.corner.br { right: 6px; bottom: 6px; border-right: 1px solid var(--lavender); border-bottom: 1px solid var(--lavender); opacity: .6; }

/* Avatars: a hex with initials, or the uploaded picture. */
.avatar { flex: none; display: inline-grid; place-items: center; position: relative; overflow: hidden;
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); }
.avatar.s { width: 26px; height: 24px; font-size: 10px; }
.avatar.m { width: 46px; height: 42px; font-size: 14px; }
.avatar.l { width: 92px; height: 84px; font-size: 26px; }
.avatar:not(.photo) { background: linear-gradient(140deg, color-mix(in srgb, var(--c) 34%, #12141b), color-mix(in srgb, var(--c) 12%, #12141b)); color: var(--c); font-family: var(--mono); font-weight: 500; letter-spacing: .04em; }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.link { color: var(--text); border-bottom: 1px dashed rgb(159 216 203 / .35); transition: color .15s, border-color .15s; }
.link:hover { color: var(--mint); border-bottom-color: var(--mint); }

/* Tables. */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; padding: 9px 12px;
  font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel);
}
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover, table.grid th.sorted { color: var(--mint); }
table.grid td { padding: 8px 12px; border-bottom: 1px solid rgb(37 42 55 / .6); vertical-align: middle; }
table.grid .n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.grid .center { text-align: center; }
table.grid tr.clickable { cursor: pointer; transition: background .12s; }
table.grid tr.clickable:hover td { background: rgb(159 216 203 / .045); }
table.grid tfoot td { border-top: 1px solid var(--line-hi); border-bottom: 0; font-weight: 600; color: var(--text); font-family: var(--mono); white-space: nowrap; }
.cell-main { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Ranked lines. */
.ranking { list-style: none; margin: 0; padding: 6px 0; }
.ranking li {
  display: grid; grid-template-columns: 22px auto 1fr auto; align-items: center; column-gap: 10px;
  padding: 7px 16px 9px; position: relative;
}
.ranking li:not(:has(.avatar)) { grid-template-columns: 22px 1fr auto; }
.ranking li.clickable { cursor: pointer; }
.ranking li.clickable:hover { background: rgb(159 216 203 / .04); }
.rank { color: var(--dim); }
.rank-name { min-width: 0; display: flex; flex-direction: column; }
.rank-name small { color: var(--dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { font-size: 13px; }
.rank-bar { grid-column: 2 / -1; height: 3px; background: rgb(37 42 55 / .7); margin-top: 6px; }
.rank-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--lavender)); box-shadow: 0 0 8px rgb(159 216 203 / .35); }
.rank-bar i.neg { background: var(--pink); }

/* Sheet (modal). */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgb(6 7 10 / .72);
  display: grid; place-items: center; padding: 16px;
  animation: enter .18s var(--ease);
}
.sheet {
  width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line-hi);
  box-shadow: 0 0 40px rgb(183 168 224 / .12);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.sheet-head h2 { flex: 1; font-size: 15px; font-weight: 600; }

/* Forms. */
.form { display: grid; gap: 14px; padding: 16px 18px 18px; }
.form.wide { max-width: none; }
.field { display: grid; gap: 6px; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input {
  width: 100%; height: 36px; padding: 0 10px;
  background: var(--inset); border: 1px solid var(--line-hi); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(-45deg, transparent 50%, var(--muted) 50%); background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
.input:focus { outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px rgb(159 216 203 / .12); }
.input.invalid { border-color: var(--pink); animation: glitch .25s linear 2; }
.input.num { font-family: var(--mono); }
input[type="date"].input { font-family: var(--mono); color-scheme: dark; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { width: 16px; height: 16px; border: 1px solid var(--line-hi); display: grid; place-items: center; flex: none; transition: border-color .15s, background .15s; }
.check input:checked + .box { border-color: var(--mint); background: rgb(159 216 203 / .2); box-shadow: 0 0 8px rgb(159 216 203 / .3); }
.check input:checked + .box::after { content: ""; width: 8px; height: 8px; background: var(--mint); }
.check input:focus-visible + .box { outline: 1px solid var(--mint); outline-offset: 2px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.shifts { display: grid; gap: 6px; }
.shift-row { display: grid; grid-template-columns: 1fr 110px auto; gap: 10px; align-items: center; }
.shift-row .input { height: 30px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; background: var(--c); clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); opacity: .55; transition: opacity .15s, transform .15s; }
.swatch.on, .swatch:hover { opacity: 1; transform: scale(1.12); }
.picker { display: flex; gap: 12px; align-items: center; }
.picker-preview { width: 96px; height: 72px; border: 1px dashed var(--line-hi); display: grid; place-items: center; overflow: hidden; flex: none; }
.picker-preview img { width: 100%; height: 100%; object-fit: cover; }
.picker-preview .placeholder { font-size: 11px; color: var(--dim); text-align: center; }
.picker-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%);
  padding: 10px 16px; background: var(--raised); border: 1px solid var(--mint);
  box-shadow: 0 0 20px rgb(159 216 203 / .2); font-size: 13px;
  animation: enter .2s var(--ease); transition: opacity .3s;
}
.toast.bad { border-color: var(--pink); box-shadow: 0 0 20px rgb(227 179 200 / .2); }
.toast.out { opacity: 0; }
