html,body{height:100%; margin:0; padding:0;}
:root{
    --ink:#0B2A45;
    --ink-2:#123A5E;
    --orange:#EF8A17;
    --orange-ink:#8a4c05;
    --green:#189A56;
    --green-ink:#0d5c33;
    --paper:#F2F5F3;
    --surface:#FFFFFF;
    --line:#DDE4E1;
    --text:#152A33;
    --muted:#5B6C71;
    --danger:#D8483F;
    --shadow: 0 10px 30px -12px rgba(11,42,69,.18);
    --focus: 0 0 0 3px rgba(239,138,23,.35);
  }
  @media (prefers-color-scheme: dark){
    :root:not([data-theme="light"]){
      --paper:#0B1620;
      --surface:#101E29;
      --line:#223341;
      --text:#E7EEF1;
      --muted:#93A4AB;
      --ink:#0B2A45;
      --ink-2:#0E2338;
      --shadow: 0 10px 30px -12px rgba(0,0,0,.55);
    }
  }
  :root[data-theme="dark"]{
    --paper:#0B1620;
    --surface:#101E29;
    --line:#223341;
    --text:#E7EEF1;
    --muted:#93A4AB;
    --ink:#0B2A45;
    --ink-2:#0E2338;
    --shadow: 0 10px 30px -12px rgba(0,0,0,.55);
  }

  *{box-sizing:border-box;}
  body{
    background:var(--paper);
    color:var(--text);
    font-family:'Manrope',system-ui,-apple-system,Segoe UI,sans-serif;
    -webkit-font-smoothing:antialiased;
  }
  h1,h2,h3,.disp{
    font-family:'Barlow Condensed',system-ui,sans-serif;
    letter-spacing:.2px;
    text-wrap:balance;
    margin:0;
  }
  button{font-family:inherit;}
  input{font-family:inherit;}
  a{color:inherit;}
  .tnum{font-variant-numeric:tabular-nums;}
  ::selection{background:rgba(239,138,23,.35);}
  :focus-visible{outline:none; box-shadow:var(--focus); border-radius:6px;}

  /* ---------- LOGIN ---------- */
  #login-screen{
    min-height:100%;
    display:flex; align-items:center; justify-content:center;
    padding:32px 16px;
    background:
      radial-gradient(1200px 600px at 15% -10%, rgba(239,138,23,.16), transparent 60%),
      radial-gradient(1200px 700px at 110% 10%, rgba(24,154,86,.18), transparent 55%),
      linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  }
  .login-card{
    width:100%; max-width:400px;
    background:var(--surface);
    border-radius:18px;
    box-shadow:var(--shadow);
    padding:28px 26px 26px;
    border:1px solid var(--line);
  }
  .login-brand{display:flex; align-items:center; gap:10px; margin-bottom:18px;}
  .login-brand h1{font-size:26px; font-weight:800; color:var(--text); line-height:1;}
  .login-brand .tag{font-size:11px; color:var(--muted); letter-spacing:.08em; text-transform:uppercase; margin-top:2px;}
  .login-club{
    display:flex; align-items:center; gap:10px;
    background:var(--paper); border:1px solid var(--line); border-radius:12px;
    padding:10px 12px; margin-bottom:20px;
  }
  .login-club .crest{width:34px;height:34px;flex:none;}
  .login-club b{font-size:14px;}
  .login-club span{display:block; font-size:12px; color:var(--muted);}
  .field{margin-bottom:14px;}
  .field label{display:block; font-size:12px; font-weight:700; color:var(--muted); margin-bottom:6px; letter-spacing:.03em;}
  .field .wrap{position:relative; display:flex; align-items:center;}
  .field .wrap svg{position:absolute; left:12px; width:16px; height:16px; color:var(--muted);}
  .field input{
    width:100%; padding:12px 12px 12px 36px; border-radius:10px;
    border:1.5px solid var(--line); background:var(--paper); color:var(--text);
    font-size:14px;
  }
  .field input:focus{border-color:var(--orange); background:var(--surface); box-shadow:var(--focus);}
  .field .toggle-pw{position:absolute; right:10px; background:none; border:none; cursor:pointer; color:var(--muted); padding:4px;}
  .btn-primary{
    width:100%; border:none; cursor:pointer;
    background:linear-gradient(180deg, var(--orange), #d97b0f);
    color:#fff; font-weight:800; font-size:15px; letter-spacing:.02em;
    padding:13px; border-radius:10px; margin-top:6px;
    box-shadow:0 8px 18px -8px rgba(239,138,23,.6);
  }
  .btn-primary:hover{filter:brightness(1.04);}
  .login-foot{display:flex; justify-content:space-between; align-items:center; margin-top:14px; font-size:12.5px;}
  .login-foot a{color:var(--green-ink); font-weight:700; text-decoration:none;}
  .login-hint{
    margin-top:16px; padding-top:14px; border-top:1px dashed var(--line);
    font-size:12px; color:var(--muted); text-align:center; line-height:1.5;
  }
  .login-hint b{color:var(--text);}
  .err{display:none; background:rgba(216,72,63,.12); color:#b23c34; border:1px solid rgba(216,72,63,.35); border-radius:8px; padding:8px 10px; font-size:12.5px; margin-bottom:12px; font-weight:600;}
  .auth-tabs{display:flex; gap:4px; background:var(--paper); border-radius:10px; padding:4px; margin-bottom:16px;}
  .auth-tab{flex:1; border:none; background:none; padding:9px 4px; font-size:13px; font-weight:800; color:var(--muted); border-radius:8px; cursor:pointer;}
  .auth-tab.active{background:var(--surface); color:var(--text); box-shadow:0 1px 4px rgba(0,0,0,.08);}
  .auth-form{display:none;}
  .auth-form.active{display:block;}
  .switch-auth{text-align:center; font-size:12.5px; color:var(--muted); margin:12px 0 0;}
  .switch-auth a{color:var(--orange-ink); font-weight:700; text-decoration:none;}
  .dbstatus{display:none; align-items:center; gap:8px; font-size:12px; color:var(--muted); background:var(--paper); border-radius:8px; padding:8px 10px; margin-bottom:12px;}
  .dbstatus.show{display:flex;}
  .dbstatus.warn{color:#b23c34; background:rgba(216,72,63,.1);}
  .dbstatus .spin{width:12px; height:12px; border-radius:50%; border:2px solid var(--line); border-top-color:var(--orange); flex:none; animation:spin 0.8s linear infinite;}
  @keyframes spin{to{transform:rotate(360deg);}}
  .field small.pwhint{display:block; font-size:11px; color:var(--muted); margin-top:5px;}

  /* ---------- LOGO ---------- */
  .crest{display:block;}

  /* ---------- APP SHELL ---------- */
  #app{display:none; min-height:100%; flex-direction:column;}
  .topbar{
    position:sticky; top:env(safe-area-inset-top,0px); z-index:40;
    display:flex; align-items:center; gap:16px;
    background:linear-gradient(180deg, var(--ink), var(--ink-2));
    color:#fff; padding:10px 16px; min-height:56px;
  }
  .topbar .brand{display:flex; align-items:center; gap:8px; flex:none;}
  .topbar .brand h1{font-size:20px; font-weight:800; color:#fff;}
  .topbar .club{
    font-size:13px; font-weight:700; background:rgba(255,255,255,.12);
    padding:4px 10px; border-radius:20px; border:1px solid rgba(255,255,255,.18);
    white-space:nowrap;
  }
  .searchbox{
    flex:1; max-width:420px; display:flex; align-items:center; gap:8px;
    background:rgba(255,255,255,.12); border:1px solid rgba(255,255,255,.16);
    border-radius:20px; padding:8px 14px; min-width:0;
  }
  .searchbox svg{width:15px;height:15px;flex:none;opacity:.85;}
  .searchbox input{background:none; border:none; color:#fff; font-size:13.5px; width:100%; outline:none;}
  .searchbox input::placeholder{color:rgba(255,255,255,.65);}
  .topbar .spacer{flex:1;}
  .icon-btn{
    position:relative; background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.16);
    width:38px; height:38px; border-radius:50%; display:flex; align-items:center; justify-content:center;
    cursor:pointer; color:#fff; flex:none;
  }
  .icon-btn svg{width:17px;height:17px;}
  .badge-dot{
    position:absolute; top:-3px; right:-3px; background:var(--orange); color:#fff;
    font-size:10px; font-weight:800; border-radius:20px; padding:1px 5px; line-height:1.3;
    border:2px solid var(--ink);
  }
  .profile-btn{
    display:flex; align-items:center; gap:8px; background:rgba(255,255,255,.1);
    border:1px solid rgba(255,255,255,.16); border-radius:24px; padding:5px 12px 5px 5px; cursor:pointer; color:#fff;
  }
  .avatar{
    width:28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center;
    font-size:11px; font-weight:800; color:#fff; flex:none; background:linear-gradient(135deg,var(--orange),var(--green));
  }
  .profile-btn .name{font-size:13px; font-weight:700;}
  .profile-btn .chev{font-size:9px; opacity:.7;}

  .dropdown{
    position:absolute; top:52px; right:16px; background:var(--surface); color:var(--text);
    border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow);
    width:280px; z-index:60; display:none; overflow:hidden;
  }
  .dropdown.open{display:block;}
  .dropdown h4{font-size:13px; padding:12px 14px; border-bottom:1px solid var(--line); color:var(--muted); text-transform:uppercase; letter-spacing:.05em; font-family:'Manrope'; font-weight:800;}
  .notif-item{padding:10px 14px; border-bottom:1px solid var(--line); font-size:13px; display:flex; gap:10px;}
  .notif-item:last-child{border-bottom:none;}
  .notif-item .dot{width:7px;height:7px;border-radius:50%;background:var(--orange); margin-top:5px; flex:none;}
  .notif-item.read .dot{background:var(--line);}
  .notif-item .t{color:var(--muted); font-size:11px; margin-top:2px;}
  .menu-item{display:flex; align-items:center; gap:10px; padding:11px 14px; font-size:13.5px; font-weight:600; cursor:pointer;}
  .menu-item:hover{background:var(--paper);}
  .menu-item svg{width:15px;height:15px; color:var(--muted);}
  .menu-item.danger{color:var(--danger);}

  .shell{flex:1; display:flex; min-height:0;}
  .sidebar{
    width:210px; flex:none; background:var(--surface); border-right:1px solid var(--line);
    padding:16px 10px; display:flex; flex-direction:column; gap:2px;
  }
  .nav-item{
    display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:10px;
    font-size:14px; font-weight:700; color:var(--muted); cursor:pointer; border:none; background:none; text-align:left; width:100%;
  }
  .nav-item svg{width:17px;height:17px;flex:none;}
  .nav-item:hover{background:var(--paper); color:var(--text);}
  .nav-item.active{background:rgba(239,138,23,.12); color:var(--orange-ink);}
  .nav-item.active svg{color:var(--orange);}
  .sidebar .sep{height:1px; background:var(--line); margin:10px 4px;}
  .sidebar .slogan{margin-top:auto; font-size:11px; color:var(--muted); padding:10px 12px; line-height:1.5;}
  .sidebar .slogan b{color:var(--green-ink); display:block; font-family:'Barlow Condensed'; font-size:13px; letter-spacing:.04em;}

  main{flex:1; overflow-y:auto; padding:20px; min-width:0;}
  .page{display:none; max-width:1180px; margin:0 auto;}
  .page.active{display:block;}
  .page-head{display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-bottom:16px; flex-wrap:wrap;}
  .page-head h2{font-size:26px; font-weight:800;}
  .page-head p{margin:2px 0 0; color:var(--muted); font-size:13px;}

  .card{background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:16px;}
  .card-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:12px;}
  .card-head h3{font-size:15px; font-weight:800;}
  .card-head .more{font-size:12px; color:var(--orange-ink); font-weight:700; cursor:pointer; background:none; border:none;}

  .grid{display:grid; gap:16px;}
  .dash-grid{grid-template-columns: 1.15fr 1fr .85fr;}
  @media (max-width:980px){ .dash-grid{grid-template-columns:1fr;} }
  .col{display:flex; flex-direction:column; gap:16px; min-width:0;}

  .stat-row{display:flex; align-items:center; gap:12px; margin-bottom:12px;}
  .stat-row:last-child{margin-bottom:0;}
  .stat-row .lbl{width:112px; flex:none; font-size:12.5px; font-weight:700; color:var(--muted);}
  .stat-row .bar{flex:1; height:8px; background:var(--paper); border-radius:6px; overflow:hidden;}
  .stat-row .bar i{display:block; height:100%; border-radius:6px;}
  .stat-row .val{width:32px; text-align:right; font-weight:800; font-size:13px;}

  .table-wrap{overflow-x:auto;}
  table{width:100%; border-collapse:collapse; font-size:12.8px; min-width:420px;}
  th{text-align:left; color:var(--muted); font-weight:700; padding:7px 8px; border-bottom:1px solid var(--line); font-size:11.5px; text-transform:uppercase; letter-spacing:.03em;}
  td{padding:8px 8px; border-bottom:1px solid var(--line);}
  tr.me td{background:rgba(24,154,86,.08); font-weight:700;}
  tr:last-child td{border-bottom:none;}
  .pos-num{width:20px; display:inline-block; color:var(--muted);}
  td.club{display:flex; align-items:center; gap:8px; font-weight:700;}
  .dot-club{width:8px;height:8px;border-radius:50%;flex:none;}

  .player-cards{display:grid; grid-template-columns:repeat(4,1fr); gap:12px;}
  @media (max-width:900px){.player-cards{grid-template-columns:repeat(2,1fr);}}
  @media (max-width:520px){.player-cards{grid-template-columns:1fr;}}
  .pcard{border:1px solid var(--line); border-radius:12px; padding:12px; text-align:center; cursor:pointer; transition:transform .12s, box-shadow .12s;}
  .pcard:hover{box-shadow:var(--shadow); transform:translateY(-2px);}
  .pjersey{
    width:64px; height:64px; border-radius:50%; margin:0 auto 8px; display:flex; align-items:center; justify-content:center;
    color:#fff; font-family:'Barlow Condensed'; font-weight:800; font-size:22px; position:relative;
  }
  .pjersey .flag{position:absolute; bottom:-2px; right:-2px; width:18px; height:13px; border-radius:2px; overflow:hidden; box-shadow:0 0 0 2px var(--surface);}
  .pcard .pname{font-size:13.5px; font-weight:800; margin-top:2px;}
  .pcard .ppos{font-size:11px; color:var(--muted); margin-bottom:8px;}
  .pcard .pstats{display:flex; justify-content:center; gap:14px; font-size:11.5px;}
  .pcard .pstats b{display:block; font-size:14px;}
  .pcard .pstats span{color:var(--muted);}

  .featured{display:flex; flex-direction:column; align-items:center; text-align:center; gap:6px; padding:6px;}
  .featured .pjersey{width:88px; height:88px; font-size:30px;}
  .featured .fname{font-size:19px; font-weight:800;}
  .featured .frole{font-size:12px; color:var(--muted); margin-bottom:8px;}
  .featured .fstats{display:flex; gap:18px; margin:6px 0 10px;}
  .featured .fstats div{text-align:center;}
  .featured .fstats b{display:block; font-size:18px;}
  .featured .fstats span{font-size:11px; color:var(--muted);}
  .featured .fquote{font-size:12.5px; color:var(--muted); font-style:italic; border-top:1px dashed var(--line); padding-top:10px; margin-top:4px;}

  .fixture{display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--line); font-size:12.5px;}
  .fixture:last-child{border-bottom:none;}
  .fixture .team{flex:1; display:flex; align-items:center; gap:6px; font-weight:700; min-width:0;}
  .fixture .team.right{justify-content:flex-end; text-align:right;}
  .fixture .fdot{width:7px;height:7px;border-radius:50%; flex:none;}
  .fixture .score{font-family:'Barlow Condensed'; font-weight:800; font-size:15px; background:var(--paper); border-radius:8px; padding:3px 9px; min-width:52px; text-align:center;}
  .fixture .meta{width:100%; text-align:center; color:var(--muted); font-size:11px; margin-top:2px;}

  .news-item{padding:9px 0; border-bottom:1px solid var(--line);}
  .news-item:last-child{border-bottom:none;}
  .news-item .tag{font-size:10px; font-weight:800; color:var(--orange-ink); text-transform:uppercase; letter-spacing:.05em;}
  .news-item h4{font-size:13px; font-weight:700; margin:3px 0;}
  .news-item p{font-size:12px; color:var(--muted); margin:0;}
  .news-item .time{font-size:10.5px; color:var(--muted);}

  /* players page */
  .filter-row{display:flex; gap:8px; margin-bottom:14px; flex-wrap:wrap;}
  .chip{border:1.5px solid var(--line); background:var(--surface); color:var(--muted); font-size:12.5px; font-weight:700; padding:6px 13px; border-radius:20px; cursor:pointer;}
  .chip.active{background:var(--ink); color:#fff; border-color:var(--ink);}

  /* modal */
  .modal-bg{position:fixed; inset:0; background:rgba(11,22,32,.55); display:none; align-items:center; justify-content:center; z-index:100; padding:16px;}
  .modal-bg.open{display:flex;}
  .modal{background:var(--surface); border-radius:16px; max-width:460px; width:100%; max-height:85vh; overflow-y:auto; box-shadow:var(--shadow); border:1px solid var(--line);}
  .modal-top{background:linear-gradient(135deg,var(--ink),var(--ink-2)); padding:22px; color:#fff; text-align:center; border-radius:16px 16px 0 0; position:relative;}
  .modal-close{position:absolute; top:12px; right:12px; background:rgba(255,255,255,.15); border:none; color:#fff; width:28px; height:28px; border-radius:50%; cursor:pointer;}
  .modal-top .pjersey{margin:0 auto 10px; box-shadow:0 0 0 4px rgba(255,255,255,.15);}
  .modal-top h3{font-size:22px; font-weight:800;}
  .modal-top .sub{font-size:12.5px; opacity:.85; margin-top:2px;}
  .modal-body{padding:18px 22px 22px;}
  .mstat-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:16px;}
  .mstat{background:var(--paper); border-radius:10px; padding:9px 4px; text-align:center;}
  .mstat b{display:block; font-size:17px; font-family:'Barlow Condensed';}
  .mstat span{font-size:10px; color:var(--muted); text-transform:uppercase;}
  .mrow{display:flex; justify-content:space-between; font-size:13px; padding:8px 0; border-bottom:1px solid var(--line);}
  .mrow span:first-child{color:var(--muted);}
  .mrow:last-child{border-bottom:none;}
  .mbio{font-size:12.5px; color:var(--muted); line-height:1.6; margin-top:12px;}

  /* messages */
  .msg-shell{display:flex; height:calc(100vh - 170px); min-height:420px; border:1px solid var(--line); border-radius:14px; overflow:hidden; background:var(--surface);}
  .conv-list{width:270px; flex:none; border-right:1px solid var(--line); display:flex; flex-direction:column; overflow-y:auto;}
  @media (max-width:760px){.conv-list{width:210px;}}
  .conv-section-title{font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); font-weight:800; padding:12px 12px 4px;}
  .conv-empty{padding:14px 12px; font-size:12px; color:var(--muted); line-height:1.5;}
  .conv{display:flex; gap:10px; padding:11px 12px; cursor:pointer; border-bottom:1px solid var(--line); align-items:flex-start;}
  .conv:hover{background:var(--paper);}
  .conv.active{background:rgba(239,138,23,.09);}
  .conv .cname{font-size:13px; font-weight:700; display:flex; justify-content:space-between; gap:6px;}
  .conv .cname .time{font-size:10.5px; color:var(--muted); font-weight:500;}
  .conv .clast{font-size:11.5px; color:var(--muted); margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
  .conv .cunread{background:var(--orange); color:#fff; font-size:10px; font-weight:800; border-radius:20px; padding:1px 6px; flex:none;}
  .chat{flex:1; display:flex; flex-direction:column; min-width:0;}
  .chat-head{display:flex; align-items:center; gap:10px; padding:12px 16px; border-bottom:1px solid var(--line);}
  .chat-head .cname2{font-size:14px; font-weight:800;}
  .chat-head .cstatus{font-size:11px; color:var(--green-ink); font-weight:700;}
  .chat-body{flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:10px;}
  .bubble{max-width:72%; padding:9px 13px; border-radius:14px; font-size:13px; line-height:1.4;}
  .bubble.them{background:var(--paper); align-self:flex-start; border-bottom-left-radius:4px;}
  .bubble.me{background:var(--orange); color:#fff; align-self:flex-end; border-bottom-right-radius:4px;}
  .bubble .btime{font-size:10px; opacity:.65; margin-top:4px; display:block;}
  .chat-input{display:flex; gap:8px; padding:12px; border-top:1px solid var(--line);}
  .chat-input input{flex:1; border:1.5px solid var(--line); border-radius:20px; padding:9px 15px; font-size:13px; background:var(--paper); color:var(--text);}
  .chat-input input:focus{border-color:var(--orange); background:var(--surface);}
  .chat-input button{background:var(--orange); border:none; color:#fff; width:38px; height:38px; border-radius:50%; cursor:pointer; flex:none; display:flex; align-items:center; justify-content:center;}

  /* calendar */
  .cal-filter{display:flex; gap:8px; margin-bottom:14px;}
  .month-group{margin-bottom:18px;}
  .month-group h4{font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin-bottom:8px; font-family:'Manrope'; font-weight:800;}
  .cal-row{display:flex; align-items:center; gap:14px; background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:12px 14px; margin-bottom:8px; flex-wrap:wrap;}
  .cal-date{width:52px; flex:none; text-align:center;}
  .cal-date .d{font-family:'Barlow Condensed'; font-weight:800; font-size:21px; line-height:1;}
  .cal-date .m{font-size:10px; text-transform:uppercase; color:var(--muted);}
  .cal-mid{flex:1; display:flex; align-items:center; gap:10px; min-width:220px;}
  .cal-mid .team{font-weight:700; font-size:13.5px;}
  .cal-mid .vs{color:var(--muted); font-size:11px;}
  .cal-score{font-family:'Barlow Condensed'; font-weight:800; font-size:16px; background:var(--paper); border-radius:8px; padding:4px 10px;}
  .cal-venue{font-size:11.5px; color:var(--muted); width:100%;}
  .status-pill{font-size:10.5px; font-weight:800; padding:3px 9px; border-radius:20px; flex:none;}
  .status-pill.done{background:rgba(24,154,86,.14); color:var(--green-ink);}
  .status-pill.next{background:rgba(239,138,23,.14); color:var(--orange-ink);}

  /* bottom nav (mobile) */
  .bottom-nav{display:none; position:fixed; left:0; right:0; bottom:0; background:var(--surface); border-top:1px solid var(--line); padding-bottom:env(safe-area-inset-bottom,0px); z-index:50;}
  .bottom-nav .row{display:flex; justify-content:space-around;}
  .bottom-nav button{background:none; border:none; display:flex; flex-direction:column; align-items:center; gap:2px; padding:9px 0; color:var(--muted); font-size:10px; font-weight:700; flex:1;}
  .bottom-nav button svg{width:18px;height:18px;}
  .bottom-nav button.active{color:var(--orange-ink);}

  @media (max-width:760px){
    .sidebar{display:none;}
    .bottom-nav{display:block;}
    main{padding-bottom:76px;}
    .searchbox{max-width:none;}
    .topbar .club{display:none;}
  }
  @media (max-width:520px){
    .topbar{gap:8px; padding:8px 10px;}
    .topbar .brand h1{font-size:17px;}
    .profile-btn .name{display:none;}
    main{padding:14px;}
  }
