:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f3f5f7;
  color: #20262e;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f3f5f7;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
tr.selectable:focus-visible {
  outline: 3px solid rgb(15 118 110 / 28%);
  outline-offset: 1px;
}

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

.shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.title h1 {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.15;
}

.title p {
  margin: 5px 0 0;
  color: #69727d;
  font-size: 0.91rem;
}

.primary-button,
.secondary-button,
.danger-button,
.compact-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 680;
}

.primary-button {
  color: #ffffff;
  background: #176b5b;
}

.primary-button:hover:not(:disabled) {
  background: #11594c;
}

.secondary-button {
  color: #293944;
  background: #ffffff;
  border-color: #c9d1d8;
}

.secondary-button:hover:not(:disabled),
.compact-button:hover:not(:disabled) {
  background: #f0f4f3;
  border-color: #9facb3;
}

.danger-button {
  color: #a1242f;
  background: #fff5f5;
  border-color: #efc1c5;
}

.compact-button {
  min-height: 34px;
  padding: 6px 9px;
  color: #293944;
  background: #ffffff;
  border-color: #c9d1d8;
  font-size: 0.84rem;
}

.compact-button.danger-text {
  color: #a1242f;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(620px, 1.35fr) minmax(390px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.panel {
  overflow: hidden;
  border: 1px solid #d7dde2;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 4px 14px rgb(27 36 44 / 6%);
}

.editor-panel {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(230px, 330px);
  gap: 12px;
  align-items: center;
  padding: 13px;
  border-bottom: 1px solid #e3e7ea;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tab {
  min-height: 34px;
  border: 1px solid #ccd3d8;
  border-radius: 6px;
  padding: 6px 11px;
  color: #384751;
  background: #f7f8f9;
  font-size: 0.9rem;
  font-weight: 650;
}

.tab.active {
  color: #ffffff;
  border-color: #176b5b;
  background: #176b5b;
}

.search-field,
.search {
  width: 100%;
}

.search {
  min-height: 38px;
  border: 1px solid #c3ccd2;
  border-radius: 6px;
  padding: 8px 10px;
  color: #20262e;
  background: #ffffff;
}

.table-wrap {
  max-height: calc(100vh - 176px);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid #e9edef;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #59656f;
  background: #f8f9fa;
  font-size: 0.76rem;
  text-transform: uppercase;
}

tr.selectable {
  cursor: pointer;
}

tr.selectable:hover,
tr.selectable.active {
  background: #edf7f4;
}

tr.selectable:focus-visible {
  outline-offset: -3px;
}

.code-cell strong {
  display: block;
  color: #20262e;
}

.code-cell span,
td,
.editor-header p,
.sync-message,
.error {
  overflow-wrap: anywhere;
}

.muted {
  color: #6c7780;
}

.small {
  font-size: 0.84rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.status.pending {
  color: #704700;
  background: #fff0c2;
}

.status.active {
  color: #0b6047;
  background: #d9f3e8;
}

.status.expired {
  color: #9b2630;
  background: #f9dfe2;
}

.status.closed {
  color: #4f5963;
  background: #e9edf0;
}

.hours {
  min-width: 112px;
  white-space: nowrap;
}

.hours.over {
  color: #ad2f25;
  font-weight: 750;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid #e3e7ea;
}

.editor-header h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.25;
}

.editor-header p {
  margin: 4px 0 0;
  color: #69727d;
  font-size: 0.88rem;
}

.form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: #4f5963;
  font-size: 0.82rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid #c3ccd2;
  border-radius: 6px;
  padding: 8px 10px;
  color: #20262e;
  background: #ffffff;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid #e3e7ea;
  background: #f7f9f8;
}

.metric {
  min-width: 0;
  padding: 12px 16px;
  border-right: 1px solid #e0e5e3;
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  color: #69727d;
  font-size: 0.76rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
}

.warning {
  margin: 12px 16px 0;
  border: 1px solid #e8c58f;
  border-radius: 6px;
  padding: 9px 10px;
  color: #74420b;
  background: #fff8e8;
}

.error,
.sync-message {
  margin-bottom: 12px;
  border-radius: 6px;
  padding: 10px 12px;
}

.error {
  border: 1px solid #eab7bd;
  color: #982633;
  background: #fff3f4;
}

.sync-message {
  border: 1px solid #b8d5cd;
  color: #205b50;
  background: #eef8f5;
}

.empty {
  padding: 34px 18px;
  color: #69727d;
  text-align: center;
}

.empty.compact {
  padding: 18px 8px 8px;
}

.time-section {
  border-top: 1px solid #e3e7ea;
  padding: 16px;
}

.time-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.time-form,
.time-row {
  display: grid;
  grid-template-columns: 145px 90px minmax(140px, 1fr) auto;
  gap: 7px;
  align-items: center;
}

.time-row {
  margin-top: 8px;
}

.time-form input,
.time-row input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid #c3ccd2;
  border-radius: 6px;
  padding: 7px 9px;
}

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

  .editor-panel {
    position: static;
    max-height: none;
    overflow: hidden;
  }

  .workspace.editor-priority .editor-panel {
    order: -1;
  }

  .table-wrap {
    max-height: 62vh;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(calc(100vw - 20px), 1500px);
    padding-top: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1 1 140px;
  }

  .toolbar,
  .form-grid,
  .time-form,
  .time-row {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric {
    padding: 10px;
  }

  .metric strong {
    font-size: 0.94rem;
  }

  .title h1 {
    font-size: 1.55rem;
  }
}

@media (max-width: 380px) {
  .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab {
    width: 100%;
    padding-inline: 5px;
  }

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

  .metric {
    border-right: 0;
    border-bottom: 1px solid #e0e5e3;
  }

  .metric:last-child {
    border-bottom: 0;
  }
}

/* Auth gate overlay */
.auth-gate {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 14, 23, 0.82);
    backdrop-filter: blur(3px);
}

.auth-card {
    width: min(22rem, 90vw);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    background: #141a26;
    border: 1px solid #2a3444;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.auth-card h1 {
    margin: 0;
}

.auth-card a.primary-button {
    display: block;
    text-decoration: none;
}

.user-chip {
    align-self: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: #1b2333;
    border: 1px solid #2a3444;
    font-size: 0.85rem;
    color: #c9d4e6;
}

.topbar-actions .secondary-button.active {
    background: #176b5b;
    color: #ffffff;
    border-color: #176b5b;
}
