  :root {
    --primary: #2563EB;
    --primary-light: #DBEAFE;
    --primary-dark: #1D4ED8;
    --accent: #0F766E;
    --danger: #F97316;
    --warning: #F59E0B;
    --success: #059669;
    --bg: #F4F7FB;
    --card-bg: #FFFFFF;
    --text: #17202A;
    --text-light: #667085;
    --border: #E2E8F0;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    --shadow-hover: 0 18px 45px rgba(15, 23, 42, 0.14);
    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    font-family: 'Noto Sans Thai', sans-serif;
    background:
      radial-gradient(circle at top left, rgba(37,99,235,0.12), transparent 34rem),
      linear-gradient(180deg, #F8FAFC 0%, var(--bg) 42%, #EEF2F7 100%);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
  }
  img { max-width: 100%; }

  /* Loading Screen */
  .loading-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 16px;
  }
  .loading-screen p { color: var(--text-light); font-size: 14px; }
  .loading-spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .loading-error {
    width: min(360px, calc(100vw - 40px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    padding: 24px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .loading-error .material-icons-round {
    font-size: 36px;
    color: var(--danger);
  }

  /* Top Navigation */
  .top-nav {
    background: rgba(255,255,255,0.86);
    padding: 14px 28px;
    border-bottom: 1px solid rgba(226,232,240,0.9);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 8px 28px rgba(15,23,42,0.06);
    backdrop-filter: blur(18px);
  }
  .nav-brand {
    display: flex; align-items: center; gap: 10px;
  }
  .nav-brand .material-icons-round {
    width: 36px; height: 36px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: white;
    background: linear-gradient(135deg, var(--primary), var(--accent));
  }
  .nav-brand h1 { font-size: 20px; font-weight: 800; color: var(--text); }
  .nav-tabs {
    display: flex; gap: 6px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #F8FAFC;
  }
  .tab-btn {
    border: none; background: none; cursor: pointer;
    padding: 8px 14px; border-radius: 999px;
    display: flex; align-items: center; gap: 6px;
    font-family: inherit; font-size: 14px; font-weight: 700;
    color: var(--text-light); transition: var(--transition);
  }
  .tab-btn:hover { background: white; color: var(--text); }
  .tab-btn.active {
    background: white; color: var(--primary);
    box-shadow: 0 6px 18px rgba(37,99,235,0.14);
  }
  .tab-btn .material-icons-round { font-size: 20px; }

  .app-hero {
    max-width: 1400px;
    margin: 22px auto 0;
    padding: 0 24px;
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(420px, 1.35fr);
    gap: 18px;
    align-items: stretch;
  }
  .hero-copy {
    min-width: 0;
    padding: 22px;
    border: 1px solid rgba(226,232,240,0.9);
    border-radius: var(--radius);
    background:
      linear-gradient(135deg, rgba(37,99,235,0.10), rgba(15,118,110,0.08)),
      rgba(255,255,255,0.9);
    box-shadow: var(--shadow);
  }
  .hero-eyebrow {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(37,99,235,0.10);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
  }
  .hero-copy h2 {
    margin-top: 10px;
    font-size: 24px;
    line-height: 1.28;
    font-weight: 800;
  }
  .hero-copy p {
    margin-top: 6px;
    color: var(--text-light);
    font-size: 14px;
  }
  .summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }
  .summary-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid rgba(226,232,240,0.9);
    background: rgba(255,255,255,0.92);
    box-shadow: var(--shadow);
  }
  .summary-card .material-icons-round {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
  }
  .summary-card strong {
    display: block;
    font-size: 26px;
    line-height: 1;
    font-weight: 800;
  }
  .summary-card small {
    display: block;
    margin-top: 4px;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 700;
  }
  .summary-card-green .material-icons-round { background: rgba(5,150,105,0.12); color: var(--success); }
  .summary-card-yellow .material-icons-round { background: rgba(245,158,11,0.16); color: var(--warning); }
  .summary-card-blue .material-icons-round { background: rgba(37,99,235,0.12); color: var(--primary); }
  .summary-card-gray .material-icons-round { background: rgba(100,116,139,0.14); color: var(--text-light); }

  /* Filter Bar */
  .filter-bar {
    max-width: 1400px;
    margin: 16px auto 0;
    background: rgba(255,255,255,0.92);
    padding: 16px;
    border: 1px solid rgba(226,232,240,0.9);
    border-radius: var(--radius);
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    gap: 12px 16px;
    align-items: start;
    box-shadow: var(--shadow);
  }
  .search-box {
    display: flex; align-items: center; gap: 10px;
    background: #F8FAFC; border-radius: 12px;
    min-height: 46px;
    padding: 10px 16px; border: 1.5px solid var(--border);
    transition: var(--transition);
  }
  .search-box:focus-within {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.10);
  }
  .search-box .material-icons-round { color: var(--text-light); font-size: 22px; }
  .search-box input {
    border: none; background: none; outline: none;
    font-family: inherit; font-size: 15px; width: 100%;
    color: var(--text);
  }
  .clear-btn {
    border: none; background: none; cursor: pointer;
    color: var(--text-light); display: flex;
  }

  .status-filter {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    justify-content: flex-end;
  }
  .filter-groups {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(190px, 0.85fr) minmax(260px, 1.15fr) minmax(320px, 1.35fr);
    gap: 12px;
  }
  .filter-section {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #F8FAFC;
  }
  .filter-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 18px;
  }
  .filter-count {
    min-width: 24px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: white;
    border: 1px solid var(--border);
    color: var(--text-light);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
  }
  .filter-scroll {
    min-width: 0;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1px 2px 7px;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }
  .filter-scroll::-webkit-scrollbar { height: 6px; }
  .filter-scroll::-webkit-scrollbar-thumb {
    background: rgba(99,110,114,0.25);
    border-radius: 999px;
  }
  .status-btn {
    border: 1.5px solid var(--border); background: white; cursor: pointer;
    min-height: 36px;
    padding: 6px 14px; border-radius: 999px;
    font-family: inherit; font-size: 13px; font-weight: 700;
    color: var(--text-light); transition: var(--transition);
  }
  .status-btn:hover { border-color: var(--primary-light); }
  .status-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
  .status-btn.active.green { background: var(--success); border-color: var(--success); }
  .status-btn.active.yellow { background: #F39C12; border-color: #F39C12; }
  .status-btn.active.red { background: var(--danger); border-color: var(--danger); }
  .status-btn.active.gray { background: var(--text-light); border-color: var(--text-light); }

  .cat-btn, .brand-btn, .channel-btn {
    border: 1.5px solid transparent; background: white; cursor: pointer;
    height: 36px;
    padding: 6px 12px; border-radius: 999px;
    font-family: inherit; font-size: 13px; font-weight: 700;
    display: flex; align-items: center; gap: 6px;
    transition: var(--transition); color: var(--text);
    flex: 0 0 auto;
    max-width: 190px;
    scroll-snap-align: start;
  }
  .cat-btn { max-width: 160px; }
  .brand-btn { max-width: 180px; }
  .channel-btn { max-width: 230px; }
  .cat-btn, .brand-btn, .channel-btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .chip-icon {
    flex: 0 0 auto;
  }
  .chip-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cat-btn:hover, .brand-btn:hover, .channel-btn:hover { border-color: var(--primary-light); transform: translateY(-1px); }
  .cat-btn.active { border-color: var(--primary); background: var(--primary); color: white; }
  .brand-btn.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
  .channel-btn.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,0.12); }
  .brand-btn img, .channel-btn img {
    width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
    flex: 0 0 auto;
  }
  .filter-label {
    font-size: 12px; font-weight: 600; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0;
    margin-right: 0;
  }

  /* Content */
  .content { padding: 22px 24px 32px; max-width: 1400px; margin: 0 auto; }
  .tab-content { display: none; }
  .tab-content.active { display: block; animation: fadeIn 0.3s ease; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

  .section-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px;
    padding: 0 2px;
  }
  .section-header h2 { font-size: 20px; font-weight: 800; }
  .section-actions {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 10px; flex-wrap: wrap;
  }
  .sort-control {
    display: flex; align-items: center; gap: 8px;
    min-height: 40px; padding: 0 10px;
    background: white; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-light);
    box-shadow: 0 6px 16px rgba(15,23,42,0.05);
  }
  .sort-control .material-icons-round { font-size: 18px; color: var(--primary); }
  .sort-control select {
    border: none; outline: none; background: transparent;
    font-family: inherit; font-size: 13px; font-weight: 600;
    color: var(--text); cursor: pointer;
  }

  .add-btn {
    background: var(--primary); color: white; border: none;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    transition: var(--transition);
  }
  .add-btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-hover); }

  /* Card Grid */
  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 16px;
  }
  .card-grid > .card-section {
    grid-column: 1 / -1;
  }
  .card-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .card-section + .card-section {
    margin-top: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
  }
  .card-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 34px;
  }
  .card-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
  }
  .card-section-title .material-icons-round {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    background: rgba(0,184,148,0.12);
    color: var(--success);
  }
  .card-section-used .card-section-title .material-icons-round {
    background: rgba(99,110,114,0.12);
    color: var(--text-light);
  }
  .card-section-count {
    min-width: 28px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: white;
    border: 1px solid var(--border);
    color: var(--text-light);
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
  }

  .card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(15,23,42,0.07);
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid rgba(226,232,240,0.95);
    position: relative;
    display: flex; flex-direction: column;
    min-width: 0;
  }
  .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
  .card-used {
    background: #F8FAFC;
  }
  .card-used .card-image,
  .card-used .card-no-image {
    filter: saturate(0.55);
  }
  .card-used .card-title,
  .card-used .card-discount {
    color: var(--text-light);
  }
  .card-used .card-click-target {
    opacity: 0.84;
  }
  .card-used:hover .card-click-target {
    opacity: 1;
  }
  .card-click-target {
    cursor: pointer;
    flex: 1 1 auto;
    min-width: 0;
  }

  .card-image {
    width: 100%; height: auto; aspect-ratio: 16 / 9;
    object-fit: contain; display: block;
    background:
      linear-gradient(135deg, rgba(37,99,235,0.10), rgba(15,118,110,0.10)),
      #F8FAFC;
  }
  .card-no-image {
    width: 100%; aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, rgba(37,99,235,0.78), rgba(15,118,110,0.78));
    display: flex; align-items: center; justify-content: center;
  }
  .card-no-image .material-icons-round { font-size: 48px; color: rgba(255,255,255,0.5); }

  .card-badge {
    position: absolute; top: 12px; right: 12px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 18px rgba(15,23,42,0.12);
  }
  .badge-active { background: rgba(0,184,148,0.9); color: white; }
  .badge-expiring { background: rgba(243,156,18,0.9); color: white; }
  .badge-expired { background: rgba(255,107,107,0.9); color: white; }
  .badge-used { background: rgba(99,110,114,0.85); color: white; }
  .badge-unused { background: rgba(0,184,148,0.9); color: white; }

  .card-cat-badge {
    position: absolute; top: 12px; left: 12px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(8px);
  }

  .card-body { padding: 16px; }
  .card-title { font-size: 16px; font-weight: 800; margin-bottom: 6px; line-height: 1.4; }
  .card-subtitle { font-size: 13px; color: var(--text-light); margin-bottom: 10px; }
  .card-discount {
    font-size: 22px; font-weight: 800; color: var(--danger);
    margin-bottom: 8px;
  }
  .card-meta { display: flex; flex-direction: column; gap: 4px; }
  .card-meta-item {
    display: flex; align-items: flex-start; gap: 6px;
    font-size: 13px; color: var(--text-light);
    min-width: 0;
  }
  .card-meta-item .material-icons-round { font-size: 16px; flex: 0 0 auto; margin-top: 2px; }
  .card-countdown { font-weight: 600; }
  .countdown-green { color: var(--success); }
  .countdown-yellow { color: #F39C12; }
  .countdown-red { color: var(--danger); }

  .card-channels {
    display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px;
  }
  .card-channel-tag {
    padding: 3px 8px; border-radius: 999px; font-size: 11px;
    background: #EEF2F7; color: var(--text-light); font-weight: 700;
  }

  /* Usage Indicator */
  .usage-bar-container { margin-top: 10px; }
  .usage-label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; margin-bottom: 4px; font-weight: 600;
  }
  .usage-label-left { color: var(--text-light); }
  .usage-label-right { font-weight: 700; }
  .usage-bar {
    width: 100%; height: 8px; background: var(--border);
    border-radius: 4px; overflow: hidden;
  }
  .usage-bar-fill {
    height: 100%; border-radius: 4px; transition: width 0.4s ease;
  }
  .usage-green .usage-bar-fill { background: var(--success); }
  .usage-green .usage-label-right { color: var(--success); }
  .usage-yellow .usage-bar-fill { background: #F39C12; }
  .usage-yellow .usage-label-right { color: #F39C12; }
  .usage-red .usage-bar-fill { background: var(--danger); }
  .usage-red .usage-label-right { color: var(--danger); }
  .usage-full .usage-bar-fill { background: var(--text-light); }
  .usage-full .usage-label-right { color: var(--text-light); }

  .detail-usage-box {
    background: var(--bg); border-radius: var(--radius-sm);
    padding: 16px; margin-bottom: 18px;
  }
  .detail-usage-title {
    font-size: 12px; font-weight: 600; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
  }
  .detail-usage-big {
    font-size: 28px; font-weight: 800; text-align: center; margin-bottom: 8px;
  }
  .detail-usage-bar { height: 10px; border-radius: 5px; }
  .detail-usage-period {
    text-align: center; font-size: 13px; color: var(--text-light); margin-top: 8px;
  }
  .usage-log-list { margin-top: 12px; }
  .usage-log-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--border);
    font-size: 13px;
  }
  .usage-log-item:last-child { border-bottom: none; }
  .usage-log-date { color: var(--text-light); }
  .usage-log-delete {
    border: none; background: none; cursor: pointer;
    color: var(--text-light); padding: 2px;
  }
  .usage-log-delete:hover { color: var(--danger); }

  .card-footer {
    padding: 12px 16px; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px;
    background: #FBFCFE;
  }
  .card-brand {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 500;
    min-width: 0;
  }
  .card-brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .card-brand img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
  .card-actions { display: flex; gap: 4px; }
  .card-action-btn {
    border: none; background: var(--bg); cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition); color: var(--text-light);
  }
  .card-action-btn:hover { background: var(--primary-light); color: white; }
  .card-action-btn.danger:hover { background: var(--danger); color: white; }
  .card-action-btn .material-icons-round { font-size: 18px; }

  .voucher-code-box {
    background: var(--bg); border: 2px dashed var(--primary-light);
    border-radius: var(--radius-sm); padding: 10px;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
  }
  .voucher-code {
    font-size: 18px; font-weight: 700; color: var(--primary);
    letter-spacing: 2px; font-family: monospace;
  }
  .copy-btn {
    border: none; background: var(--primary); color: white;
    padding: 4px 12px; border-radius: 6px; cursor: pointer;
    font-size: 12px; font-weight: 600; transition: var(--transition);
  }
  .copy-btn:hover { background: var(--primary-dark); }

  .use-voucher-btn {
    width: 100%; padding: 10px; border: none; cursor: pointer;
    background: var(--success); color: white;
    border-radius: var(--radius-sm); font-family: inherit;
    font-size: 14px; font-weight: 600; transition: var(--transition);
    display: flex; align-items: center; justify-content: center; gap: 6px;
  }
  .use-voucher-btn:hover { background: #00A884; }
  .use-voucher-btn.used { background: var(--text-light); cursor: default; }

  /* Empty State */
  .empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-light);
  }
  .empty-state .material-icons-round { font-size: 64px; margin-bottom: 12px; opacity: 0.3; }
  .empty-state p { margin-bottom: 16px; }

  /* Modals */
  .modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    align-items: flex-start; justify-content: center;
    padding: 20px; overflow-y: auto;
  }
  .modal-overlay.active { display: flex; animation: fadeIn 0.2s ease; }
  .modal {
    background: var(--card-bg); border-radius: var(--radius);
    width: 100%; max-width: 640px;
    overflow: visible; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    margin: auto 0;
  }
  .modal-sm { max-width: 440px; }
  .modal-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card-bg); z-index: 1;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .modal-header h3 { font-size: 17px; font-weight: 600; }
  .close-btn {
    border: none; background: var(--bg); cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-light); transition: var(--transition);
  }
  .close-btn:hover { background: var(--danger); color: white; }
  .modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
  .modal-footer {
    padding: 14px 20px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
    background: var(--card-bg);
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .form-group { display: flex; flex-direction: column; gap: 4px; }
  .form-group label { font-size: 13px; font-weight: 600; color: var(--text-light); }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-group input, .form-group select, .form-group textarea {
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; font-family: inherit; font-size: 14px;
    outline: none; transition: var(--transition); color: var(--text);
    background: white;
    min-width: 0;
    width: 100%;
  }
  .form-group select {
    min-height: 42px;
    cursor: pointer;
  }
  .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,0.1);
  }

  .image-upload {
    border: 2px dashed var(--border); border-radius: var(--radius-sm);
    padding: 16px; text-align: center; cursor: pointer;
    transition: var(--transition); position: relative; overflow: hidden;
    min-height: 150px; display: grid; place-items: center;
  }
  .image-upload:hover { border-color: var(--primary-light); background: rgba(108,92,231,0.02); }
  .image-upload input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
  }
  .upload-placeholder { color: var(--text-light); }
  .upload-placeholder .material-icons-round { font-size: 36px; margin-bottom: 4px; }
  .upload-placeholder p { font-size: 13px; }
  .image-preview {
    width: 100%; max-height: min(260px, 45vh);
    object-fit: contain; border-radius: 8px;
  }

  .channel-select {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    max-height: 148px;
    overflow-y: auto;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    scrollbar-width: thin;
  }
  .channel-chip {
    min-width: 0;
    height: 36px;
    padding: 6px 10px; border-radius: 999px;
    border: 1.5px solid var(--border); background: white;
    font-size: 13px; cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; gap: 4px;
  }
  .channel-chip.selected { border-color: var(--primary); background: rgba(108,92,231,0.08); color: var(--primary); font-weight: 600; }
  .channel-chip:hover { border-color: var(--primary-light); }
  .channel-chip img { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto; }

  .btn-cancel {
    border: 1.5px solid var(--border); background: white;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px; cursor: pointer;
    color: var(--text-light); transition: var(--transition);
  }
  .btn-cancel:hover { background: var(--bg); }
  .btn-save {
    background: var(--primary); color: white; border: none;
    padding: 10px 24px; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    transition: var(--transition);
  }
  .btn-save:hover { background: var(--primary-dark); }
  .btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

  /* Settings */
  #tab-settings.active {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
  }
  .settings-section {
    background: rgba(255,255,255,0.94); border-radius: var(--radius);
    padding: 14px;
    border: 1px solid rgba(226,232,240,0.95); box-shadow: var(--shadow);
    min-width: 0;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 190px);
  }
  .settings-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
  }
  .settings-section h2 {
    font-size: 15px; font-weight: 600; margin: 0;
    display: flex; align-items: center; gap: 8px;
    min-width: 0;
    line-height: 1.35;
  }
  .settings-section h2 .material-icons-round { font-size: 22px; color: var(--primary); }
  .settings-section .add-btn {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }
  .settings-list {
    display: flex; flex-direction: column; gap: 8px;
    min-height: 120px;
    overflow-y: auto;
    padding: 2px 4px 4px 2px;
    scrollbar-width: thin;
  }
  .settings-list::-webkit-scrollbar { width: 6px; }
  .settings-list::-webkit-scrollbar-thumb {
    background: rgba(99,110,114,0.25);
    border-radius: 999px;
  }
  .settings-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; background: #F8FAFC; border-radius: var(--radius-sm);
    border: 1px solid transparent;
    gap: 10px;
  }
  .settings-item:hover {
    background: white;
    border-color: var(--border);
  }
  .settings-item-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .settings-item-info span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .settings-item-info img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
  .settings-item-info .cat-icon {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
  }
  .settings-item-actions { display: flex; gap: 4px; flex: 0 0 auto; }

  /* Toast */
  .toast {
    position: fixed; bottom: -60px; left: 50%; transform: translateX(-50%);
    background: var(--text); color: white;
    padding: 12px 24px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500;
    z-index: 9999; transition: bottom 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  }
  .toast.show { bottom: 24px; }

  /* Detail Modal */
  .modal-detail {
    max-width: min(720px, 100%); border-radius: var(--radius);
    overflow: visible;
  }
  .detail-header {
    position: relative; min-height: 60px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
  }
  .detail-header-img {
    width: 100%; max-height: min(380px, 45vh);
    object-fit: contain; display: block;
    background: linear-gradient(135deg, rgba(162,155,254,0.24), rgba(0,206,201,0.18));
  }
  .detail-close-btn {
    position: absolute; top: 12px; right: 12px; z-index: 2;
    border: none; background: rgba(0,0,0,0.4); color: white;
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition); backdrop-filter: blur(4px);
  }
  .detail-close-btn:hover { background: var(--danger); }

  .detail-body { padding: 24px; }
  .detail-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
  .detail-badge {
    padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  }
  .detail-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; line-height: 1.3; }
  .detail-subtitle { font-size: 14px; color: var(--text-light); margin-bottom: 16px; }
  .detail-discount-box {
    background: linear-gradient(135deg, #FFF5F5, #FFF0F0);
    border: 1.5px solid #FFCCCC;
    border-radius: var(--radius-sm); padding: 14px 18px;
    margin-bottom: 18px; text-align: center;
  }
  .detail-discount-label { font-size: 12px; color: var(--danger); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
  .detail-discount-value { font-size: 28px; font-weight: 800; color: var(--danger); margin-top: 2px; }
  .detail-discount-min { font-size: 13px; color: var(--text-light); margin-top: 4px; }

  .detail-voucher-code {
    background: var(--bg); border: 2px dashed var(--primary-light);
    border-radius: var(--radius-sm); padding: 14px;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px;
  }
  .detail-voucher-code .voucher-code { font-size: 22px; }

  .detail-info-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    margin-bottom: 18px;
  }
  .detail-info-item {
    background: var(--bg); border-radius: var(--radius-sm); padding: 12px;
  }
  .detail-info-label {
    font-size: 11px; font-weight: 600; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
    display: flex; align-items: center; gap: 4px;
  }
  .detail-info-label .material-icons-round { font-size: 14px; }
  .detail-info-value { font-size: 14px; font-weight: 600; color: var(--text); }

  .detail-desc {
    margin-bottom: 18px; padding: 14px;
    background: var(--bg); border-radius: var(--radius-sm);
  }
  .detail-desc-label {
    font-size: 11px; font-weight: 600; color: var(--text-light);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
  }
  .detail-desc-text { font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; }

  .detail-channels {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px;
  }
  .detail-channel-chip {
    padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
    background: var(--bg); border: 1.5px solid var(--border);
    display: flex; align-items: center; gap: 6px;
  }
  .detail-channel-chip img { width: 18px; height: 18px; border-radius: 50%; }

  .detail-countdown-box {
    text-align: center; padding: 12px; border-radius: var(--radius-sm);
    margin-bottom: 12px;
  }
  .detail-countdown-box.green { background: rgba(0,184,148,0.1); color: var(--success); }
  .detail-countdown-box.yellow { background: rgba(243,156,18,0.1); color: #E67E22; }
  .detail-countdown-box.red { background: rgba(255,107,107,0.1); color: var(--danger); }
  .detail-countdown-text { font-size: 16px; font-weight: 700; }

  .detail-footer {
    padding: 14px 24px; border-top: 1px solid var(--border);
    display: flex; gap: 10px; justify-content: flex-end;
    flex-wrap: wrap;
    border-radius: 0 0 var(--radius) var(--radius);
  }
  .detail-btn {
    padding: 10px 20px; border-radius: var(--radius-sm); border: none;
    font-family: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    transition: var(--transition);
  }
  .detail-btn-edit { background: var(--primary); color: white; }
  .detail-btn-edit:hover { background: var(--primary-dark); }
  .detail-btn-delete { background: white; color: var(--danger); border: 1.5px solid var(--danger); }
  .detail-btn-delete:hover { background: var(--danger); color: white; }
  .detail-btn-use { background: var(--success); color: white; }
  .detail-btn-use:hover { background: #00A884; }
  .detail-btn-copy { background: var(--accent); color: white; }
  .detail-btn-copy:hover { opacity: 0.85; }

  /* Responsive */
  @media (max-width: 768px) {
    .top-nav { flex-direction: column; gap: 8px; padding: 12px 16px; }
    .nav-tabs { width: 100%; justify-content: center; }
    .tab-btn span:last-child { display: none; }
    .app-hero {
      grid-template-columns: 1fr;
      padding: 0 16px;
      margin-top: 14px;
    }
    .summary-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .filter-bar {
      grid-template-columns: 1fr;
      margin: 14px 16px 0;
      padding: 12px 16px;
      gap: 10px;
    }
    .status-filter { justify-content: flex-start; }
    .filter-groups { grid-template-columns: 1fr; }
    .filter-section {
      padding: 9px;
    }
    .filter-scroll { padding-bottom: 4px; }
    .cat-btn, .brand-btn, .channel-btn { max-width: 180px; }
    .content { padding: 16px; }
    .card-grid { grid-template-columns: 1fr; gap: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .section-header { flex-direction: column; gap: 10px; align-items: stretch; }
    .section-actions { justify-content: stretch; }
    .section-actions .add-btn, .sort-control { flex: 1 1 180px; }
    .sort-control select { width: 100%; }
    #tab-settings.active {
      grid-template-columns: 1fr;
    }
    .settings-section {
      max-height: none;
    }
    .settings-list {
      max-height: 320px;
    }
    .detail-info-grid { grid-template-columns: 1fr; }
    .modal-detail { max-width: 100%; }
  }
  @media (max-width: 520px) {
    .top-nav { position: static; }
    .nav-tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
    .tab-btn { justify-content: center; padding: 9px 10px; }
    .hero-copy { padding: 18px; }
    .hero-copy h2 { font-size: 20px; }
    .summary-grid { grid-template-columns: 1fr; }
    .summary-card { padding: 14px; }
    .status-filter {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .status-btn { padding: 8px 10px; }
    .card-footer { align-items: flex-start; flex-direction: column; }
    .card-actions { width: 100%; justify-content: flex-end; }
    .modal-overlay { padding: 10px; }
    .modal-body, .detail-body { padding: 16px; }
    .modal-footer, .detail-footer { padding: 12px 16px; }
    .detail-btn, .btn-cancel, .btn-save { flex: 1 1 auto; justify-content: center; }
    .settings-section-head {
      align-items: stretch;
      flex-direction: column;
    }
    .settings-section .add-btn {
      justify-content: center;
      width: 100%;
    }
  }