/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #004890;
  --blue-d:  #00356a;
  --blue-l:  #e8f1fb;
  --green:   #14783c;
  --green-l: #e6f7ee;
  --gold:    #f59e0b;
  --red:     #dc2626;
  --bg:      #f1f5f9;
  --card:    #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --muted:   #64748b;
  --radius:  10px;
  --shadow:  0 2px 12px rgba(0,0,0,.08);
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Header ── */
.app-header {
  background: linear-gradient(135deg, #004890, #006acc);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 16px rgba(0,72,144,.35);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  min-height: 64px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .8rem; flex: 1; min-width: 180px; }
.brand-icon {
  width: 42px; height: 42px; border-radius: 9px;
  background: rgba(255,255,255,.18);
  display: grid; place-items: center;
  font-size: 1.2rem; color: #fff;
}
.brand h1 { font-size: 1.35rem; font-weight: 700; color: #fff; }
.brand span { font-size: .75rem; color: rgba(255,255,255,.7); }
nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.nav-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem; border-radius: 8px;
  color: rgba(255,255,255,.85); text-decoration: none;
  font-size: .85rem; font-weight: 500;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  transition: .15s; position: relative;
}
.nav-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,.25); color: #fff; font-weight: 600; }
.nav-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold); color: #000;
  font-size: .7rem; font-weight: 700; font-style: normal;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px;
}

/* ── Main ── */
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

