:root {
    --bg: #fff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --border2: #eef2f7;
    --shadow: 0 8px 24px rgba(17, 24, 39, .08);
    --shadow2: 0 1px 2px rgba(17, 24, 39, .06);
    --radius: 14px;
    --radius2: 18px;
    --focus: rgba(59, 130, 246, .18);
    --primary: #2563eb;
    --primary2: rgba(37, 99, 235, .10);
    --chipActiveBg: rgba(37, 99, 235, .10);
    --chipActiveBorder: rgba(37, 99, 235, .28);
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    font-family: "Google Sans Flex", "Google Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}


body.filters-open main {
    opacity: .92;
}

/* ===== Topbar ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topLeft {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.brand {
    font-weight: 800;
    letter-spacing: .2px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #fff, #fafafa);
    box-shadow: var(--shadow2);
    user-select: none;
    flex: 0 0 auto;
}

.topRight {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.stats {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.btn {
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow2);
    transition: background .12s ease, transform .06s ease, border-color .12s ease;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn:hover {
    background: #f9fafb
}

.btn:active {
    transform: translateY(1px)
}

.btn.primary {
    border-color: rgba(37, 99, 235, .22);
    background: var(--primary2);
    color: var(--primary);
}

.btn.icon {
    padding: 0 10px;
    width: 40px;
    justify-content: center;
}

.pill {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid var(--border);
}

.searchWrap {
    flex: 1;
    min-width: 220px;
    max-width: 720px;
    position: relative;
}

.search {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 42px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    outline: none;
    box-shadow: var(--shadow2);
    transition: border-color .12s ease, box-shadow .12s ease;
}

.search:focus {
    border-color: rgba(37, 99, 235, .35);
    box-shadow: 0 0 0 4px var(--focus);
}

.search::placeholder {
    color: #9ca3af
}

.searchIcon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    opacity: .55;
}

/* ===== Layout: sidebar + main ===== */
.layout {
    display: grid;
    grid-template-columns: 0px 1fr;
    transition: grid-template-columns .18s ease;
}

body.filters-open .layout {
    grid-template-columns: 320px 1fr;
}

/* Sidebar desktop: sticky dưới topbar */
.sidebar {
    position: sticky;
    top: 69px;
    height: calc(100vh - 69px);
    border-right: 1px solid var(--border);
    background: #fff;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform .18s ease;
}

body.filters-open .sidebar {
    transform: translateX(0)
}

.sideInner {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-width: 320px;
}

.sideHead {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sideTitle {
    font-weight: 800
}

.sideHeadBtns {
    display: flex;
    align-items: center;
    gap: 8px;
}

.resetLink {
    border: none;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-weight: 700;
    padding: 6px 8px;
    border-radius: 10px;
}

.resetLink:hover {
    background: rgba(37, 99, 235, .08)
}

.sideContent {
    padding: 14px;
    overflow: auto;
}

.sideSection {
    margin-bottom: 18px;
}

.sideSection h4 {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: var(--muted);
    font-weight: 800;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 12.5px;
    color: var(--muted);
}

select {
    height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    outline: none;
    box-shadow: var(--shadow2);
    font-size: 14px; 
}

select:focus {
    border-color: rgba(37, 99, 235, .35);
    box-shadow: 0 0 0 4px var(--focus);
}

/* Category chips grid */
.chipGrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.chip {
    height: 34px;
    border-radius: 999px;
    padding: 0 12px;
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: var(--shadow2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    user-select: none;
    font-size: 13.5px;
    color: #374151;
    min-width: 0;
}

.chip:hover {
    background: #f9fafb
}

.chip.active {
    background: var(--chipActiveBg);
    border-color: var(--chipActiveBorder);
    color: var(--primary);
}

.chip span {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip small {
    font-size: 12.5px;
    color: var(--muted);
    flex: 0 0 auto;
}

/* ===== Main grid ===== */
main {
    padding: 16px;
    min-width: 0;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.tile {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    box-shadow: var(--shadow2);
    transition: transform .08s ease, box-shadow .14s ease, border-color .14s ease;
    background: #fff;
}

.tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: rgba(37, 99, 235, .18);
}

.iconbox {
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #fafafa;
    border: 1px solid var(--border2);
}

.iconbox img {
    width: 46px;
    height: 46px
}

.name {
    margin-top: 10px;
    font-size: 14.5px;
    font-weight: 650;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub {
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading {
    padding: 14px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* ===== Mobile drawer ===== */
@media (max-width: 920px) {
    .layout {
        grid-template-columns: 1fr;
    }

    body.filters-open .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        height: 100vh;
        z-index: 45;
        box-shadow: var(--shadow);
        transform: translateX(-110%);
    }

    body.filters-open .sidebar {
        transform: translateX(0)
    }

    .sideInner {
        min-width: 320px;
        max-width: 86vw;
    }

    main {
        padding: 14px
    }
}

/* ===== Modal ===== */
/* ===== Modal (new) ===== */
.modal{
  position:fixed; inset:0;
  background: rgba(17,24,39,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index:60;
}
.hidden{display:none}

.modal-card{
  width: min(860px, 94vw);
  background:#fff;
  border:1px solid var(--border);
  border-radius: 22px;
  padding: 14px;
  box-shadow: var(--shadow);
  position:relative;
}

.modal-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  padding: 4px 4px 10px;
}

.modal-title{
  min-width:0;
  flex:1;
}

.mName{
  font-weight: 850;
  font-size: 20px;
  letter-spacing: .2px;
}

.mMeta{
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-all;
}

.modal-controls{
  display:flex;
  align-items:flex-start;
  gap:12px;
  flex:0 0 auto;
}

.mStyleWrap{
  display:flex;
  flex-direction:column;
  gap:6px;
  align-items:flex-end;
}

.mStyleLabel{
  font-size: 11px;
  color: var(--muted);
  user-select:none;
}

.mStyleSelect{
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow2);
  font-size: 14px;
  outline:none;
}
.mStyleSelect:focus{
  border-color: rgba(37,99,235,.35);
  box-shadow: 0 0 0 4px var(--focus);
}

.iconBtn{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background:#fff;
  box-shadow: var(--shadow2);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: background .12s ease, transform .06s ease;
  user-select:none;
}
.iconBtn:hover{ background:#f9fafb; }
.iconBtn:active{ transform: translateY(1px); }

.previewShell{
  padding: 10px 4px 12px;
}

.previewStage{
  height: 260px;
  border-radius: 18px;
  border: 1px solid var(--border2);
  background:
    radial-gradient(circle at 1px 1px, rgba(17,24,39,.06) 1px, transparent 0) 0 0/18px 18px,
    #ffffff;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}

.previewStage img{
  width: 140px;
  height: 140px;
}

.actionsRow{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  padding: 6px 4px 2px;
}

/* toast giữ nguyên */
.toast{
  position:absolute;
  right:12px;
  bottom:12px;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  box-shadow:var(--shadow2);
  font-size:12px;
}
