:root{
    --bg:#F7F5EF;
    --surface:#FFFFFF;
    --ink:#211F1B;
    --ink-soft:#5B584F;
    --line:#E3DFD3;
    --line-strong:#CFC9B8;
    --forest:#2E5339;
    --forest-dark:#203A28;
    --gold:#B9812E;
    --gold-soft:#F3E4C6;
    --danger:#B3392F;
    --radius:10px;
    --radius-lg:16px;
    --shadow:0 1px 2px rgba(33,31,27,0.06), 0 4px 16px rgba(33,31,27,0.05);
    --font-display:'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  }
  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;}
  body{
    background:var(--bg);
    color:var(--ink);
    font-family:var(--font-body);
    font-size:15px;
    line-height:1.5;
    -webkit-font-smoothing:antialiased;
  }
  a{color:var(--forest);}

  /* ---------- header ---------- */
  header.app-head{
    position:relative;
    background:var(--forest);
    color:#F3F1E7;
    padding:30px 24px 26px;
    overflow:hidden;
  }
  header.app-head::before{
    content:"";
    position:absolute; inset:0;
    background-image:
      radial-gradient(circle at 8% 30%, rgba(255,255,255,0.05) 0, transparent 45%),
      repeating-linear-gradient(115deg, rgba(255,255,255,0.035) 0 2px, transparent 2px 34px);
    pointer-events:none;
  }
  .head-inner{position:relative; max-width:1080px; margin:0 auto; display:flex; align-items:flex-end; justify-content:space-between; gap:20px; flex-wrap:wrap;}
  .brand{display:flex; align-items:center; gap:14px;}
  .brand svg{flex:none; opacity:0.92;}
  h1{
    font-family:var(--font-display);
    font-weight:600;
    font-size:30px;
    letter-spacing:-0.01em;
    margin:0;
  }
  .brand-sub{font-size:13px; color:#D8D2BE; margin-top:2px; letter-spacing:0.02em;}
  .head-actions{display:flex; gap:8px; flex-wrap:wrap;}

  /* ---------- buttons ---------- */
  button{
    font-family:var(--font-body);
    cursor:pointer;
    border:1px solid transparent;
    border-radius:8px;
    font-size:13.5px;
    font-weight:600;
    padding:9px 14px;
    transition:background .12s ease, border-color .12s ease, transform .05s ease;
  }
  button:active{transform:translateY(1px);}
  button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible{
    outline:3px solid #7FB2E5; outline-offset:1px;
  }
  .btn-primary{background:var(--gold); color:#2A1D06; border-color:var(--gold);}
  .btn-primary:hover{background:#C79038;}
  .btn-ghost{background:rgba(255,255,255,0.08); color:#F3F1E7; border-color:rgba(255,255,255,0.28);}
  .btn-ghost:hover{background:rgba(255,255,255,0.16);}
  .btn-soft{background:#EFEBDD; color:var(--ink); border-color:var(--line-strong);}
  .btn-soft:hover{background:#E7E1CD;}
  .btn-danger-text{background:transparent; color:var(--danger); border:none; padding:6px 8px; font-weight:600;}
  .btn-danger-text:hover{text-decoration:underline;}
  .btn-icon{background:transparent; border:none; color:var(--ink-soft); padding:4px 6px; font-size:16px; line-height:1;}
  .btn-icon:hover{color:var(--danger);}

  /* ---------- layout ---------- */
  main{max-width:1080px; margin:0 auto; padding:22px 24px 60px;}
  nav.tabs{
    display:flex; gap:4px; margin-bottom:20px; border-bottom:1px solid var(--line);
    overflow-x:auto;
  }
  nav.tabs button{
    background:none; border:none; border-radius:0;
    padding:11px 16px 12px; font-size:14px; color:var(--ink-soft);
    border-bottom:2px solid transparent; white-space:nowrap;
  }
  nav.tabs button.active{color:var(--forest); border-bottom-color:var(--forest); font-weight:700;}
  nav.tabs button:hover{color:var(--forest);}

  .panel{display:none;}
  .panel.active{display:block; animation:fade .15s ease;}
  @keyframes fade{from{opacity:0; transform:translateY(2px);} to{opacity:1; transform:none;}}

  .panel-head{display:flex; justify-content:space-between; align-items:flex-end; gap:16px; margin-bottom:14px; flex-wrap:wrap;}
  .panel-head h2{font-family:var(--font-display); font-size:21px; font-weight:600; margin:0 0 4px;}
  .panel-head p{margin:0; color:var(--ink-soft); font-size:13.5px; max-width:56ch;}

  .card{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-lg); box-shadow:var(--shadow); overflow-x:auto;}
  .card > table{min-width:620px;}

  table{width:100%; border-collapse:collapse;}
  th{
    text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:0.06em;
    color:var(--ink-soft); font-weight:700; padding:11px 14px; border-bottom:1px solid var(--line);
    background:#FBFAF6;
  }
  td{padding:9px 14px; border-bottom:1px solid var(--line); vertical-align:middle;}
  tr:last-child td{border-bottom:none;}
  tbody tr:hover{background:#FBFAF6;}
  td.num{color:var(--ink-soft); font-variant-numeric:tabular-nums;}

  input[type=text], input[type=search], textarea, select{
    font-family:var(--font-body); font-size:14px; color:var(--ink);
    background:#fff; border:1px solid var(--line-strong); border-radius:7px;
    padding:7px 10px; width:100%;
  }
  input[type=color]{
    width:40px; height:30px; padding:2px; border:1px solid var(--line-strong); border-radius:7px; background:#fff;
  }
  .row-inline{display:flex; gap:8px; align-items:center;}

  .pill-select{
    appearance:none; -webkit-appearance:none;
    border:1px solid rgba(0,0,0,0.12); border-radius:999px;
    font-weight:700; font-size:12.5px; letter-spacing:0.01em;
    padding:5px 26px 5px 12px; min-width:96px;
    background-repeat:no-repeat; background-position:right 9px center; background-size:9px;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23000' stroke-opacity='0.45' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    text-overflow:ellipsis; overflow:hidden; white-space:nowrap;
  }
  .pill-none{background:#EDEAE0; color:#8B8874; border-color:var(--line-strong);}

  .dash-cell{color:#C7C2B2; text-align:center; font-size:13px;}
  .swatch{display:inline-block; width:16px; height:16px; border-radius:5px; border:1px solid rgba(0,0,0,0.15); vertical-align:-3px; margin-right:7px;}

  .empty-state{padding:40px 20px; text-align:center; color:var(--ink-soft);}
  .empty-state strong{display:block; color:var(--ink); font-size:15px; margin-bottom:4px;}

  .toggle{position:relative; display:inline-block; width:38px; height:22px;}
  .toggle input{opacity:0; width:0; height:0;}
  .toggle span{position:absolute; inset:0; background:#D8D3C2; border-radius:999px; transition:.15s;}
  .toggle span::before{content:""; position:absolute; width:16px; height:16px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.15s; box-shadow:0 1px 2px rgba(0,0,0,.25);}
  .toggle input:checked + span{background:var(--forest);}
  .toggle input:checked + span::before{transform:translateX(16px);}
  .toggle input:focus-visible + span{outline:3px solid #7FB2E5; outline-offset:2px;}

  .status-badge{font-size:12px; padding:2px 8px; border-radius:999px; font-weight:700; display:inline-block;}
  .status-inactive{background:#EDEAE0; color:#8B8874;}
  .status-active{background:#E1EEE2; color:var(--forest-dark);}

  .matrix-wrap{overflow:auto; border:1px solid var(--line); border-radius:var(--radius-lg); background:#fff;}
  table.matrix{min-width:100%;}
  table.matrix th, table.matrix td{border:1px solid var(--line); padding:0;}
  table.matrix th{
    background:var(--forest); color:#F3F1E7; font-size:11.5px; padding:8px 10px;
    position:sticky; top:0; z-index:2; white-space:nowrap;
  }
  table.matrix th.corner{position:sticky; left:0; top:0; z-index:3; background:var(--forest-dark);}
  table.matrix td.rowhead{
    background:var(--forest); color:#F3F1E7; font-weight:700; font-size:12.5px;
    padding:8px 10px; position:sticky; left:0; z-index:1; white-space:nowrap;
  }
  table.matrix td.cell{width:74px; height:40px; text-align:center;}
  table.matrix select.pill-select{width:100%; height:100%; border-radius:0; border:none; text-align:center; padding:4px 20px 4px 6px; font-size:11.5px;}

  footer.app-foot{max-width:1080px; margin:0 auto; padding:0 24px 50px; color:var(--ink-soft); font-size:12.5px;}
  footer.app-foot a{color:var(--forest); font-weight:600;}
  details.help summary{cursor:pointer; font-weight:600; color:var(--ink); padding:8px 0;}
  details.help[open] summary{margin-bottom:4px;}
  details.help ul{margin:6px 0 4px 18px; padding:0;}
  details.help li{margin-bottom:5px;}

  .toast{
    position:fixed; bottom:20px; left:50%; transform:translateX(-50%) translateY(20px);
    background:var(--ink); color:#fff; padding:10px 18px; border-radius:8px; font-size:13.5px;
    box-shadow:0 8px 24px rgba(0,0,0,0.25); opacity:0; pointer-events:none; transition:.2s;
    z-index:50;
  }
  .toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

  input[type=file]{display:none;}

  .sync-status{font-size:12px; color:#D8D2BE; display:inline-flex; align-items:center; gap:6px; margin-right:4px;}
  .sync-dot{width:7px; height:7px; border-radius:50%; background:#8FBF7A; flex:none;}
  .sync-status.offline .sync-dot{background:#E3A83B;}
  .sync-status.saving .sync-dot{animation:pulse 1s ease-in-out infinite;}
  @keyframes pulse{0%,100%{opacity:1;} 50%{opacity:.35;}}

  .loading-banner{
    display:flex; align-items:center; justify-content:center; gap:10px;
    padding:40px 20px; color:var(--ink-soft); font-size:14px;
  }
  .loading-spin{
    width:16px; height:16px; border-radius:50%; border:2px solid var(--line-strong);
    border-top-color:var(--forest); animation:spin .7s linear infinite;
  }
  @keyframes spin{to{transform:rotate(360deg);}}

  @media (max-width:640px){
    header.app-head{padding:22px 16px 20px;}
    main{padding:16px 16px 60px;}
    h1{font-size:24px;}
    td, th{padding:8px 9px;}
  }
