:root {
  --ui-page: #f5f7fa;
  --ui-panel: #fff;
  --ui-surface: #edf3f6;
  --ui-text: #243746;
  --ui-muted: #596e7e;
  --ui-divider: #d5dfe7;
  --ui-border: #bccbd6;
  --ui-control: #e8eaee;
  --ui-control-border: #a8b1be;
  --ui-control-hover: #dce2ea;
  --ui-active: #dfebf8;
  --ui-accent: #3f70a4;
  --ui-green: #145f55;
  --ui-primary: #d8e8f8;
  --ui-primary-border: #789bc2;
  --ui-primary-text: #224e79;
  --ui-primary-hover: #cbdff4;
  --ui-error: #963647;
  --ui-error-bg: #fcebed;
  --ui-focus: #156db2;
  --ui-appbar: #1f3647;
  --ui-appbar-line: #5b778c;
  --ui-tabstrip: #dbe4eb;
  color-scheme: light;
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--ui-text);
  background: var(--ui-page);
}

* { box-sizing: border-box; }
body { margin: 0; }

.app-bar,
main {
  padding-inline: max(20px, calc((100% - 1560px) / 2));
}

.app-bar, .app-title, .work-bar, .fields, .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-bar {
  justify-content: space-between;
  min-height: 64px;
  padding-block: 12px;
  background: var(--ui-appbar);
  color: var(--ui-panel);
}

.app-title { gap: 12px; flex-wrap: wrap; }
.brand {
  border-right: 1px solid var(--ui-appbar-line);
  padding-right: 12px;
  color: #c9d8e3;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
}

h1, h2 { font-weight: 600; }
h1 { margin: 0; font-size: 18px; }
h2 { margin: 0 0 12px; font-size: 16px; }
main { padding-block: 16px 24px; }

#status { margin: 0; color: var(--ui-green); }
#status:not(:empty) { margin-bottom: 12px; }
#status[data-error], #detail-content [data-error] {
  padding: 8px 12px;
  border-radius: 5px;
  color: var(--ui-error);
  background: var(--ui-error-bg);
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--ui-divider);
  border-radius: 8px;
  background: var(--ui-panel);
}

#login { max-width: 420px; margin: 24px auto; }
#workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.forms { display: grid; gap: 12px; align-items: start; }
form { display: grid; gap: 8px; }
form + form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ui-divider);
}

label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--ui-border);
  border-radius: 5px;
  background: var(--ui-panel);
  padding: 4px 8px;
}
input[type="checkbox"] { margin: 0; accent-color: var(--ui-accent); }
textarea { min-height: 7rem; }

button {
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--ui-control-border);
  border-radius: 5px;
  background: var(--ui-control);
  cursor: pointer;
  justify-self: start;
}
button:not(:disabled):hover { background: var(--ui-control-hover); }
button:disabled { cursor: wait; opacity: .6; }
:where(button, input, select, textarea, .table-wrap):focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 2px;
}
.app-bar button {
  border-color: var(--ui-appbar-line);
  background: transparent;
  color: #e3edf4;
}
.app-bar button:not(:disabled):hover { background: #2c4a5f; }
.primary {
  border-color: var(--ui-primary-border);
  background: var(--ui-primary);
  color: var(--ui-primary-text);
  font-weight: 600;
}
.primary:not(:disabled):hover { background: var(--ui-primary-hover); }
.fields { align-items: end; }
.fields > label { flex: 1; min-width: 0; }
.actions { flex-wrap: wrap; gap: 6px; }

.licenses { padding: 0; }
.work-bar {
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--ui-divider);
  border-radius: 7px 7px 0 0;
  background: var(--ui-tabstrip);
}
.work-bar h2 { margin: 0; }
.license-view-bar, .license-views, .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.license-view-bar {
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--ui-divider);
}
.license-views button[aria-pressed="true"] {
  border-color: var(--ui-accent);
  background: var(--ui-active);
  color: var(--ui-primary-text);
  font-weight: 600;
}
.checkbox-label { cursor: pointer; }
.checkbox-label span { overflow-wrap: anywhere; }
.license-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 136px), 1fr));
  padding: 8px 12px 12px;
  border-bottom: 1px solid var(--ui-divider);
  background: var(--ui-surface);
}
#license-count {
  margin: 0;
  padding: 8px 12px;
  color: var(--ui-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.table-wrap {
  max-height: min(62vh, 560px);
  overflow: auto;
  border-block: 1px solid var(--ui-divider);
}
table {
  width: 100%;
  min-width: 850px;
  border-spacing: 0;
  text-align: left;
  font-size: 13px;
}
th, td { padding: 8px; border-bottom: 1px solid var(--ui-divider); }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--ui-surface);
  font-weight: 600;
  white-space: nowrap;
}
td { overflow-wrap: anywhere; }
td:first-child, th:first-child { text-align: center; }
.license-state, .license-product, .license-period { white-space: nowrap; }
.license-customer, .license-project { min-width: 104px; word-break: keep-all; }
.license-period { font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--ui-page); }
tbody tr:has(input:checked) { background: var(--ui-active); }

.license-label { min-width: 7rem; max-width: 14rem; }
.pc-status {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--ui-divider);
  border-radius: 999px;
  color: var(--ui-muted);
  background: var(--ui-page);
  font-weight: 600;
  white-space: nowrap;
}
.pc-status[data-connected] {
  border-color: #9fc5be;
  color: var(--ui-green);
  background: #e6f2ef;
}
td .actions { flex-wrap: nowrap; }
td button { min-height: 28px; padding-inline: 8px; white-space: nowrap; }

#admin-list { margin: 12px 0 0; padding-inline-start: 16px; }
#admin-list li { overflow-wrap: anywhere; }
#admin-list li + li { margin-top: 8px; }

dialog {
  width: min(31rem, 90vw);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 16px;
  color: var(--ui-text);
  background: var(--ui-panel);
  box-shadow: 0 12px 32px #24374626;
}
dialog::backdrop { background: #1f364780; }
dialog form[method="dialog"] { float: right; margin: 0 0 8px 8px; }
#detail-content { clear: both; }
.dialog-note { margin: 0; color: var(--ui-muted); font-size: 13px; }
.customer-visibility {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-height: min(45vh, 20rem);
  margin: 0;
  padding: 8px 12px 12px;
  overflow: auto;
  border: 1px solid var(--ui-divider);
  border-radius: 5px;
}
.customer-visibility legend { padding-inline: 4px; }

[hidden] { display: none !important; }

@media (max-width: 1180px) {
  #workspace { grid-template-columns: minmax(0, 1fr); }
  .forms { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 660px) {
  .app-bar, main { padding-inline: 12px; }
  .forms { grid-template-columns: minmax(0, 1fr); }
}
