:root {
    --side-bg: #333;
    --side-active: #c5a47e;
    --primary: #1a73e8;
    --body-bg: #f4f7f9;
    --border: #ddd;
    --danger: #d93025;
  }

  body {
    font-family: 'Malgun Gothic', sans-serif;
    background: var(--body-bg);
    margin: 0;
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    scroll-behavior: smooth;
  }

  #initSection {
    position: fixed;
    width: 100%;
    height: 100%;
    background: #2c3e50;
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .login-card {
    background: white;
    padding: 45px;
    border-radius: 12px;
    width: 340px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
  }

  #loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 20000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .loading-box {
    background: white;
    padding: 30px 50px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }

  .spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    animation: spin 1s linear infinite;
  }

  @keyframes spin {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }

  #sidebar {
    width: 180px;
    background: var(--side-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
  }

  .logo-area {
    padding: 15px 10px;
    font-weight: bold;
    border-bottom: 1px solid #444;
    color: var(--side-active);
    text-align: center;
    font-size: 16px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .logo-area img {
    max-width: 90%;
    max-height: 90%;
  }

  .menu-item {
    padding: 15px 20px;
    cursor: pointer;
    font-size: 13px;
    color: #ccc;
    border-bottom: 1px solid #3d3d3d;
  }

  .menu-item.active {
    background: var(--side-active);
    color: #fff;
    font-weight: bold;
  }

  .menu-group {
    border-top: 1px solid #4a4a4a;
  }

  .menu-parent::after {
    content: '▾';
    float: right;
    color: #999;
  }

  .menu-parent.open::after {
    color: #fff;
  }

  .submenu-list {
    display: none;
    background: #2a2a2a;
  }

  .submenu-list.open {
    display: block;
  }

  .submenu-item {
    padding: 11px 20px 11px 34px;
    cursor: pointer;
    font-size: 13px;
    color: #bfc7cf;
    border-bottom: 1px solid #383838;
  }

  .submenu-item.active {
    background: #4b5563;
    color: #fff;
    font-weight: bold;
  }

  #content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
  }

  #header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 55px;
    flex-shrink: 0;
  }

  .tab {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-bottom: none;
    background: #fff;
    font-size: 13px;
    border-top: 3px solid var(--primary);
    font-weight: bold;
    color: var(--primary);
  }

  #main-scroll-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  .filter-bar {
    background: #fff;
    margin: 15px;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
  }

  .table-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin: 0 15px 15px 15px;
  }

  .table-container {
    flex: 1;
    overflow: auto;
  }

  .mobile-cards {
    display: none;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1300px;
    font-size: 13px;
  }

  th {
    background: #f8f9fa;
    padding: 12px;
    border-bottom: 2px solid #dee2e6;
    text-align: center;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: center;
    color: #444;
  }

  .pagination-container {
    padding: 15px;
    border-top: 1px solid #eee;
    text-align: center;
    background: #fff;
  }

  .page-btn {
    margin: 0 3px;
    padding: 5px 11px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
  }

  .page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: bold;
  }

  .asset-code {
    display: inline-block;
    min-width: 16ch;
    white-space: nowrap;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 13px;
    letter-spacing: 0.2px;
  }

  .modal-overlay {
    display: none;
    position: fixed;
    z-index: 15000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
  }

  .modal-window {
    background: #fff;
    margin: 3% auto;
    width: 950px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  }

  .modal-header {
    background: #3498db;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 16px;
  }

  .modal-body {
    padding: 20px;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 30px;
  }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
  }

  .form-group label {
    font-weight: bold;
    font-size: 13px;
    color: #333;
  }

  .input-field {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 2px;
    width: 100%;
    box-sizing: border-box;
    font-size: 13px;
    outline: none;
  }

  .input-field:focus {
    border-color: var(--primary);
  }

  .input-field.readonly {
    background: #f5f5f5;
    color: #888;
  }

  .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .filter-group>span {
    font-size: 13px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
  }

  .content-padding {
    padding: 0;
  }

  .header-user-info {
    font-size: 13px;
    color: #444;
  }

  #mobileMenuBtn,
  #mobileMenuClose {
    display: none;
  }

  .logout-link {
    color: var(--primary);
    cursor: pointer;
    font-weight: bold;
  }

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

  .admin-form-grid .full {
    grid-column: 1 / -1;
  }

  .btn {
    padding: 8px 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
  }

  .btn-primary {
    background: var(--primary);
    color: #fff;
  }

  .btn-success {
    background: #188038;
    color: #fff;
  }

  .bulk-edit-grid {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 10px 12px;
    align-items: center;
  }

  .bulk-edit-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: bold;
    color: #333;
  }

  .parts-modal-body {
    display: block;
    padding: 20px;
  }

  .parts-entry-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 12px;
  }

  .parts-entry-table th {
    position: static;
    top: auto;
    z-index: auto;
    white-space: nowrap;
  }

  .parts-entry-table td {
    padding: 8px;
    vertical-align: middle;
  }

  .parts-entry-table .input-field {
    padding: 7px 8px;
    font-size: 12px;
  }

  /* ===== 태블릿 모드 (768px ~ 1024px) ===== */
  @media (max-width: 1024px) {
    #sidebar {
      width: 150px;
    }

    .menu-list {
      font-size: 13px;
    }

    .filter-bar {
      flex-wrap: wrap;
      gap: 8px;
    }

    .filter-group {
      min-width: 100px;
    }

    .input-field {
      padding: 8px 6px;
      font-size: 12px;
    }

    .btn {
      padding: 8px 12px;
      font-size: 12px;
    }

    .table-container {
      font-size: 12px;
    }

    .pagination-container {
      font-size: 12px;
    }
  }

  /* ===== 모바일 모드 (480px ~ 768px) ===== */
  @media (max-width: 768px) {
    body {
      flex-direction: column;
      height: 100vh;
      overflow: hidden;
    }

    /* 로고 영역 스타일 */
    #sidebar {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 500;
      flex-direction: column;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }

    #sidebar.mobile-hidden {
      display: none !important;
    }

    #header {
      border-bottom: 1px solid #e0e0e0;
      padding: 0 12px;
      height: 54px;
      flex-shrink: 0;
      background: #fff;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }

    #header .tab {
      font-size: 16px;
      font-weight: 600;
      color: #222;
      border: none;
      padding: 0;
      background: transparent;
      flex: 1;
      text-align: left;
    }

    .header-user-info {
      font-size: 12px;
      white-space: nowrap;
    }

    #mobileMenuBtn {
      display: flex;
      background: none;
      border: 1px solid #ddd;
      font-size: 20px;
      cursor: pointer;
      padding: 0;
      color: #333;
      width: 40px;
      height: 40px;
      align-items: center;
      justify-content: center;
      border-radius: 6px;
      flex-shrink: 0;
      margin-right: 10px;
    }

    /* 로고 영역 스타일 */
    .logo-area {
      display: flex !important;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      height: auto;
      padding: 16px 20px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.12);
      flex-shrink: 0;
    }

    .logo-area img {
      max-height: 36px;
      max-width: 120px;
    }

    #mobileMenuClose {
      display: flex;
      background: rgba(255, 255, 255, 0.15);
      border: 1px solid rgba(255, 255, 255, 0.3);
      color: #fff;
      font-size: 20px;
      cursor: pointer;
      width: 42px;
      height: 42px;
      align-items: center;
      justify-content: center;
      border-radius: 8px;
      flex-shrink: 0;
    }

    .menu-list {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      padding: 14px;
      overflow: visible;
      width: auto;
    }

    .menu-item,
    .submenu-item {
      flex: unset;
      padding: 18px 10px;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.07);
      white-space: normal;
      text-align: center;
      font-size: 15px;
      font-weight: 500;
      color: #eee;
      min-height: 70px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.15s ease;
      scroll-snap-align: unset;
    }

    .menu-item:nth-child(2n),
    .submenu-item:nth-child(2n) {
      border-right: 1px solid rgba(255, 255, 255, 0.12);
    }

    .menu-item:nth-child(n+3),
    .submenu-item:nth-child(n+3) {
      border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .menu-item:active,
    .submenu-item:active {
      background: rgba(255, 255, 255, 0.18);
    }

    .menu-item.active,
    .submenu-item.active {
      background: var(--side-active);
      color: #fff;
      font-weight: 700;
      border-color: var(--side-active);
    }

    .menu-group {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    .menu-parent {
      grid-column: 1 / -1;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(255, 255, 255, 0.08);
      font-size: 13px;
      color: #aaa;
      padding: 10px 16px;
      min-height: 44px;
    }

    .submenu-list {
      position: static;
      top: auto;
      left: auto;
      min-width: unset;
      max-height: none;
      overflow: visible;
      background: transparent;
      grid-column: 1 / -1;
      display: none;
    }

    .submenu-list.open {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      flex-direction: unset;
    }

    #content-wrapper {
      display: flex;
      flex-direction: column;
      width: 100%;
      height: 100vh;
      overflow: hidden;
    }

    #main-scroll-area {
      width: 100%;
      overflow-x: auto;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      flex: 1;
    }

    .filter-bar {
      display: flex;
      flex-wrap: wrap;
      flex-direction: row;
      gap: 8px;
      padding: 12px;
      background: white;
      border-bottom: 1px solid #eee;
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    /* 로고 영역 스타일 */
    .filter-group {
      flex: 1 1 calc(50% - 4px);
      min-width: calc(50% - 4px);
    }

    /* 로고 영역 스타일 */
    .filter-group[style*="flex:1"] {
      flex: 1 1 100% !important;
      min-width: 100% !important;
    }

    .filter-group span {
      font-size: 12px;
      font-weight: 500;
      color: #555;
      margin-bottom: 4px;
      display: block;
    }

    .input-field {
      padding: 10px 12px;
      font-size: 13px;
      min-height: 40px;
      border: 1px solid #ddd;
      border-radius: 6px;
      -webkit-appearance: none;
      appearance: none;
    }

    .input-field:focus {
      border-color: var(--primary);
      outline: none;
      box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
    }

    /* 로고 영역 스타일 */
    .btn {
      padding: 10px 8px;
      font-size: 12px;
      white-space: nowrap;
      min-height: 40px;
      border-radius: 6px;
      transition: all 0.2s ease;
      -webkit-appearance: none;
      appearance: none;
      flex: 1 1 calc(50% - 4px);
      min-width: calc(50% - 4px);
    }

    .btn:active {
      transform: scale(0.98);
    }

    .btn-primary,
    .btn-success {
      padding: 10px 8px;
      min-height: 40px;
    }

    .filter-bar .btn {
      flex: 1 1 calc(50% - 4px);
      min-width: calc(50% - 4px);
    }

    .table-card {
      margin: 8px;
      border-radius: 8px;
      border: 1px solid #e8e8e8;
      background: white;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
      padding: 0;
    }

    .table-container {
      font-size: 12px;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      flex: none;
    }

    /* 카드 UI가 있는 화면만 테이블 숨김. 카드가 없는 화면은 가로 스크롤 테이블로 표시 */
    .has-mobile-cards table {
      display: none;
    }

    table {
      min-width: 700px;
      font-size: 12px;
    }

    th,
    td {
      padding: 9px 8px;
      white-space: nowrap;
    }

    .mobile-cards {
      display: block;
    }

    /* 로고 영역 스타일 */
    .asset-card {
      display: block;
      background: white;
      border: 1px solid #e8e8e8;
      border-radius: 8px;
      margin: 8px;
      padding: 12px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }

    .asset-card-row {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 8px;
      margin-bottom: 10px;
      padding-bottom: 10px;
      border-bottom: 1px solid #f0f0f0;
    }

    .asset-card-row:last-child {
      margin-bottom: 0;
      padding-bottom: 0;
      border-bottom: none;
    }

    .asset-card-cell {
      display: flex;
      flex-direction: column;
      font-size: 12px;
    }

    .asset-card-label {
      font-size: 10px;
      color: #999;
      margin-bottom: 2px;
      font-weight: 500;
    }

    .asset-card-value {
      font-size: 12px;
      color: #333;
      font-weight: 500;
      word-break: break-word;
    }

    .asset-card-btn {
      padding: 6px 4px;
      font-size: 11px;
      min-height: 32px;
      white-space: nowrap;
      flex: 1;
      min-width: 0;
      width: 100%;
    }

    .page-btn {
      padding: 8px 10px;
      font-size: 11px;
      min-height: 32px;
      border-radius: 4px;
      transition: all 0.2s ease;
    }

    .pagination-container {
      font-size: 12px;
      padding: 12px 8px;
      display: flex;
      gap: 6px;
      justify-content: center;
      flex-wrap: wrap;
    }

    .pagination-container button {
      padding: 6px 10px;
      min-height: 36px;
      border-radius: 4px;
    }

    .content-padding {
      padding: 10px;
    }

    .login-card {
      width: 90%;
      max-width: 320px;
      padding: 32px 24px;
      border-radius: 12px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }

    .login-card h2 {
      margin-bottom: 24px;
      font-size: 20px;
    }

    input[type="text"],
    input[type="password"],
    select,
    textarea {
      font-size: 16px;
      padding: 12px 14px;
      border-radius: 6px;
      border: 1px solid #ddd;
    }

    input[type="text"]:focus,
    input[type="password"]:focus,
    select:focus,
    textarea:focus {
      border-color: var(--primary);
      outline: none;
      box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
    }

    /* 모바일 모달: 풀스크린에 가깝게 (인라인 width를 이기기 위해 !important) */
    .modal-window {
      width: 100% !important;
      max-width: 100% !important;
      margin: 0 !important;
      height: 100vh;
      height: 100dvh;
      max-height: 100vh !important;
      max-height: 100dvh !important;
      border-radius: 0;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
    }

    .modal-body {
      grid-template-columns: 1fr;
      gap: 16px;
    }

    /* 자산 모달 내부 2단 레이아웃(인라인 스타일)을 1단으로 */
    .asset-modal-layout {
      grid-template-columns: 1fr !important;
    }

    .modal-header {
      padding: 16px;
      border-bottom: 1px solid #eee;
      font-weight: 600;
      font-size: 16px;
      flex-shrink: 0;
      position: sticky;
      top: 0;
      z-index: 5;
    }

    .modal-header button {
      font-size: 20px;
      line-height: 1;
      min-width: 44px;
      min-height: 44px;
    }

    .modal-body {
      padding: 16px;
      font-size: 13px;
    }

    .modal-body .input-field {
      margin-bottom: 12px;
      padding: 10px 12px;
      font-size: 14px;
    }

    .modal-footer {
      padding: 12px;
      gap: 8px;
      border-top: 1px solid #eee;
      display: flex;
      flex-wrap: wrap;
    }

    .modal-footer button {
      flex: 1;
      min-height: 40px;
      min-width: 100px;
      border-radius: 6px;
    }
  }

  /* ===== 소형 모바일 모드 (< 480px) ===== */
  @media (max-width: 480px) {
    .filter-bar {
      flex-direction: row;
      flex-wrap: wrap;
      gap: 6px;
      padding: 8px;
    }

    .filter-group {
      flex: 1 1 calc(50% - 3px);
      min-width: calc(50% - 3px);
    }

    .filter-group[style*="flex:1"] {
      flex: 1 1 100% !important;
      min-width: 100% !important;
    }

    .btn {
      padding: 8px 6px;
      font-size: 11px;
      min-height: 38px;
      flex: 1 1 calc(50% - 3px);
      min-width: calc(50% - 3px);
    }

    .filter-bar .btn {
      flex: 1 1 calc(50% - 3px);
      min-width: calc(50% - 3px);
    }

    .table-container {
      font-size: 11px;
    }

    table {
      min-width: 450px;
    }

    table th,
    table td {
      padding: 8px 6px;
    }

    .page-btn {
      padding: 6px 8px;
      font-size: 11px;
      min-height: 36px;
    }

    .content-padding {
      padding: 10px;
    }

    .table-card {
      margin: 8px;
      border-radius: 8px;
    }

    .login-card {
      width: 95%;
      max-width: 280px;
      padding: 24px 16px;
      border-radius: 12px;
    }

    .login-card h2 {
      font-size: 18px;
      margin-bottom: 20px;
    }

    .input-field {
      padding: 10px 12px;
      font-size: 14px;
      min-height: 40px;
      border-radius: 6px;
    }

    .modal-header {
      padding: 12px;
    }

    .modal-body {
      padding: 12px;
    }

    /* 소형 화면에서는 입력 필드를 한 줄에 하나씩 */
    .asset-field-grid,
    .admin-form-grid {
      grid-template-columns: 1fr !important;
    }
  }
}

/* Table Sorting Styles */
.sortable-header {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.2s ease;
}
.sortable-header:hover {
  background-color: rgba(0, 0, 0, 0.05) !important;
}
.sort-icon {
  margin-left: 6px;
  font-size: 11px;
  color: #888;
  transition: color 0.2s ease;
  display: inline-block;
}
.sortable-header:hover .sort-icon {
  color: #1a73e8;
}