: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; }


.save-status-banner { display:flex; flex-direction:column; gap:6px; padding:12px 14px; border-radius:12px; margin-bottom:14px; border:1px solid var(--line); }
.save-status-banner strong { font-size:1rem; }
.save-status-banner small { color:#475569; }
.save-status-synced { background:#ecfdf3; border-color:#86efac; color:#166534; }
.save-status-offline { background:#fff7ed; border-color:#fdba74; color:#9a3412; }
.save-status-conflict { background:#fff1f2; border-color:#fda4af; color:#9f1239; }
.save-status-fatal { background:#fef2f2; border-color:#fca5a5; color:#991b1b; }
.draft-recovery-banner { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:12px 14px; border-radius:12px; border:1px solid #cbd5e1; background:#f8fafc; margin-bottom:14px; }
.draft-recovery-actions { display:flex; gap:8px; flex-wrap:wrap; }


.work-live-status-bar { display:flex; flex-wrap:wrap; gap:8px; margin: 0 0 14px; }
.work-live-pill { display:inline-flex; align-items:center; gap:6px; padding:8px 12px; border-radius:999px; background:#f8fafc; border:1px solid #dbe4ef; font-size:.92rem; font-weight:700; }
.work-live-pill.is-online { background:#ecfdf3; border-color:#86efac; color:#166534; }
.work-live-pill.is-offline { background:#fff7ed; border-color:#fdba74; color:#9a3412; }
.work-live-pill.is-dirty { background:#fff1f2; border-color:#fda4af; color:#9f1239; }
.work-live-pill.is-clean { background:#eff6ff; border-color:#bfdbfe; color:#1d4ed8; }
.quick-chip-board { display:grid; gap:10px; margin-bottom:14px; }
.quick-chip-group { display:grid; gap:8px; }
.quick-chip-title { font-weight:800; color:#334155; font-size:.95rem; }
.quick-chip-list { display:flex; flex-wrap:wrap; gap:8px; }
.chip-action { background:#eef2ff; border-color:#c7d2fe; color:#3730a3; cursor:pointer; }
.chip-favorite { background:#fff7ed; border-color:#fdba74; color:#9a3412; cursor:pointer; }
.chip-recent { background:#eff6ff; border-color:#bfdbfe; color:#1d4ed8; cursor:pointer; }
.diagnostics-summary-grid { margin-bottom:16px; }
.work-table thead th { top: 0; z-index: 3; }
.work-table .sticky-col { position: sticky; background: inherit; z-index: 2; }
.work-table .sticky-col-1 { left: 0; min-width:70px; max-width:70px; }
.work-table .sticky-col-2 { left: 70px; min-width:250px; }
.work-table thead .sticky-col { z-index: 4; background:#eef3fb; }
body.ui-compact .work-table th, body.ui-compact .work-table td { padding: 6px 8px; }
body.ui-compact .btn { padding: 8px 11px; }
body.ui-compact .text-input, body.ui-compact .text-area, body.ui-compact select.text-input { padding: 7px 8px; }
body.ui-contrast { --bg:#eef2f7; --card:#ffffff; --text:#0f172a; --line:#94a3b8; }
body.ui-contrast .page-card, body.ui-contrast .summary-card, body.ui-contrast .form-card { box-shadow: 0 0 0 1px #94a3b8, 0 10px 24px rgba(15,23,42,.08); }
body.ui-contrast .work-table .cell-active { background:#93c5fd !important; box-shadow: inset 0 0 0 3px #1d4ed8; }
body.ui-contrast .work-table .grid-range-selected { background:#bfdbfe !important; box-shadow: inset 0 0 0 2px #2563eb; }
body.ui-contrast .notice.info { background:#dbeafe; color:#1e3a8a; border:1px solid #60a5fa; }
body.ui-contrast .notice.warning { background:#fffbeb; color:#92400e; border:1px solid #f59e0b; }

.global-banner { margin-bottom: .85rem; padding: 10px 14px; }
.compact-notice { padding: 10px 12px; margin-bottom: 10px; }
.compact-status-banner { padding: 10px 12px; margin-bottom: 10px; }
.draft-recovery-banner-compact { padding: 8px 12px; margin-bottom: 10px; }
.status-details-panel { display: grid; gap: 10px; margin-bottom: 10px; padding: 10px 12px; border: 1px solid #dbe4ef; border-radius: 14px; background: #fbfdff; }
.status-details-toolbar { display: flex; justify-content: flex-end; }
.chip-toggle { background:#f8fafc; border-color:#cbd5e1; color:#334155; cursor:pointer; }
.quick-chip-board-compact { margin-bottom: 0; }
.quick-chip-group-actions { padding-bottom: 2px; border-bottom: 1px dashed #dbe4ef; }
.grouped-toolbar-line { align-items: flex-end; gap: 12px; }
.toolbar-group { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.toolbar-group-label { font-size:.8rem; font-weight:800; color:#64748b; margin-right: 2px; }
.toolbar-group-core .toolbar-group-label { color:#1d4ed8; }
.toolbar-group-secondary .toolbar-group-label { color:#475569; }
.compact-save-meta { margin-left: auto; }
.work-header-card { gap: 10px; }
.work-header-card h1 { margin-bottom: 4px; }
.work-live-status-bar { margin-bottom: 10px; }
.work-summary-grid { margin-bottom: 12px; }
.quick-chip-list .chip { white-space: nowrap; }
.work-table thead th { background:#e8eef8; font-weight:800; border-bottom:2px solid #b8c7da; }
.work-table tbody tr:nth-child(even) td { background:#fbfdff; }
.work-table tbody tr:hover td { background:#f3f8ff; }
.work-table .grid-static-cell { background:#eef3f9; }
.work-table tr.row-key-active td { background:#eef6ff; }
.work-table .cell-active { background:#bfdbfe !important; box-shadow: inset 0 0 0 2px #1d4ed8; }
.work-table .grid-range-selected { background:#cfe3ff !important; box-shadow: inset 0 0 0 1px #2563eb; }
.diagnostics-kpi-grid .summary-card { min-height: 92px; }
.diagnostics-mini { font-size: 1.15rem; }
.diagnostics-detail-card { display: grid; gap: 14px; }
.diagnostics-section-block { display: grid; gap: 6px; }
.diagnostics-section-block p { margin: 0; }
@media (max-width: 900px) {
  .grouped-toolbar-line { align-items: stretch; }
  .toolbar-group { width: 100%; }
  .compact-save-meta { margin-left: 0; }
}


/* === sidebar restore patch START === */
.sidebar {
    display: flex;
    flex-direction: column;
}

.brand {
    margin-bottom: 18px;
}

.brand-title {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    display: none;
}

.nav-menu {
    flex: 1 1 auto;
}

.nav-menu-spacer {
    flex: 1 1 auto;
    min-height: 12px;
}

.sidebar-user-panel {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,.12);
}

.sidebar-user-label {
    font-size: .82rem;
    color: rgba(255,255,255,.65);
    margin-bottom: 8px;
}

.sidebar-user-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 10px;
}

.nav-link,
.nav-link-button {
    width: 100%;
    text-align: left;
    font-weight: 700;
}

.nav-link-button {
    border: none;
    background: transparent;
    cursor: pointer;
}

.nav-link.active,
.nav-link:hover,
.nav-link-button:hover {
    background: rgba(74, 130, 201, .28);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.10);
}
/* === sidebar restore patch END === */