/* ── Alerts ── */
.alert {
  padding: .85rem 1.2rem; border-radius: var(--radius);
  display: flex; align-items: center; gap: .6rem;
  font-size: .9rem; font-weight: 500;
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.alert-ok  { background: #dcfce7; color: #166534; border-left: 4px solid #22c55e; }
.alert-err { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }

/* ── Card ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: .8rem;
  padding: 1.1rem 1.5rem; border-bottom: 2px solid var(--border);
  background: linear-gradient(135deg, #f8faff, #f0f4f8);
}
.card-head i { color: var(--blue); font-size: 1.15rem; }
.card-head h2 { font-size: 1.05rem; font-weight: 700; }
.ml-auto { margin-left: auto; }

/* ── Form ── */
.form-doc { padding: 1.5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.span2 { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label {
  font-size: .8rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  display: flex; align-items: center; gap: .35rem;
}
.form-group label i { color: var(--blue); width: 13px; }
.req { color: var(--red); }
.form-group input {
  padding: .65rem .9rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .95rem; color: var(--text);
  background: #fff; outline: none; transition: .15s;
}
.form-group input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,72,144,.1); }
.form-foot {
  display: flex; justify-content: flex-end; gap: .8rem;
  padding-top: 1.2rem; margin-top: 1.2rem;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}

/* ── Type Picker ── */
.type-picker { display: flex; gap: .9rem; flex-wrap: wrap; }
.type-opt input { display: none; }
.type-card {
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: .9rem 1.6rem; border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: .15s;
  min-width: 150px; text-align: center; background: #fff;
}
.type-card i { font-size: 1.5rem; color: #bbb; transition: .15s; }
.type-card strong { font-size: .9rem; color: var(--text); }
.type-card small { font-size: .72rem; color: var(--muted); }
.type-opt input:checked + .type-card.pv  { border-color: var(--blue);  background: var(--blue-l);  box-shadow: 0 0 0 3px rgba(0,72,144,.12); }
.type-opt input:checked + .type-card.pv i { color: var(--blue); }
.type-opt input:checked + .type-card.sf  { border-color: var(--green); background: var(--green-l); box-shadow: 0 0 0 3px rgba(20,120,60,.12); }
.type-opt input:checked + .type-card.sf i { color: var(--green); }
.type-card:hover { border-color: #cbd5e1; }

/* ── Stars Input ── */
.stars-input {
  display: flex; align-items: center;
  flex-direction: row-reverse; justify-content: flex-end;
  gap: .15rem; padding: .3rem 0;
}
.stars-input input { display: none; }
.stars-input label {
  font-size: 1.8rem; color: #d1d5db; cursor: pointer;
  transition: color .12s, transform .12s;
}
.stars-input label:hover,
.stars-input label:hover ~ label,
.stars-input input:checked ~ label { color: var(--gold); }
.stars-input label:hover { transform: scale(1.15); }
.star-val { font-size: .95rem; font-weight: 700; color: var(--gold); margin-left: .7rem; min-width: 35px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .62rem 1.25rem; border-radius: 8px;
  font-size: .88rem; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; white-space: nowrap;
  transition: .15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); box-shadow: 0 4px 12px rgba(0,72,144,.3); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #0d5c2e; }
.btn-info    { background: #3b82f6; color: #fff; }
.btn-info:hover { background: #2563eb; }
.btn-ghost   { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: .38rem .85rem; font-size: .82rem; }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue); color: #fff;
  border-radius: 12px; min-width: 22px; height: 22px;
  font-size: .72rem; font-weight: 700; padding: 0 5px; margin-left: .3rem;
}

/* ── Bulk bar ── */
.bulk-bar {
  display: none; align-items: center; gap: .9rem; flex-wrap: wrap;
  padding: .75rem 1.5rem;
  background: #eff6ff; border-bottom: 1px solid #bfdbfe;
  animation: fadeIn .2s ease;
}
.bulk-bar.show { display: flex; }
.bulk-bar > span { font-size: .85rem; font-weight: 700; color: var(--blue); }
.bulk-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Filters ── */
.filters {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.5rem; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.filter-tabs { display: flex; gap: .3rem; }
.ftab {
  padding: .28rem .85rem; border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff; font-size: .82rem; font-weight: 600;
  color: var(--muted); cursor: pointer; transition: .13s;
}
.ftab.active { border-color: var(--blue); background: var(--blue); color: #fff; }
.ftab:hover:not(.active) { border-color: var(--blue); color: var(--blue); }
.search {
  display: flex; align-items: center; gap: .5rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: .3rem .75rem; background: #fff; flex: 1; max-width: 280px;
}
.search i { color: var(--muted); font-size: .82rem; }
.search input { border: none; outline: none; font-size: .87rem; width: 100%; }

/* ── Table ── */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .87rem; }
.tbl thead { background: #f8fafc; }
.tbl th {
  padding: .7rem 1rem; text-align: left;
  font-size: .75rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.tbl td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover { background: #f8faff; }
.tbl tbody tr.hidden { display: none; }
.th-chk { width: 38px; text-align: center; }
.mono { font-family: monospace; color: var(--blue); font-weight: 600; font-size: .85rem; }
.trunc { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-weight: 700; color: var(--green); white-space: nowrap; }
.dt  { color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ── Tags ── */
.tag { display: inline-block; padding: .18rem .6rem; border-radius: 20px; font-size: .72rem; font-weight: 700; letter-spacing: .4px; }
.tag-pv { background: var(--blue-l);  color: var(--blue);  border: 1px solid #b3cfed; }
.tag-sf { background: var(--green-l); color: var(--green); border: 1px solid #a3d9b4; }

/* ── Stars row ── */
.stars-row { display: flex; gap: 1px; }
.s-on  { color: var(--gold); font-size: .82rem; }
.s-off { color: #d1d5db;     font-size: .82rem; }

/* ── Action buttons ── */
.acts { white-space: nowrap; }
.act-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  border: 1.5px solid var(--border); background: #fff;
  cursor: pointer; font-size: .82rem; color: var(--muted);
  text-decoration: none; margin: 0 1px; transition: .13s;
}
.act-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,.1); }
.act-btn.dl:hover  { border-color: var(--blue);  color: var(--blue);  background: var(--blue-l); }
.act-btn.em:hover  { border-color: #3b82f6; color: #3b82f6; background: #eff6ff; }
.act-btn.del:hover { border-color: var(--red);   color: var(--red);   background: #fee2e2; }

/* ── Empty state ── */
.empty { padding: 3.5rem 2rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.empty i { font-size: 3rem; color: #cbd5e1; }
.empty h3 { font-size: 1.1rem; }
.empty p { color: var(--muted); }

/* ── Modal ── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
  display: none; place-items: center; z-index: 999; padding: 1rem;
}
.modal-bg.open { display: grid; }
.modal {
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  width: 100%; max-width: 460px;
  animation: scaleIn .22s ease;
}
@keyframes scaleIn { from { opacity:0; transform:scale(.94); } to { opacity:1; transform:none; } }
.modal-head {
  display: flex; align-items: center; gap: .7rem;
  padding: 1rem 1.4rem; border-bottom: 1px solid var(--border);
}
.modal-head i { color: var(--blue); }
.modal-head h3 { font-size: 1rem; font-weight: 700; flex: 1; }
.modal-x { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1rem; padding: .2rem; border-radius: 4px; }
.modal-x:hover { background: var(--bg); }
.modal-body { padding: 1.3rem 1.4rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-info {
  font-size: .83rem; color: var(--blue);
  background: var(--blue-l); padding: .55rem .85rem;
  border-radius: 7px; display: flex; align-items: center; gap: .45rem;
}
.modal-foot {
  padding: .9rem 1.4rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .6rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header-inner { padding: .7rem 1rem; }
  main { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: 1; }
  .form-doc { padding: 1rem; }
  .form-foot { justify-content: stretch; }
  .form-foot .btn { flex: 1; justify-content: center; }
  .type-card { min-width: 120px; padding: .7rem 1rem; }
  .tbl th, .tbl td { padding: .6rem .65rem; }
  .trunc { max-width: 100px; }
  .filters { padding: .65rem 1rem; }
  .card-head { padding: 1rem; }
}
@media (max-width: 480px) {
  .brand span { display: none; }
  .nav-btn span { display: none; }
  .tbl .dt { display: none; }
  .tbl th:nth-child(8) { display: none; }
}


.status-badges { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }

.sbadge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .72rem; font-weight: 600;
    padding: .18rem .55rem; border-radius: 20px;
    white-space: nowrap;
}
.dl-badge { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.em-badge { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }