
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&display=swap');
:root{--green:#176b55;--deep:#123d32;--mint:#eaf5ef;--ink:#182b25;--muted:#718078;--line:#e4ece7;--bg:#f5f8f6;--white:#fff;--red:#b93838;--amber:#a66b13}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:14px 'Be Vietnam Pro',system-ui,sans-serif}button,input,select{font:inherit}button{cursor:pointer}.boot{padding:40px;text-align:center;color:var(--green)}
.login-wrap{min-height:100vh;display:grid;place-items:center;padding:22px;background:linear-gradient(140deg,#eaf5ef,#f7faf8 55%,#e6f1eb)}
.login{width:min(100%,420px);background:white;border:1px solid var(--line);border-radius:22px;padding:30px;box-shadow:0 20px 60px #123d3212}.brand{display:flex;align-items:center;gap:12px;font-weight:800;font-size:20px;color:var(--deep)}.logo{width:42px;height:42px;border-radius:13px;background:var(--green);color:white;display:grid;place-items:center;font-size:24px;font-weight:800}.muted{color:var(--muted)}.login h1{font-size:25px;margin:28px 0 5px}.field{display:grid;gap:7px;margin:15px 0}.field label{font-weight:600;font-size:12px;color:#4d6057}.field input,.field select{width:100%;padding:12px 13px;border:1px solid var(--line);border-radius:11px;background:white;outline:none}.field input:focus,.field select:focus{border-color:var(--green);box-shadow:0 0 0 3px #176b5517}
.btn{border:0;border-radius:10px;padding:11px 15px;background:var(--green);color:white;font-weight:700}.btn:hover{filter:brightness(.96)}.btn.secondary{background:white;color:var(--deep);border:1px solid var(--line)}.btn.ghost{background:var(--mint);color:var(--green)}.btn.danger{background:#fff0f0;color:var(--red)}.btn.full{width:100%;padding:13px}.error{background:#fff0f0;color:var(--red);padding:10px;border-radius:9px;margin:10px 0}.app{min-height:100vh}.top{height:66px;background:white;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 25px;position:sticky;top:0;z-index:5}.top .brand{font-size:17px}.top-right{display:flex;align-items:center;gap:12px}.shell{display:grid;grid-template-columns:245px 1fr;min-height:calc(100vh - 66px)}.side{background:white;border-right:1px solid var(--line);padding:20px 13px}.nav-label{font-size:10px;font-weight:800;color:#91a098;letter-spacing:1px;padding:15px 12px 7px}.nav{display:flex;align-items:center;gap:11px;padding:11px 12px;border-radius:10px;color:#52645b;cursor:pointer;margin:3px 0;font-weight:600}.nav:hover,.nav.active{background:var(--mint);color:var(--green)}.nav .ico{width:20px;text-align:center}.main{padding:27px;max-width:1500px;width:100%;margin:auto}.page-head{display:flex;justify-content:space-between;align-items:center;gap:15px;margin-bottom:22px}.page-head h1{font-size:24px;margin:0 0 4px}.page-head p{margin:0;color:var(--muted)}.grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.metric,.panel{background:white;border:1px solid var(--line);border-radius:15px;padding:18px}.metric .k{font-size:12px;color:var(--muted)}.metric .v{font-size:27px;font-weight:800;margin:8px 0 2px;color:var(--deep)}.metric .hint{font-size:11px;color:var(--muted)}.panel{margin-top:16px}.panel h3{margin:0 0 14px;font-size:15px}.two{display:grid;grid-template-columns:1.2fr .8fr;gap:15px}.toolbar{display:flex;gap:9px;flex-wrap:wrap;margin-bottom:14px}.toolbar input{flex:1;min-width:180px}.toolbar input,.toolbar select{padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:white}.table-wrap{overflow:auto}table{border-collapse:collapse;width:100%;min-width:540px}th,td{text-align:left;padding:12px 10px;border-bottom:1px solid #edf1ee;font-size:12px}th{color:#7c8b83;font-weight:700;background:#fbfcfb}td{color:#35483e}.pill{display:inline-flex;padding:4px 8px;border-radius:30px;background:var(--mint);color:var(--green);font-size:10px;font-weight:700}.pill.gray{background:#f0f2f1;color:#68766e}.empty{padding:28px;text-align:center;color:var(--muted)}.form-row{display:grid;grid-template-columns:1fr 1fr;gap:12px}.notice{padding:13px;border-radius:11px;background:#f3f7f4;color:#506258;font-size:12px;line-height:1.6}.modal-bg{position:fixed;inset:0;background:#10251dcc;display:grid;place-items:center;padding:18px;z-index:20}.modal{background:white;border-radius:17px;padding:22px;width:min(100%,480px);max-height:90vh;overflow:auto}.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px}.modal-head h3{margin:0}.modal-actions{display:flex;justify-content:flex-end;gap:9px;margin-top:18px}.toast{position:fixed;right:18px;bottom:18px;background:#153e32;color:white;padding:12px 16px;border-radius:11px;z-index:30;box-shadow:0 8px 30px #0002}.mobile-menu{display:none}.user-chip{font-size:12px;color:#56675e}.loading{padding:30px;text-align:center;color:var(--muted)}.subgrid{display:grid;grid-template-columns:repeat(3,1fr);gap:13px}.plan{border:1px solid var(--line);border-radius:14px;padding:17px}.plan strong{font-size:17px}.plan p{color:var(--muted);font-size:12px;line-height:1.6}
@media(max-width:900px){.shell{grid-template-columns:1fr}.side{display:flex;overflow:auto;gap:5px;padding:8px;border-right:0;border-bottom:1px solid var(--line)}.nav-label{display:none}.nav{white-space:nowrap;margin:0;padding:9px}.main{padding:18px}.grid{grid-template-columns:repeat(2,minmax(0,1fr))}.two{grid-template-columns:1fr}.top{padding:0 14px}.user-chip{display:none}}
@media(max-width:520px){.page-head{align-items:flex-start;flex-direction:column}.grid{gap:9px}.metric{padding:13px}.metric .v{font-size:23px}.main{padding:13px}.top .brand{font-size:14px}.form-row,.subgrid{grid-template-columns:1fr}.side{position:sticky;top:66px;z-index:4;background:#fff}}

/* ==================================================
   FARMNEX CLOUD R3 - DARK SMART FARM + RESPONSIVE
   CSS OVERRIDE - PRESERVE R2 FUNCTIONALITY
================================================== */

:root{
  --green:#18a995;
  --deep:#071725;
  --mint:#123447;
  --ink:#e7f1f5;
  --muted:#a2b6c2;
  --line:#294758;
  --bg:#071725;
  --white:#10283a;
  --red:#ff7474;
  --amber:#f4ca70;
}

html{
  width:100%;
  overflow-x:hidden;
}

body{
  width:100%;
  max-width:100%;
  overflow-x:hidden;
  background:
    radial-gradient(ellipse at 15% 0%,#124b58 0,transparent 38%),
    radial-gradient(ellipse at 90% 45%,#123b4c 0,transparent 35%),
    linear-gradient(145deg,#061522,#0b1e2d 55%,#071725);
  color:var(--ink);
}

.app{
  min-height:100vh;
  background:
    radial-gradient(ellipse at 80% 10%,#0e455033,transparent 40%);
}

.top{
  background:#091c2bee;
  border-bottom:1px solid #315064;
  backdrop-filter:blur(16px);
  color:#eaf7f8;
}

.top .brand{
  color:#eaf7f8;
}

.logo{
  background:linear-gradient(145deg,#1bc5ad,#087e78);
  box-shadow:0 5px 20px #12b9a633;
}

.shell{
  min-width:0;
}

.side{
  background:#0a2030;
  border-color:#294758;
}

.nav{
  color:#afc2cc;
  transition:background .2s,color .2s;
}

.nav:hover,
.nav.active{
  background:linear-gradient(110deg,#0c716d66,#16455a88);
  color:#60e0cf;
}

.main{
  min-width:0;
  background:
    radial-gradient(ellipse at 50% 0%,#16445622,transparent 55%);
}

.page-head h1{
  color:#e9f5f7;
}

.page-head p,
.muted{
  color:#a2b6c2;
}

.metric,
.panel,
.plan{
  min-width:0;
  background:linear-gradient(145deg,#142e40,#102638);
  border:1px solid #2a4a5d;
  color:#e7f1f5;
  box-shadow:0 8px 28px #00000020;
}

.metric .v{
  color:#57dfcf;
}

.metric .k,
.metric .hint{
  color:#a2b6c2;
}

.panel h3,
.plan strong{
  color:#e7f1f5;
}

.btn{
  background:linear-gradient(135deg,#159d8d,#08766e);
  color:#fff;
  box-shadow:0 4px 14px #087e7830;
}

.btn.secondary{
  background:#17374a;
  border:1px solid #36596b;
  color:#dcebf0;
}

.btn.ghost{
  background:#174c50;
  color:#65e0d0;
}

.field label{
  color:#b6cbd4;
}

.field input,
.field select,
.toolbar input,
.toolbar select{
  background:#0a2030;
  border:1px solid #365568;
  color:#edf7f8;
}

.field input::placeholder,
.toolbar input::placeholder{
  color:#829ba9;
}

.field input:focus,
.field select:focus{
  border-color:#39cbb8;
  box-shadow:0 0 0 3px #39cbb822;
}

.notice{
  background:#123b43;
  color:#c4e5df;
  border:1px solid #28635f;
}

.table-wrap{
  width:100%;
  max-width:100%;
  overflow-x:auto;
  overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;
  border-radius:10px;
}

table{
  color:#e7f1f5;
}

th{
  background:#18384b;
  color:#a9c2cd;
}

td{
  color:#dce9ee;
  border-color:#294758;
}

.pill{
  background:#164e4b;
  color:#69e0d0;
}

.pill.gray{
  background:#263c4b;
  color:#b5c6ce;
}

.empty{
  color:#9eb3bf;
}

.modal-bg{
  background:#020b12dd;
  backdrop-filter:blur(8px);
}

.modal{
  background:#10283a;
  border:1px solid #365568;
  color:#e7f1f5;
  box-shadow:0 20px 70px #0008;
}

.modal-head h3{
  color:#e7f1f5;
}

.toast{
  background:#087e78;
  color:#fff;
  border:1px solid #36c7b5;
}

/* RESPONSIVE TABLET */
@media(max-width:900px){
  .shell{
    display:block;
    min-width:0;
  }

  .side{
    display:flex;
    width:100%;
    max-width:100%;
    overflow-x:auto;
    overflow-y:hidden;
    white-space:nowrap;
    gap:5px;
    scrollbar-width:thin;
    scrollbar-color:#347b7a transparent;
    position:sticky;
    top:66px;
    z-index:4;
    padding:9px;
  }

  .nav{
    flex:0 0 auto;
    white-space:nowrap;
    padding:11px 13px;
  }

  .main{
    width:100%;
    min-width:0;
    padding:18px;
  }

  .grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .two{
    grid-template-columns:1fr;
  }
}

/* RESPONSIVE PHONE */
@media(max-width:520px){
  body{
    font-size:14px;
  }

  .top{
    height:60px;
    padding:0 12px;
  }

  .top .brand{
    font-size:14px;
    gap:8px;
  }

  .top .logo{
    width:36px;
    height:36px;
  }

  .top-right{
    gap:6px;
  }

  .main{
    padding:13px;
  }

  .page-head{
    align-items:flex-start;
    flex-direction:column;
    gap:10px;
    margin-bottom:15px;
  }

  .page-head h1{
    font-size:21px;
  }

  .grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:9px;
  }

  .metric{
    padding:12px;
    overflow-wrap:anywhere;
  }

  .metric .v{
    font-size:22px;
  }

  .panel{
    padding:14px;
    overflow:hidden;
  }

  .side{
    top:60px;
    padding:7px;
  }

  .nav{
    padding:10px 12px;
    font-size:12px;
  }

  .form-row,
  .subgrid{
    grid-template-columns:1fr;
  }

  .table-wrap{
    margin:0;
  }

  table{
    min-width:540px;
  }

  .modal-bg{
    padding:12px;
  }

  .modal{
    width:100%;
    max-height:88vh;
    padding:17px;
  }

  .modal-actions{
    position:sticky;
    bottom:0;
    background:#10283a;
    padding-top:12px;
  }

  .toast{
    left:12px;
    right:12px;
    bottom:16px;
    text-align:center;
  }

  .user-chip{
    display:none;
  }
}

/* SMALL PHONE */
@media(max-width:360px){
  .main{
    padding:10px;
  }

  .grid{
    gap:7px;
  }

  .metric{
    padding:10px;
  }

  .metric .v{
    font-size:19px;
  }

  .nav{
    padding:9px 10px;
    font-size:11px;
  }
}


/* FARMNEX R4 - Mobile device cards */
.device-cards{display:none}
.device-card{
  border:1px solid var(--line);
  border-radius:13px;
  padding:14px;
  margin-top:12px;
  background:rgba(255,255,255,.035);
  min-width:0
}
.device-card-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px
}
.device-card-name{font-weight:800;font-size:14px;overflow-wrap:anywhere}
.device-card-id{font-size:11px;color:var(--muted);margin-top:5px;overflow-wrap:anywhere}
.device-card-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:14px
}
.device-card-grid>div,.device-card-place{
  padding:10px;
  border-radius:9px;
  background:rgba(128,160,180,.08);
  min-width:0
}
.device-card-grid span,.device-card-place span{
  display:block;
  font-size:10px;
  color:var(--muted);
  margin-bottom:5px
}
.device-card-grid b,.device-card-place b{
  font-size:14px;
  overflow-wrap:anywhere
}
.device-card-action{
  display:flex;
  justify-content:flex-end;
  margin-top:12px
}
@media(max-width:900px){
  .device-table-wrap{display:none !important}
  .device-cards{display:block !important}
  .device-card .btn{white-space:normal}
}

/* FARMNEX R4.1 - Explicit device layout */
.device-table-wrap{
  display:none !important;
}
.device-cards{
  display:block !important;
}
@media(min-width:901px){
  .device-table-wrap{
    display:block !important;
  }
  .device-cards{
    display:none !important;
  }
}
