:root{
  /* Light base */
  --bg:#f6f8fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:rgba(15,23,42,.10);

  /* CI Orange */
  --pri:#ff4b00;
  --pri2:#ff9b00;
  --pri3:#ff6e00;

  --ok:#16a34a;
  --warn:#d97706;
  --bad:#dc2626;

  --shadow: 0 10px 22px rgba(15,23,42,.08);
  --r: 14px;
}

*{box-sizing:border-box}
html,body{
  margin:0;padding:0;
  background: linear-gradient(180deg,#ffffff, var(--bg));
  color:var(--text);
  font-family:Segoe UI, Arial, sans-serif;
}
img{max-width:100%;height:auto}
a{color:#0b66c3;text-decoration:none}
a:hover{text-decoration:underline}

/* =========================
   Topbar
   ========================= */
.topbar{
  background: linear-gradient(180deg, #ffffff, rgba(255,155,0,.80));
  border-bottom:1px solid var(--pri3);
  box-shadow: 0 6px 16px rgba(15,23,42,.08);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .inner{
  max-width:1200px;margin:0 auto;
  padding:14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--text);
  font-weight:900;
  min-width:0;
}
.brand img{height:34px;width:auto;display:block}
.brand .title{font-size:16px;line-height:1.1;color:var(--text)}
.brand .sub{font-size:12px;font-weight:700;color:var(--muted);opacity:1}
.top-actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.container{max-width:1200px;margin:0 auto;padding:18px;}

/* =========================
   Layout / Cards / Text
   ========================= */
.card{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding:14px;
  margin:12px 0;
}
.grid{display:grid;grid-template-columns:1fr;gap:12px;}
@media(min-width:900px){
  .grid.cols2{grid-template-columns:1fr 1fr;}
}

.h1{font-size:18px;font-weight:900;margin:4px 0 2px}
.h2{font-size:14px;font-weight:900;margin:0 0 10px;color:#1f2937}
.muted{color:var(--muted);font-size:12px}

.sep{height:1px;background:var(--line);margin:10px 0}
hr{border:0;height:1px;background:var(--line);margin:10px 0}

/* =========================
   Inputs
   ========================= */
.controls{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}
.input, select, textarea{
  background:#fff;
  border:1px solid rgba(15,23,42,.16);
  color:var(--text);
  padding:10px 10px;
  border-radius:12px;
  outline:none;
}
.input{min-width:260px}
textarea{width:100%;min-height:92px;resize:vertical}
.input:focus, select:focus, textarea:focus{
  border-color: rgba(255,75,0,.55);
  box-shadow: 0 0 0 4px rgba(255,75,0,.12);
}

/* =========================
   Buttons
   ========================= */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  min-height:42px;
  padding:10px 18px;

  font-size:14px;
  font-weight:700;
  line-height:1;
  white-space:nowrap;

  border-radius:12px;
  border:1px solid rgba(0,0,0,.08);
  cursor:pointer;

  background: linear-gradient(90deg, var(--pri), var(--pri2));
  color:#fff;

  box-shadow: 0 10px 16px rgba(255,75,0,.14);
}
.btn:hover{filter:brightness(1.03)}
.btn.gray{
  background:#f8fafc;
  color:#334155;
  border:1px solid rgba(15,23,42,.12);
  box-shadow:none;
}
.btn.gray:hover{background:#eef2f7}
.btn.primary{
  background: linear-gradient(90deg, var(--pri), var(--pri2));
  color:#fff;
  border:1px solid rgba(0,0,0,.08);
  box-shadow: 0 8px 18px rgba(255,75,0,.25);
}
.btn.primary:hover{filter:brightness(1.05)}
.btn.danger{
  background:#fff1f2;
  color:#991b1b;
  border:1px solid rgba(220,38,38,.35);
  box-shadow: 0 8px 16px rgba(220,38,38,.10);
}
.btn.danger:hover{background:#ffe4e6}
.btn.sm{
  padding:6px 10px;
  border-radius:10px;
  font-size:12px;
  min-height:34px;
  box-shadow:none;
}

/* =========================
   Badges
   ========================= */
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(15,23,42,.12);
  font-size:12px;
  font-weight:900;
  background:#fff;
}

.badge.ok{
  background: #2f6fed;   /* 유지 = 파란색 */
  color: #fff;
  border-color: #2f6fed;
}

.badge.warn{
  background: #868e96;   /* 만료 = 회색 */
  color: #fff;
  border-color: #868e96;
}

.badge.bad{
  background: #dc2626;   /* 해지 = 빨간색 */
  color: #fff;
  border-color: #dc2626;
}
.dot{width:8px;height:8px;border-radius:50%}
.dot.ok{background:var(--ok)}
.dot.warn{background:var(--warn)}
.dot.bad{background:var(--bad)}
.dot.pri{background:var(--pri3)}

/* =========================
   Tables (base)
   ========================= */
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
  border-radius:14px;
  border:1px solid rgba(15,23,42,.12);
}
.table th,.table td{
  padding:10px 10px;
  border-bottom:1px solid rgba(15,23,42,.10);
  font-size:13px;
  vertical-align:middle;
  text-align:center;
}
.table th{
  background:#fff7f2;
  color:#111827;
  font-weight:900;
  white-space:nowrap;
}
.table tr:nth-child(even) td{background:#fbfdff;}
.table tr:hover td{background: rgba(255,155,0,.12);}

/* contract status highlight */
.table tr.row-expired td{background: rgba(220,38,38,.10) !important;}
.table tr.row-expired:hover td{background: rgba(220,38,38,.16) !important;}
.table tr.row-soon td{background: rgba(217,119,6,.10) !important;}
.table tr.row-soon:hover td{background: rgba(217,119,6,.16) !important;}
.small-muted{color:var(--muted); font-size:12px;}
.sumline{display:flex; gap:10px; align-items:center; justify-content:flex-end; margin:10px 0;}
.sumline .sumcard{background:rgba(255,155,0,.10); border:1px solid rgba(15,23,42,.10); padding:8px 10px; border-radius:12px; font-weight:800;}

/* detail table (4-column) */
.table.detail{table-layout:fixed;}
.table.detail th{
  width:18%;
  background:#f8fafc;
  font-weight:700;
  text-align:center;
  white-space:nowrap;
}
.table.detail td{
  width:32%;
  text-align:left;
  word-break:break-word;
}
.table.detail td[colspan]{width:auto;}

/* attachments table */
.table.attach th{
  background:#f8fafc;
  font-weight:700;
  text-align:center;
}
.table.attach td:nth-child(1){text-align:center;font-weight:700;}
.table.attach td:nth-child(2){text-align:left;word-break:break-word;}
.table.attach td:nth-child(3){text-align:right;padding-right:16px;white-space:nowrap;}
.table.attach td:nth-child(4){text-align:center;white-space:nowrap;}

/* list table (index) */
.table.list{table-layout:auto;}
.table.list td:nth-child(1){text-align:center;width:70px;}
.table.list td:nth-child(2),.table.list td:nth-child(3){text-align:center;width:120px;}
.table.list td:nth-child(4),.table.list td:nth-child(5){white-space:normal;}
.table.list td:nth-child(6),.table.list td:nth-child(7){text-align:center;}
.table.list td:nth-child(8){text-align:center;width:80px;}
.table.list td:nth-child(9),.table.list th:nth-child(9){
  text-align:center;
  width:260px;
  padding-left:8px;
  padding-right:8px;
}

/* manage actions inside list table */
.manage-actions{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:6px;
  flex-wrap:nowrap;
}
.inline-form{display:inline-flex;margin:0}

/* =========================
   Page / Form actions
   ========================= */
.form-actions{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:12px;
  margin-top:20px;
  padding-top:14px;
  border-top:1px solid var(--line);
}
.page-actions{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
.page-actions .left,.page-actions .right{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

/* =========================
   Form Table (label + field)
   ========================= */
.form-table{
  border:1px solid var(--line);
  border-radius: var(--r);
  overflow:hidden;
  background: var(--card);
}
.form-table .tr{
  display:grid;
  grid-template-columns: 220px 1fr;
  border-top:1px solid var(--line);
}
.form-table .tr:first-child{ border-top:none; }
.form-table .th{
  padding:12px 14px;
  background: rgba(15,23,42,.03);
  font-weight:900;
  color: var(--text);
}
.form-table .td{padding:10px 14px;}
.form-table input.input,
.form-table select,
.form-table textarea{
  width:100%;
  padding:10px 12px;
  border:1px solid rgba(15,23,42,.16);
  border-radius: 12px;
  background:#fff;
  color: var(--text);
  outline:none;
}
.form-table input.input:focus,
.form-table select:focus,
.form-table textarea:focus{
  border-color: rgba(255,75,0,.55);
  box-shadow: 0 0 0 3px rgba(255,75,0,.12);
}
.form-table .td.inline{
  display:flex;
  flex-wrap:wrap;
  gap:10px 14px;
  align-items:center;
}

/* =========================
   Responsive
   ========================= */
@media (max-width: 900px){
  .container{padding:12px;}
  .topbar .inner{padding:12px 12px;}
  .brand img{height:30px;}
  .brand .title{font-size:15px;}
  .brand .sub{font-size:11px;}
  .card{padding:12px;}
  .grid{gap:10px;}
}

/* Phone / narrow */
@media (max-width: 700px){
  .h1{font-size:16px;}
  .h2{font-size:13px;}

  /* Է UI:   */
  .controls{flex-direction:column;align-items:stretch;gap:8px;}
  .input, select, textarea{width:100%;min-width:0 !important;}

  /* Ͽ ư ٹٲ  */
  .manage-actions{flex-wrap:wrap;justify-content:flex-start;}
  .btn{min-height:44px;}

  /* form-table:   /Է Ʒ */
  .form-table .tr{grid-template-columns:1fr;}
  .form-table .th{
    padding:10px 12px;
    border-bottom:1px dashed var(--line);
  }
  .form-table .td{padding:10px 12px 12px;}

  /* =========================
     STACK TABLE (Ͽ  ũ  Ʒ ױ)
     - class="table ... stack"  ̺ ȯ
     ========================= */
  .table.stack thead{display:none;}
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td{
    display:block;
    width:100%;
  }
  .table.stack{
    border:none;
    border-radius:0;
  }
  .table.stack tr{
    background: var(--card);
    border:1px solid var(--line);
    border-radius: var(--r);
    overflow:hidden;
    margin:10px 0;
    box-shadow: var(--shadow);
  }
  .table.stack td{
    display:flex;
    justify-content:space-between;
    gap:12px;
    text-align:left;
    padding:10px 12px;
    border-bottom:1px dashed var(--line);
    white-space:normal;
    word-break:break-word;
  }
  .table.stack td:last-child{border-bottom:none;}
  .table.stack td::before{
    content: attr(data-label);
    font-weight:900;
    color: var(--muted);
    flex:0 0 auto;
    white-space:nowrap;
  }

  /* detail table ũ  Ʒ ġ */
  .table.detail{
    border-radius: var(--r);
  }
  .table.detail tbody tr{
    display:grid;
    grid-template-columns: 120px 1fr;
  }
  .table.detail th,
  .table.detail td{
    display:block;
    width:auto !important;
    text-align:left;
    padding:10px 12px;
    white-space:normal;
  }
  .table.detail th{
    background:#f8fafc;
    font-weight:900;
  }
  .table.detail td[colspan]{
    grid-column: 2 / -1;
  }
}

/* index: desktop table / mobile cards toggle */
.only-desktop{ display:block; }
.only-mobile{ display:none; }

@media (max-width: 700px){
  .only-desktop{ display:none; }
  .only-mobile{ display:block; }
}

/* Mobile case cards */
.case-cards{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.case-card{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.case-card .head{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  padding:12px;
  border-bottom:1px solid var(--line);
  background: rgba(255,155,0,.10);
}

.case-card .id{
  font-weight:900;
  font-size:13px;
  color: var(--text);
  white-space:nowrap;
}

.case-card .tags{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-start;
}

.case-card .body{
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.case-card .row{
  display:flex;
  gap:10px;
  align-items:flex-start;
}

.case-card .k{
  flex:0 0 92px;
  font-weight:900;
  color: var(--muted);
  font-size:12px;
  white-space:nowrap;
}
.case-card .v{
  flex:1 1 auto;
  color: var(--text);
  font-size:13px;
  word-break:break-word;
}

.case-card .actions{
  display:flex;
  gap:8px;
  padding:12px;
  border-top:1px solid var(--line);
  background:#fff;
}
.case-card .actions .btn{
  flex:1 1 0;
}
.case-card .actions .btn.sm{
  min-height:40px;
}

.case-card .client-name{
    font-size:13px;
    font-weight:600;
    color:var(--text);
    display:flex;
    align-items:center;
}

/* =========================
   user_admin tweaks
   ========================= */
.ua-actions{
  display:flex;
  gap:8px;
  justify-content:center; /* ũ鿡  */
  align-items:center;
  flex-wrap:wrap;
}
.ua-form{ margin:0; display:inline-flex; }
.action-cell{ text-align:center; }

/*  stack action    /ٹٲ */
@media (max-width: 700px){
  .action-cell{ text-align:left; }
  .ua-actions{ justify-content:flex-end; }
}

/* =========================
   Topbar: PC=1, Mobile=2(ŸƲ  /  Ʒ )
   ========================= */

.topbar{
  background:#ffffff;
  border-bottom:1px solid #e5e7eb;
  box-shadow:0 2px 8px rgba(15,23,42,.06);
  position:sticky;
  top:0;
  z-index:20;
}

.topbar .inner{
  max-width:1200px;
  margin:0 auto;
  padding:14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.brand .brand-line{
  display:flex;
  align-items:baseline;
  gap:10px;
  white-space:nowrap;
  min-width:0;
}

.brand-title{
  font-weight:900;
  color:var(--text);
  font-size:16px;
  line-height:1.1;
}

.brand-sub{
  font-weight:800;
  color:var(--muted);
  font-size:12px;
  line-height:1.1;
}

.top-actions{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

/*  ̸ (  ) */
.top-user{
  max-width:140px;
  display:inline-block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-weight:800;
  color:#334155;
}

.btn.iconbtn{ gap:8px; padding:10px 12px; }


@media (max-width: 700px){


  .topbar .inner{
    display:grid;
    grid-template-columns: 1fr;
    gap:8px;
  }


  .brand .brand-line{
    overflow:hidden;
    text-overflow:ellipsis;
  }


  .top-actions{
    justify-content:flex-end;
  }

  .btn .btn-text{ display:none; }
  .btn.iconbtn{
    padding:9px 10px;
    min-height:36px;
    border-radius:12px;
  }

  /*  ̸  ª */
  .top-user{ max-width:90px; }


  .btn.gray.iconbtn{
    background:#f8fafc;
    box-shadow:none;
  }
}

.brand-line {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {  
  font-size: clamp(14px, 3.5vw, 22px);
  font-weight: 600;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* =========================
   FIX: index mobile/desktop toggle
   ========================= */
.only-desktop { display: block !important; }
.only-mobile  { display: none  !important; }

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

/* =========================
   FIX: Topbar brand stack (title above / sub below)
   ========================= */
.brand .brand-line{
  display:flex !important;
  flex-direction:column !important;
  align-items:flex-start !important;
  gap:4px !important;
  white-space:normal !important;
  min-width:0;
}

.brand-title{
  font-size: clamp(14px, 3.5vw, 22px) !important;
  font-weight:900 !important; /*  600   */
  line-height:1.15;
}

.brand-sub{
  font-size:12px !important;
  font-weight:800;
  color:var(--muted) !important;
  margin-top:0 !important;
  line-height:1.1;
}


/* ===== Filters (clean) ===== */
.filters-clean{
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.65));
}

.filters-clean .filters-row{
  display: grid;
  gap: 10px;
  grid-template-columns: 1.4fr .7fr;
  align-items: end;
  margin-bottom: 10px;
}

.filters-clean .filters-row:nth-child(2){
  grid-template-columns: 1fr 1fr 1fr auto;
}

.filters-clean .field label{
  display:block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.filters-clean input[type="text"],
.filters-clean input[type="date"],
.filters-clean select{
  width: 100%;
}

.filters-clean .range{
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}

.filters-clean .range .sep{
  color: var(--muted);
  font-size: 12px;
  padding: 0 2px;
}

.filters-clean .actions{
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

.filters-clean .sumbar{
  display:flex;
  gap: 14px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  flex-wrap: wrap;
}

.filters-clean .sumitem{
  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
}

.filters-clean .sumitem b{
  font-size: 14px;
  margin: 0 4px;
}

.filters-clean .hint{
  margin-left: auto;
}

/* Responsive */
@media (max-width: 980px){
  .filters-clean .filters-row{
    grid-template-columns: 1fr 1fr;
  }
  .filters-clean .filters-row:nth-child(2){
    grid-template-columns: 1fr 1fr;
  }
  .filters-clean .actions{
    justify-content: flex-start;
  }
  .filters-clean .hint{
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 560px){
  .filters-clean .filters-row{
    grid-template-columns: 1fr;
  }
  .filters-clean .filters-row:nth-child(2){
    grid-template-columns: 1fr;
  }
  .filters-clean .actions{
    width: 100%;
  }
  .filters-clean .actions .btn{
    flex: 1;
    justify-content: center;
  }
}

/* ====== Header tidy ====== */
.hd-slim{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
}
.hd-left h2{ margin:0; }
.hd-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.hd-actions .btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
}

/* ====== Searchbar (like screenshot) ====== */
.searchbar{
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap:wrap;
}
.search-left{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap:wrap;
}
.searchbar .ctrl{
  height: 40px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.12);
  background:#fff;
  min-width: 140px;
}
.searchbar input.ctrl{ min-width: 260px; }
.searchbar select.ctrl{ min-width: 120px; }

.date-range{
  display:flex;
  align-items:center;
  gap:8px;
}
.date-range .tilde{
  color: var(--muted);
  font-size: 12px;
}

.search-right{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin-left:auto;
}
.sumchip{
  display:inline-flex;
  align-items:baseline;
  gap:6px;
  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
}
.sumchip b{ font-size: 14px; }

/* Responsive */
@media (max-width: 900px){
  .hd-slim{ flex-direction: column; align-items: stretch; }
  .hd-actions{ justify-content:flex-start; }
  .search-right{ width:100%; margin-left:0; }
  .searchbar input.ctrl{ min-width: 220px; }
}
@media (max-width: 560px){
  .search-left{ width:100%; }
  .searchbar .ctrl{ width:100%; min-width: 0; }
  .date-range{ width:100%; }
  .date-range .ctrl{ width: calc(50% - 10px); }
  .search-right{ width:100%; }
}

.btn.disabled { opacity:.45; pointer-events:none; }

.terminated-link,
.terminated-link:visited{
    color:#dc2626 !important;
    font-weight:900;
}

.terminated-link:hover{
    color:#b91c1c !important;
}
