:root{
  --primary:#3182f6;
  --primary-hover:#2272eb;
  --canvas:#ffffff;
  --fg:#191f28;
  --body-c:#4e5968;
  --muted:#8b95a1;
  --surface:#f2f4f6;
  --border:#e5e8eb;
  --on-primary:#ffffff;
  --weak-bg:#e8f3ff;
  --weak-fg:#1b64da;
  --danger:#e42939;
  --danger-weak-bg:#fde8ea;
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--surface);
  color:var(--fg);
  font-family:"Toss Product Sans","Pretendard",-apple-system,BlinkMacSystemFont,"Malgun Gothic",sans-serif;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{margin:0; font-weight:600; color:var(--fg);}
p{margin:0;}
.hidden{display:none !important;}

/* ---------- shell / topbar ---------- */
.topbar{
  height:56px; background:var(--canvas); border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; padding:0 20px;
  position:sticky; top:0; z-index:10;
}
.brand{
  font-size:17px; font-weight:700; color:var(--fg); cursor:pointer; user-select:none;
  display:flex; align-items:center; gap:6px;
  text-decoration:none;
}
.brand:hover{color:var(--primary);}
.brand .dot{width:8px;height:8px;border-radius:50%;background:var(--primary);}
.topbar-right{display:flex; align-items:center; gap:14px; font-size:14px; color:var(--body-c);}
.user-link{cursor:pointer; color:var(--body-c); font-weight:600; text-decoration:none;}
.user-link:hover{color:var(--primary);}
.logout-link{cursor:pointer; color:var(--muted); background:none; border:none; font-family:inherit; font-size:inherit;}
.logout-link:hover{color:var(--fg);}

main{max-width:1600px; margin:0 auto; padding:40px 48px 96px;}

/* ---------- buttons (TDS button spec) ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  border:none; cursor:pointer; font-family:inherit; font-weight:600;
  background:var(--surface); color:var(--fg); transition:background .12s ease;
  text-decoration:none;
}
.btn:hover{background:#e9ebee;}
.btn:active{transform:scale(0.98);}
.btn-md{height:38px; padding:0 16px; border-radius:10px; font-size:14px;}
.btn-lg{height:48px; padding:0 20px; border-radius:14px; font-size:16px;}
.btn-xl{height:56px; padding:0 20px; border-radius:16px; font-size:17px;}
.btn-sm{height:32px; padding:0 12px; border-radius:8px; font-size:13px;}
.btn-primary{background:var(--primary); color:var(--on-primary);}
.btn-primary:hover{background:var(--primary-hover);}
.btn-danger-weak{background:var(--danger-weak-bg); color:var(--danger);}
.btn-danger-weak:hover{background:#fbd7db;}
.btn-full{width:100%;}
.btn-disabled{opacity:.45; cursor:not-allowed;}

/* ---------- form controls ---------- */
label.field-label{display:block; font-size:13px; color:var(--body-c); font-weight:600; margin-bottom:6px;}
.input, select.input, input[type="date"].input{
  width:100%; height:48px; border:1px solid var(--border); border-radius:10px;
  padding:0 14px; font-size:15px; font-family:inherit; color:var(--fg); background:var(--canvas);
  outline:none; transition:border-color .12s ease;
}
.input:focus, select.input:focus{border-color:var(--primary);}
textarea.input{height:auto; min-height:76px; padding:12px 14px; resize:vertical;}
.input::placeholder{color:var(--muted);}
.field{margin-bottom:16px;}
.row-2{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.row-3{display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px;}

/* ---------- badge (dept pill) ---------- */
.badge{
  display:inline-block; font-size:12px; font-weight:600; padding:3px 10px; border-radius:20px;
  background:var(--weak-bg); color:var(--weak-fg);
}

/* ---------- card / panel ---------- */
.card{background:var(--canvas); border:1px solid var(--border); border-radius:16px; padding:24px; margin-bottom:20px;}
.card-title{font-size:15px; font-weight:700; color:var(--fg); margin-bottom:16px; display:block;}

/* ---------- table ---------- */
table{width:100%; border-collapse:collapse; font-size:14px; table-layout:fixed;}
th{
  text-align:left; font-size:12px; font-weight:600; color:var(--muted);
  padding:10px 16px; border-bottom:1px solid var(--border);
}
td{padding:12px 16px; border-bottom:1px solid var(--border); color:var(--fg); vertical-align:middle;}
tr:last-child td{border-bottom:none;}
.proj-link{color:var(--fg); font-weight:600; cursor:pointer; text-decoration:none;}
.proj-link:hover{color:var(--primary);}
.row-actions{display:flex; gap:6px; flex-wrap:nowrap; white-space:nowrap;}
.row-actions form{display:inline;}
.empty-note{font-size:13px; color:var(--muted); padding:24px 0; text-align:center;}

/* ---------- filter bar ---------- */
.filter-bar{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:10px; align-items:flex-end;}
.filter-bar .field{margin-bottom:0; flex:1; min-width:150px;}
.quick-range{display:flex; gap:8px; margin:12px 0 20px;}

/* ---------- dropzone ---------- */
.dropzone{
  border:1.5px dashed var(--border); border-radius:14px; padding:36px 16px;
  text-align:center; background:var(--surface); cursor:pointer; margin-bottom:14px;
}
.dropzone:hover{border-color:var(--primary); background:var(--weak-bg);}
.dropzone .icon{font-size:26px; color:var(--muted); margin-bottom:8px;}
.dropzone .main-txt{font-size:14px; color:var(--fg); font-weight:600;}
.dropzone .sub-txt{font-size:12px; color:var(--muted); margin-top:4px;}
.progress-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  border:1px solid var(--border); border-radius:10px; padding:10px 14px; font-size:13px; color:var(--body-c);
}
.progress-bar{flex:1; height:6px; background:var(--surface); border-radius:3px; overflow:hidden; margin:0 12px;}
.progress-bar-fill{height:100%; background:var(--primary); width:0%; transition:width .25s ease;}

