:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #1e2a39;
    --muted: #6b7280;
    --line: #d9e0ea;
    --primary: #2b579a;
    --primary-soft: #e8eef8;
    --danger: #c0392b;
    --warning: #fff3cd;
    --success-bg: #ecfdf3;
    --success-text: #166534;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --info-bg: #eff6ff;
    --info-text: #1d4ed8;
    --shadow: 0 8px 24px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Malgun Gothic", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { background: #1f2937; color: white; padding: 20px 16px; }
.brand { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-title { font-size: 1.35rem; font-weight: 700; }
.brand-subtitle { font-size: .9rem; opacity: .7; margin-top: 4px; }
.nav-menu { display: flex; flex-direction: column; gap: 8px; }
.nav-link { display: block; padding: 10px 12px; border-radius: 12px; color: rgba(255,255,255,.85); }
.nav-link.active, .nav-link:hover { background: rgba(255,255,255,.12); color: white; }
.content { padding: 24px; }

.page-grid { display: grid; gap: 16px; }
.page-card, .summary-card, .form-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; }
.mini-card { padding: 16px; }
.page-card h1, .page-card h3, .page-card h4 { margin-top: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 16px; }
.toolbar-stack { gap: 8px; }
.toolbar-line { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.field-inline, .field-label { display: inline-flex; flex-direction: column; gap: 6px; font-weight: 600; }
.field-inline span { font-size: .95rem; }

.text-input, .text-area, select.text-input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: white; font: inherit; }
.text-input:focus, .text-area:focus { outline: 2px solid rgba(43, 87, 154, .2); border-color: var(--primary); }
.text-right { text-align: right; }

