/* Trang tạo thiệp — cùng bảng màu nâu–kem với app.willhouse.vn */
:root{
  --bg:#fbf8f3;--surface:#fffdfc;--surface-2:#faf5ef;--cream:#f4e8d7;
  --brand:#8a5a2b;--brand-hover:#70461f;--brand-soft:#f5ede3;
  --ink:#49301e;--muted:#6b625b;--border:#e9e1d8;--border-strong:#d8cbbb;
  --shadow:0 8px 30px rgba(72,49,30,.08);--danger:#b91c1c;--ok:#15803d;
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Be Vietnam Pro',system-ui,sans-serif;background:var(--bg);color:var(--ink);font-size:14px;line-height:1.5}
button,input,select,textarea{font:inherit;color:inherit}

.top{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:14px;padding:12px 24px;
  background:rgba(251,248,243,.92);backdrop-filter:blur(10px);border-bottom:1px solid var(--border)}
.brand{display:flex;flex-direction:column;line-height:1.15}
.brand b{letter-spacing:.28em;font-size:14px}
.brand span{font-size:12px;color:var(--muted)}
.demo-badge{font-size:11.5px;padding:4px 10px;border-radius:999px;background:#fef3c7;color:#92400e;font-weight:600}
.top-actions{margin-left:auto;display:flex;gap:8px}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:9px 14px;border-radius:10px;
  border:1px solid var(--border-strong);background:var(--surface);cursor:pointer;font-weight:600;font-size:13.5px;text-decoration:none;white-space:nowrap}
.btn:hover{background:var(--brand-soft)}
.btn.primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn.primary:hover{background:var(--brand-hover)}
.btn.small{padding:7px 12px;font-size:13px}
.btn.big{padding:14px 22px;font-size:15px;width:100%}
.btn.danger{color:var(--danger)}
.btn:disabled{opacity:.55;cursor:wait}
.count{background:var(--brand);color:#fff;border-radius:999px;padding:0 7px;font-size:11.5px;min-width:20px}
.link-btn{background:none;border:0;color:var(--brand);font-weight:600;cursor:pointer;padding:6px 0;font-size:13px}

.layout{display:grid;grid-template-columns:minmax(0,1fr) 420px;gap:28px;max-width:1240px;margin:0 auto;padding:24px}
.panel{display:grid;gap:16px;align-content:start;min-width:0}
.card{background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:18px 20px;display:grid;gap:12px;box-shadow:0 1px 2px rgba(72,49,30,.05)}
.card h2{font-size:15px;display:flex;align-items:center;gap:10px}
.card h2 span{width:24px;height:24px;border-radius:50%;background:var(--brand-soft);color:var(--brand);display:grid;place-items:center;font-size:12.5px}
.card h2 small,label small{font-weight:400;color:var(--muted)}
label{display:block;font-weight:600;font-size:13px}
label > input:not([type=checkbox]):not([type=color]),label > select,label > textarea{display:block;margin-top:5px}
.req{color:var(--danger)}
input:not([type=checkbox]):not([type=color]),select,textarea{width:100%;padding:9px 11px;border:1px solid var(--border-strong);border-radius:10px;background:#fff;font-weight:400;font-size:14px}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px rgba(138,90,43,.15)}
input.invalid{border-color:var(--danger);box-shadow:0 0 0 3px rgba(185,28,28,.12)}
textarea{resize:vertical;line-height:1.55}
.row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.row.three{grid-template-columns:1.3fr 1fr 1fr}
.hint{color:var(--muted);font-size:12.5px}
.hint.small{font-size:12px}
.import-bar{background:#ecfdf5;border:1px solid #a7f3d0;border-radius:14px;padding:12px 16px;font-size:13px;color:#14532d}
.import-bar b{font-size:14px}
.import-bar ul{margin:6px 0 0 18px;color:#92400e}
.import-bar li{margin-top:3px}
.import-bar .x{float:right;border:0;background:none;font-size:18px;cursor:pointer;color:#14532d;line-height:1}
.editing-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;background:var(--cream);border:1px solid var(--border-strong);border-radius:12px;padding:10px 14px;font-size:13px}

/* mẫu thiệp */
.tpl-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:10px}
.tpl{border:2px solid var(--border);border-radius:14px;padding:0;background:none;cursor:pointer;overflow:hidden;text-align:center;transition:border-color .15s,transform .15s}
.tpl:hover{transform:translateY(-2px)}
.tpl.on{border-color:var(--brand);box-shadow:0 0 0 3px rgba(138,90,43,.18)}
.tpl .sw{aspect-ratio:3/4;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;position:relative;overflow:hidden}
.tpl .sw .nm{font-size:26px;line-height:1}
.tpl .sw .bar{width:40%;height:3px;border-radius:2px}
.tpl .sw .dots{display:flex;gap:3px;position:absolute;bottom:8px}
.tpl .sw .dots i{width:9px;height:9px;border-radius:50%}
.tpl .lbl{padding:7px 4px 8px;font-size:12px;font-weight:600;background:var(--surface)}
.tpl .lbl small{display:block;font-weight:400;color:var(--muted);font-size:10.5px;line-height:1.3;margin-top:1px}

/* bảng màu */
.pal-row{display:flex;flex-wrap:wrap;gap:8px}
.pal{display:flex;align-items:center;gap:8px;padding:6px 12px 6px 6px;border-radius:999px;border:1.5px solid var(--border);background:#fff;cursor:pointer;font-size:12.5px;font-weight:600}
.pal.on{border-color:var(--brand);background:var(--brand-soft)}
.pal .chips{display:flex}
.pal .chips i{width:18px;height:18px;border-radius:50%;border:2px solid #fff;margin-left:-6px}
.pal .chips i:first-child{margin-left:0}
.custom-colors summary{cursor:pointer;font-weight:600;color:var(--brand);font-size:13px;padding:4px 0}
.color-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-top:10px}
.color-grid label{display:flex;flex-direction:column;align-items:center;gap:4px;font-weight:500;font-size:12px}
.color-grid input{width:48px;height:48px;border:1px solid var(--border-strong);border-radius:12px;padding:3px;background:#fff;cursor:pointer}

/* chương trình */
.tl-list{display:grid;gap:8px}
.tl-row{display:grid;grid-template-columns:92px 1fr 1.3fr 34px;gap:6px;align-items:center}
.tl-row .rm{border:0;background:none;color:var(--muted);font-size:18px;cursor:pointer;height:34px;border-radius:8px}
.tl-row .rm:hover{background:#fee2e2;color:var(--danger)}

/* ảnh */
.cover-pick{display:flex;gap:14px;align-items:center}
.cover-thumb{width:84px;height:106px;border-radius:12px;background:var(--surface-2) center/cover;border:1px dashed var(--border-strong);flex:none}
.cover-pick > div:last-child{display:grid;gap:8px;justify-items:start}
.file-btn{display:inline-flex;font-weight:600}
.album-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:6px}
.album-grid:empty{display:none}
.ab{position:relative;aspect-ratio:1;border-radius:10px;overflow:hidden;background:var(--surface-2) center/cover;border:0;cursor:pointer}
.ab.is-cover::after{content:"Bìa";position:absolute;left:4px;top:4px;background:var(--brand);color:#fff;font-size:10px;padding:1px 6px;border-radius:6px}
.ab-menu{position:absolute;inset:0;background:rgba(40,25,15,.7);display:none;flex-direction:column;justify-content:center;gap:4px;padding:4px}
.ab.open .ab-menu{display:flex}
.ab-menu span{color:#fff;font-size:11px;font-weight:600;padding:3px;border-radius:6px}
.ab-menu span:hover{background:rgba(255,255,255,.2)}
.upload-msg{font-size:12.5px;color:var(--muted);min-height:1em}

/* công tắc */
.switch{display:flex;align-items:center;gap:10px;font-weight:500;cursor:pointer}
.switch input{position:absolute;opacity:0;pointer-events:none}
.switch span{width:38px;height:22px;border-radius:999px;background:var(--border-strong);position:relative;flex:none;transition:background .2s}
.switch span::after{content:"";position:absolute;left:3px;top:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .2s}
.switch input:checked + span{background:var(--brand)}
.switch input:checked + span::after{transform:translateX(16px)}
.switch input:focus-visible + span{outline:2px solid var(--brand);outline-offset:2px}

.sheet-box{display:grid;gap:10px;padding:14px;border-radius:12px;background:var(--surface-2);border:1px solid var(--border)}
.sheet-result{margin-top:12px;padding:10px 12px;border-radius:10px;font-size:13px;background:#dcfce7;color:#14532d}
.sheet-result.err{background:#fef3c7;color:#92400e}
.sheet-result a{color:inherit;font-weight:600}
.save-bar{position:sticky;bottom:12px;background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:12px;box-shadow:var(--shadow)}
.save-bar .err{color:var(--danger);font-size:13px;margin-bottom:8px}
.save-bar .err:empty{display:none}

/* xem trước */
.preview{position:sticky;top:88px;align-self:start;display:flex;flex-direction:column;align-items:center}
.phone{width:390px;height:min(800px,calc(100vh - 140px));border-radius:46px;background:#1c1714;padding:12px;position:relative;box-shadow:0 30px 60px rgba(72,49,30,.25)}
.phone iframe{width:100%;height:100%;border:0;border-radius:36px;background:#fff;display:block}
.notch{position:absolute;top:20px;left:50%;width:110px;height:28px;margin-left:-55px;border-radius:20px;background:#1c1714;z-index:2}
.preview-cap{font-size:12.5px;color:var(--muted)}
.preview-actions{display:flex;align-items:center;gap:12px;margin-top:12px}

/* hộp thoại */
.dlg{border:0;border-radius:20px;padding:22px;width:min(440px,calc(100vw - 32px));margin:auto;box-shadow:0 30px 80px rgba(0,0,0,.25);color:var(--ink);background:var(--surface)}
.dlg.wide{width:min(820px,calc(100vw - 32px))}
.dlg::backdrop{background:rgba(40,25,15,.45)}
.dlg h3{font-size:18px;margin-bottom:4px}
.dlg-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.dlg .x{border:0;background:none;font-size:26px;line-height:1;cursor:pointer;color:var(--muted);width:36px;height:36px;border-radius:10px}
.dlg .x:hover{background:var(--brand-soft)}
.link-box{display:flex;gap:8px;margin:14px 0}
.link-box input{font-size:13px}
.qr{display:grid;place-items:center;padding:14px;background:#fff;border-radius:14px;border:1px solid var(--border)}
.qr img,.qr canvas{width:180px!important;height:180px!important}
.dlg-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap}

.inv-list{display:grid;gap:8px;max-height:65vh;overflow:auto}
.inv-item{display:grid;grid-template-columns:44px 1fr auto;gap:12px;align-items:center;padding:10px 12px;border:1px solid var(--border);border-radius:14px}
.inv-item .sw{width:44px;height:44px;border-radius:12px;background:var(--surface-2) center/cover;display:grid;place-items:center;color:#fff;font-weight:700}
.inv-item b{display:block}
.inv-item .meta{font-size:12.5px;color:var(--muted)}
.inv-item .acts{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.empty{text-align:center;padding:30px;color:var(--muted)}

.rsvp-stats{display:flex;gap:10px;margin-bottom:14px;flex-wrap:wrap}
.rsvp-stats div{flex:1;min-width:120px;padding:12px 14px;border-radius:14px;background:var(--surface-2)}
.rsvp-stats b{display:block;font-size:22px}
.rsvp-stats span{font-size:12px;color:var(--muted)}
.tbl-wrap{max-height:55vh;overflow:auto;border:1px solid var(--border);border-radius:12px}
table{width:100%;border-collapse:collapse;font-size:13px}
th,td{text-align:left;padding:9px 12px;border-bottom:1px solid var(--border);vertical-align:top}
th{background:var(--surface-2);position:sticky;top:0;font-size:12px;color:var(--muted)}
.tag{display:inline-block;padding:1px 8px;border-radius:999px;font-size:11.5px;font-weight:600}
.tag.yes{background:#dcfce7;color:var(--ok)}.tag.no{background:#fee2e2;color:var(--danger)}

.toast{position:fixed;left:50%;bottom:24px;transform:translate(-50%,20px);background:#2b1d13;color:#fff;padding:10px 18px;border-radius:999px;
  font-size:13.5px;opacity:0;pointer-events:none;transition:.25s;z-index:100}
.toast.on{opacity:1;transform:translate(-50%,0)}

.mobile-tabs{display:none}

[hidden]{display:none!important}
.login{position:fixed;inset:0;z-index:200;display:grid;place-items:center;padding:16px;background:var(--bg)}
.login-card{width:min(360px,100%);display:grid;gap:14px;background:var(--surface);border:1px solid var(--border);border-radius:20px;padding:28px 24px;box-shadow:var(--shadow)}
.login-card .err{color:var(--danger);font-size:13px;min-height:1em}

@media (max-width:1100px){
  .tpl-grid{grid-template-columns:repeat(3,1fr)}
  .layout{grid-template-columns:minmax(0,1fr) 360px}
  .phone{width:340px}
}
@media (max-width:860px){
  .top{padding:10px 16px;flex-wrap:wrap}
  .demo-badge{order:3;width:100%;text-align:center}
  .top-actions .btn{padding:8px 10px;font-size:12.5px}
  .layout{grid-template-columns:1fr;padding:16px 16px 90px}
  .layout[data-tab=form] .preview{display:none}
  .layout[data-tab=preview] .panel{display:none}
  .preview{position:static}
  .phone{width:100%;max-width:390px;height:calc(100vh - 200px);border-radius:36px;padding:8px}
  .phone iframe{border-radius:30px}
  .notch{display:none}
  .row,.row.three{grid-template-columns:1fr}
  .tpl-grid{grid-template-columns:repeat(3,1fr)}
  .album-grid{grid-template-columns:repeat(4,1fr)}
  .tl-row{grid-template-columns:80px 1fr 34px}
  .tl-row input[data-f=desc]{grid-column:1 / 3}
  .save-bar{position:static}
  .mobile-tabs{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:30;background:var(--surface);border-top:1px solid var(--border);padding:8px 12px calc(8px + env(safe-area-inset-bottom));gap:8px}
  .mobile-tabs button{flex:1;padding:11px;border-radius:12px;border:1px solid var(--border);background:var(--surface);font-weight:600}
  .mobile-tabs button.on{background:var(--brand);border-color:var(--brand);color:#fff}
  .inv-item{grid-template-columns:44px 1fr}
  .inv-item .acts{grid-column:1 / -1;justify-content:flex-start}
}