/* ---------- auth screens ---------- */
.auth-wrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px;
}
.auth-card{width:360px; background:var(--canvas); border:1px solid var(--border); border-radius:20px; padding:32px 28px;}
.auth-logo{text-align:center; font-size:19px; font-weight:700; margin-bottom:6px;}
.auth-logo .dot{display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--primary); margin-right:6px;}
.auth-sub{text-align:center; font-size:13px; color:var(--muted); margin-bottom:24px;}
.auth-note{font-size:12px; color:var(--muted); text-align:center; line-height:1.6; margin-top:14px;}
.error-text{font-size:12px; color:var(--danger); margin-top:6px; display:none;}

/* ---------- modal ---------- */
.modal-overlay{
  position:fixed; inset:0; background:rgba(25,31,40,.32);
  display:flex; align-items:center; justify-content:center; z-index:100;
}
.modal{
  width:400px; max-width:90vw; background:var(--canvas); border-radius:18px; padding:26px;
  max-height:86vh; overflow-y:auto;
}
.modal h3{font-size:16px; margin-bottom:18px;}
.link-box{
  display:flex; align-items:center; gap:8px; border:1px solid var(--border); border-radius:10px;
  padding:10px 12px; font-size:12px; color:var(--body-c); background:var(--surface);
  margin:6px 0 18px; word-break:break-all;
}
.option-row{display:flex; align-items:center; justify-content:space-between; padding:10px 0; border-bottom:1px solid var(--border); font-size:14px;}
.option-row:last-of-type{border-bottom:none;}
.switch{width:36px; height:20px; border-radius:10px; background:var(--border); position:relative; cursor:pointer; transition:background .15s;}
.switch.on{background:var(--primary);}
.switch::after{content:""; position:absolute; top:2px; left:2px; width:16px; height:16px; border-radius:50%; background:#fff; transition:left .15s;}
.switch.on::after{left:18px;}
.modal-footer{display:flex; justify-content:flex-end; gap:8px; margin-top:20px;}
.purpose-box{margin-top:6px;}

/* ---------- toast ---------- */
.toast{
  position:fixed; bottom:28px; left:50%; transform:translateX(-50%);
  background:var(--fg); color:#fff; padding:12px 20px; border-radius:10px; font-size:13px;
  z-index:200; opacity:0; pointer-events:none; transition:opacity .2s ease;
}
.toast.show{opacity:1;}

.section-title{font-size:20px; font-weight:700; margin-bottom:18px;}

/* ---------- table wrapper for horizontal scroll on small screens ---------- */
.table-scroll{width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch;}
.table-scroll table{min-width:760px;}

/* ---------- view toggle (리스트형 / 갤러리형) ---------- */
.view-toggle{display:inline-flex; border:1px solid var(--border); border-radius:10px; padding:3px; gap:2px; background:var(--canvas);}
.view-toggle a, .view-toggle button{
  border:none; background:transparent; cursor:pointer; font-family:inherit; font-weight:600; font-size:13px;
  color:var(--muted); padding:6px 14px; border-radius:8px; transition:background .12s ease, color .12s ease;
  text-decoration:none; display:inline-block;
}
.view-toggle a.active, .view-toggle button.active{background:var(--primary); color:var(--on-primary);}

/* ---------- thumbnail (list & gallery) ---------- */
.thumb{
  width:40px; height:40px; border-radius:8px; background:var(--surface); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center; overflow:hidden; flex-shrink:0; font-size:16px; color:var(--muted);
}
.thumb img{width:100%; height:100%; object-fit:cover; display:block;}
.name-cell{display:flex; align-items:center; gap:10px;}

/* ---------- gallery grid ---------- */
.gallery{display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:16px;}
.gallery-card{background:var(--canvas); border:1px solid var(--border); border-radius:16px; overflow:hidden; display:flex; flex-direction:column;}
.gallery-thumb{
  width:100%; aspect-ratio:4/3; background:var(--surface); display:flex; align-items:center; justify-content:center;
  font-size:34px; color:var(--muted); overflow:hidden;
}
.gallery-thumb img{width:100%; height:100%; object-fit:cover; display:block;}
.gallery-body{padding:14px; display:flex; flex-direction:column; gap:6px; flex:1;}
.gallery-name{font-size:14px; font-weight:700; color:var(--fg); cursor:pointer; text-decoration:none;}
.gallery-name:hover{color:var(--primary);}
.gallery-meta{font-size:12px; color:var(--muted); display:flex; align-items:center; gap:6px; flex-wrap:wrap;}
.gallery-actions{display:flex; flex-wrap:wrap; gap:6px; margin-top:8px;}
.gallery-actions form{display:inline;}

/* ---------- pagination ---------- */
.tosk-pagination{display:flex; justify-content:center; gap:6px; margin-top:24px; list-style:none; padding:0;}
.tosk-pagination li{display:inline-block;}
.tosk-pagination a, .tosk-pagination span{
  display:inline-flex; align-items:center; justify-content:center; min-width:32px; height:32px;
  border-radius:8px; font-size:13px; color:var(--body-c); text-decoration:none; padding:0 8px;
}
.tosk-pagination a:hover{background:var(--surface);}
.tosk-pagination .active span{background:var(--primary); color:var(--on-primary); font-weight:700;}

@media (min-width:1440px){
  .topbar{padding:0 48px;}
}

/* ================= responsive ================= */
@media (max-width: 860px){
  main{padding:24px 16px 72px;}
  .row-3{grid-template-columns:1fr 1fr;}
}

@media (max-width: 640px){
  .topbar{padding:0 14px; height:52px;}
  .brand{font-size:15px;}
  .topbar-right{gap:8px; font-size:12.5px;}
  .topbar-right .btn-sm{height:30px; padding:0 10px; font-size:12.5px;}

  main{padding:20px 12px 64px;}
  .section-title{font-size:17px; margin-bottom:14px;}

  .card{padding:16px; border-radius:14px; margin-bottom:14px;}
  .card-title{font-size:14px; margin-bottom:12px;}

  .row-2, .row-3{grid-template-columns:1fr; gap:10px;}

  .filter-bar{flex-direction:column; align-items:stretch;}
  .filter-bar .field{min-width:0; width:100%;}
  .quick-range{flex-wrap:wrap; margin:10px 0 16px;}
  .quick-range .btn{flex:1 1 calc(50% - 8px);}

  .input, select.input, input[type="date"].input{height:44px; font-size:14px;}

  .btn-xl{height:50px; font-size:15.5px; border-radius:14px;}
  .btn-lg{height:44px; font-size:14.5px; border-radius:12px;}

  /* bottom action rows (신규등록/파일상세) become full-width stacked buttons */
  .form-actions{
    flex-direction:column-reverse !important;
    gap:8px !important;
  }
  .form-actions .btn{
    width:100%;
  }

  .auth-card{width:100%; padding:26px 20px; border-radius:16px;}
  .auth-wrap{padding:16px;}

  .modal{width:100%; padding:20px;}
  .option-row{font-size:13.5px;}

  /* MY account card stacks on mobile */
  .my-account-card{
    flex-direction:column; align-items:stretch; gap:12px;
  }
  .my-account-card .btn{width:100%;}

  .toast{width:calc(100% - 32px); left:16px; transform:none; text-align:center;}
  .gallery{grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:12px;}
}