.btn { border: none; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #eef2f7; color: #1f2937; }
.btn-light { background: #f7f9fc; color: #1f2937; border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: white; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.notice { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.notice.success { background: var(--success-bg); color: var(--success-text); }
.notice.error { background: var(--error-bg); color: var(--error-text); }
.notice.info { background: var(--info-bg); color: var(--info-text); }
.notice.warning { background: var(--warning); color: #8a6d3b; }

.summary-grid, .form-grid, .preset-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.summary-label { font-size: .9rem; color: var(--muted); }
.summary-value { font-size: 1.2rem; font-weight: 700; margin-top: 8px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 980px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
.data-table th { position: sticky; top: 0; background: #f7f9fc; z-index: 1; text-align: left; }
.data-table tbody tr:hover { background: #fbfdff; }
.warning-cell { background: var(--warning); color: #8a6d3b; font-weight: 700; }
.row-selected { background: #eef6ff; }
.row-empty { opacity: .75; }

.tab-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tab-button { border: 1px solid var(--line); background: white; padding: 10px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; }
.tab-button.active { background: var(--primary-soft); border-color: #b9cae7; color: var(--primary); }

.link-button { background: none; border: none; padding: 0; color: var(--primary); cursor: pointer; font: inherit; font-weight: 600; text-align: left; }
.row-action-group { display: flex; gap: 6px; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: #f4f6f9; border: 1px solid var(--line); }
.chip-remove { border: none; background: transparent; color: #666; cursor: pointer; font-size: 1rem; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 1000; }
.modal-panel { position: fixed; z-index: 1001; inset: 5% 10%; background: white; border-radius: 20px; box-shadow: var(--shadow); padding: 18px; overflow: auto; }
.modal-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 12px; }

.muted { color: var(--muted); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

@media (max-width: 1100px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 5; }
    .content { padding: 14px; }
    .modal-panel { inset: 2%; }
}


.global-banner { margin-bottom: 1rem; }
.diagnostic-pre { white-space: pre-wrap; word-break: break-word; margin: 0; font-family: Consolas, monospace; }
.diagnostic-small { font-size: 0.95rem; line-height: 1.4; }
.notice.warning { background: #fff6db; color: #7a5a00; border: 1px solid #e8d38a; }
.notice.warning a { color: inherit; text-decoration: underline; }

.keyboard-ux-notice {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
}

.work-table [data-grid-cell] {
    transition: background-color .12s ease, box-shadow .12s ease;
}

.work-table .grid-editor,
.work-table .grid-lot-button {
    min-height: 40px;
}

.work-table .cell-active {
    background: #eef6ff;
    box-shadow: inset 0 0 0 2px rgba(43, 87, 154, .22);
}

.work-table tr.row-key-active {
    background: #f8fbff;
}

.work-table .grid-lot-button {
    display: inline-flex;
    width: 100%;
    min-width: 120px;
    align-items: center;
    justify-content: flex-start;
    padding: 9px 10px;
    border-radius: 10px;
}

/* Work grid column resize */
.work-table {
  table-layout: fixed;
}

.work-table th {
  position: relative;
  user-select: none;
}

.work-table th .col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}

.work-table th.resizing,
.work-table th.resizing .col-resize-handle {
  cursor: col-resize;
}

.work-table th[data-col-key],
.work-table td[data-col-key] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* work grid column resize */
.work-table {
  table-layout: fixed;
}

.work-table th {
  position: relative;
  user-select: none;
}

.work-table th .col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}

.work-table th.resizing,
.work-table th.resizing .col-resize-handle {
  cursor: col-resize;
}

.work-table th,
.work-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* append to end of wwwroot/css/site.css */

.work-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.section-tabs-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.section-tabs-scroll {
  display: inline-flex;
  gap: 8px;
  min-width: max-content;
}

.work-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.mobile-only {
  display: none !important;
}

.desktop-only {
  display: block !important;
}

.work-mobile-list {
  display: none;
}

.work-mobile-card {
  border: 1px solid #dde5ee;
  border-radius: 14px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 10px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.work-mobile-card.is-filled {
  border-color: #bfd4ff;
}

.work-card-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.work-card-row-top {
  align-items: end;
}

.work-card-col {
  flex: 1 1 0;
  min-width: 0;
}

.work-card-col.full {
  flex: 1 1 100%;
}

.work-card-col-small {
  max-width: 72px;
}

.work-card-label {
  font-size: 0.82rem;
  color: #6b7280;
  margin-bottom: 4px;
}

.work-card-value {
  font-size: 1rem;
  color: #111827;
  word-break: break-word;
}

.work-card-actions {
  display: flex;
  gap: 8px;
}

.work-card-actions .btn {
  flex: 1 1 0;
}

.mobile-lot-button {
  width: 100%;
  text-align: left;
  white-space: normal;
  line-height: 1.4;
}

.warning-text {
  color: #b91c1c;
  font-weight: 700;
}

.work-toolbar-stack .work-toolbar-primary,
.work-toolbar-stack .work-toolbar-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

@media (min-width: 768px) and (max-width: 1199px) {
  .work-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: inline-flex !important;
  }

  .work-summary-grid {
    grid-template-columns: 1fr;
  }

  .work-mobile-list {
    display: grid;
    gap: 12px;
    margin-top: 12px;
  }

  .work-card-row {
    flex-direction: column;
  }

  .work-toolbar-stack .work-toolbar-primary,
  .work-toolbar-stack .work-toolbar-secondary {
    align-items: stretch;
  }

  .work-toolbar-stack .work-toolbar-primary > *,
  .work-toolbar-stack .work-toolbar-secondary > * {
    flex: 1 1 calc(50% - 8px);
  }

  .work-toolbar-stack .field-inline {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .work-toolbar-stack .work-toolbar-primary > *,
  .work-toolbar-stack .work-toolbar-secondary > * {
    flex: 1 1 100%;
  }
}



/* master lock */
.master-page-card {
    min-height: 420px;
}

.master-lock-panel {
    max-width: 640px;
    margin: 18px 0 22px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fbfdff;
    box-shadow: var(--shadow);
}

.master-lock-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.master-lock-desc {
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 14px;
}

.master-lock-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.master-lock-input {
    max-width: 240px;
    letter-spacing: 0.18em;
}

.master-lock-error {
    margin-top: 12px;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .master-lock-form {
        flex-direction: column;
        align-items: stretch;
    }

    .master-lock-input {
        max-width: none;
    }
}


.work-table { border-collapse: separate; border-spacing: 0; min-width: 1180px; background: #fff; }
.work-table thead th { background: #eef3fb; border-right: 1px solid #c1cddd; border-bottom: 1px solid #9fb2c9; font-weight: 700; }
.work-table tbody td { border-right: 1px solid #d4deeb; border-bottom: 1px solid #d4deeb; background: #fff; }
.work-table thead th:first-child, .work-table tbody td:first-child { border-left: 1px solid #d4deeb; }
.work-table tbody tr:hover td { background: #f8fbff; }
.work-table .grid-static-cell { background: #f7f9fc; font-weight: 600; }
.work-table .cell-active { background: #cfe2ff !important; box-shadow: inset 0 0 0 2px #2563eb; }
.work-table .grid-range-selected { background: #dbeafe !important; box-shadow: inset 0 0 0 1px #3b82f6; }
.work-table tr.row-key-active td { background: #eef6ff; }
.work-table tr.row-key-active td.cell-active { background: #cfe2ff !important; }
.work-table .grid-editor, .work-table .grid-lot-button { border: 1px solid #b7c6d8; border-radius: 9px; background: #fff; }
.work-table .grid-editor:focus, .work-table .grid-lot-button:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.work-table .row-action-group .btn { min-width: 58px; }
.table-wrap.work-table-wrap { border: 1px solid #b8c7da; border-radius: 14px; background: #fff; }
.keyboard-ux-notice { border: 1px solid #bfd4ff; }
body.grid-resizing { cursor: col-resize; user-select: none; }
