:root {
  --matos-green: #1c7c3c;
  --matos-green-dark: #145a2b;
  --matos-lime: #6cbb3c;
  --matos-charcoal: #33383b;
  --matos-bg: #f4f7f3;
  --matos-border: #e1e8df;
  --matos-muted: #6f7b74;
  --matos-radius: 14px;
  --matos-shadow: 0 8px 24px rgba(20, 60, 35, .07);
}

html, body { min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--matos-bg);
  color: #26302b;
}
.has-text-muted { color: var(--matos-muted) !important; }
.has-text-brand { color: var(--matos-green) !important; }
a { color: var(--matos-green-dark); }
a:hover { color: var(--matos-green); }
.button.is-primary, .button.is-link { background-color: var(--matos-green); border-color: var(--matos-green); }
.button.is-primary:not(.is-light), .button.is-link:not(.is-light) { color: #fff; }
.button.is-primary:hover, .button.is-link:hover { background-color: var(--matos-green-dark); border-color: var(--matos-green-dark); }
.button.is-primary:not(.is-light):hover, .button.is-link:not(.is-light):hover { color: #fff; }
.button.is-primary.is-light { background: #eaf5e7; color: var(--matos-green-dark); border-color: #cfe8c9; }
.tag.is-brand { background: #eaf5e7; color: var(--matos-green-dark); }
.title, .subtitle { color: #1f2a24; }

/* --------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; height: 64px; padding: 0 1.25rem;
  background: #fff; border-bottom: 1px solid var(--matos-border);
}
.topbar .brand { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.topbar .brand img { height: 38px; width: auto; }
.topbar .brand-name { font-weight: 800; letter-spacing: .08em; color: var(--matos-charcoal); font-size: 1.05rem; }
.topbar .brand-sub { color: var(--matos-muted); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar .user-chip {
  display: flex; align-items: center; gap: .55rem; padding: .35rem .6rem;
  border: 1px solid var(--matos-border); border-radius: 999px; background: #fff; cursor: pointer;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--matos-green);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}
.dropdown-menu { min-width: 230px; }
.dropdown-item { display: block; padding: .55rem .9rem; }
.dropdown-item:hover { background: var(--matos-bg); }
.burger-btn { display: none; background: none; border: 0; font-size: 1.35rem; color: var(--matos-charcoal); padding: .25rem .4rem; }

/* --------------------------------------------------------------- layout */
.app-shell { display: flex; min-height: calc(100vh - 64px); }
.sidebar {
  width: 236px; flex: 0 0 236px; background: #fff;
  border-right: 1px solid var(--matos-border); padding: 1rem .75rem;
  position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto;
}
.sidebar .menu-label { color: #9aa59e; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; margin: 1rem .65rem .35rem; }
.sidebar a.nav-item {
  display: flex; align-items: center; gap: .6rem; padding: .58rem .7rem;
  border-radius: 9px; color: #3e4a43; font-weight: 500; font-size: .92rem; margin-bottom: 2px;
}
.sidebar a.nav-item svg { width: 18px; height: 18px; opacity: .75; flex: 0 0 18px; }
.sidebar a.nav-item:hover { background: #f2f7f0; color: var(--matos-green-dark); }
.sidebar a.nav-item.is-active { background: #e8f4e4; color: var(--matos-green-dark); font-weight: 700; }
.sidebar a.nav-item.is-active svg { opacity: 1; }
.sidebar .nav-sep { border-top: 1px solid var(--matos-border); margin: .75rem .4rem; }
.main { flex: 1 1 auto; min-width: 0; padding: 1.35rem 1.6rem 3rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.55rem; font-weight: 750; margin: 0; }
.page-head .subtitle { margin: .15rem 0 0; font-size: .92rem; color: var(--matos-muted); }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --------------------------------------------------------------- cards */
.box, .card { border-radius: var(--matos-radius); box-shadow: var(--matos-shadow); border: 1px solid var(--matos-border); }
.box { padding: 1.15rem 1.25rem; }
.card-header { box-shadow: none; border-bottom: 1px solid var(--matos-border); }
.card-content { padding: 1.1rem 1.25rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; }
.stat {
  background: #fff; border: 1px solid var(--matos-border); border-radius: var(--matos-radius);
  padding: 1rem 1.1rem; box-shadow: var(--matos-shadow);
}
.stat .label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--matos-muted); margin-bottom: .3rem; }
.stat .value { font-size: 1.8rem; font-weight: 800; line-height: 1.1; color: #22302a; }
.stat .hint { font-size: .78rem; color: var(--matos-muted); margin-top: .25rem; }
.stat.is-danger .value { color: #b42318; }
.stat.is-warning .value { color: #9a6700; }
.stat.is-success .value { color: var(--matos-green); }

.table { background: #fff; border-radius: var(--matos-radius); }
.table thead th { background: #f7faf6; color: #4f5b54; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--matos-border); }
.table td, .table th { vertical-align: middle; }
.table.is-hoverable tbody tr:hover { background: #f8fbf7; }
.table-wrap { overflow-x: auto; border-radius: var(--matos-radius); border: 1px solid var(--matos-border); }
.table-wrap .table { border-radius: 0; margin: 0; }

.machine-card {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  background: #fff; border: 1px solid var(--matos-border); border-radius: 12px;
  padding: .85rem 1rem; margin-bottom: .55rem; box-shadow: 0 2px 8px rgba(20,60,35,.04);
  transition: border-color .15s, transform .15s;
}
.machine-card:hover { border-color: #b9d9b1; transform: translateY(-1px); }
.machine-card .machine-name { font-weight: 700; font-size: 1.02rem; }
.machine-card .machine-meta { color: var(--matos-muted); font-size: .8rem; }

.usage-hero {
  background: linear-gradient(135deg, var(--matos-green-dark), var(--matos-green) 65%, #2c9a4b);
  color: #fff; border-radius: 18px; padding: 1.5rem 1.6rem; box-shadow: 0 14px 30px rgba(20,90,43,.22);
}
.usage-hero h1, .usage-hero .title { color: #fff; }
.usage-hero .button.is-white { font-weight: 700; }

.meter-box {
  background: #f3f9f0; border: 1px dashed #b9d9b1; border-radius: 12px; padding: 1rem;
}
.meter-box .meter-value { font-size: 2rem; font-weight: 800; color: var(--matos-green-dark); line-height: 1; }
.meter-box .meter-unit { font-size: .9rem; color: var(--matos-muted); margin-left: .25rem; }

.tabs.is-boxed li.is-active a { background: var(--matos-green); border-color: var(--matos-green); color: #fff; }
.tabs a { border-bottom-color: var(--matos-border); color: #55625a; }

.notification { border-radius: 12px; }
.flash-stack { margin-bottom: 1rem; }
.field-label { font-weight: 600; color: #3c4a41; }
.help.is-danger, .error-text { color: #b42318; font-size: .8rem; }
.required::after { content: " *"; color: #b42318; }
.hero-operator { background: linear-gradient(160deg, #f2f9ef, #e6f3e1); border-radius: 18px; padding: 1.5rem; }

.timeline { position: relative; margin-left: .5rem; padding-left: 1.2rem; border-left: 2px solid #dfe9db; }
.timeline-item { position: relative; margin-bottom: 1rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -1.58rem; top: .3rem; width: 10px; height: 10px;
  border-radius: 50%; background: var(--matos-lime); border: 2px solid #fff; box-shadow: 0 0 0 2px #cfe7c7;
}
.timeline-item .time { font-size: .75rem; color: var(--matos-muted); }

.tab-panel { padding-top: 1.1rem; }
.hidden { display: none !important; }
.is-nowrap { white-space: nowrap; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.doc-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px dashed var(--matos-border); }
.doc-row:last-child { border-bottom: 0; }
.photo-frame { border-radius: 14px; overflow: hidden; border: 1px solid var(--matos-border); background: #fff; }
.photo-frame img { display: block; width: 100%; height: auto; }
.inline-form { display: inline; }
details.help-panel summary { cursor: pointer; color: var(--matos-green-dark); font-weight: 600; }

/* --------------------------------------------------------------- login */
.login-page {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: #fff;
}
.login-visual {
  background: radial-gradient(circle at 20% 20%, #2c9a4b 0, var(--matos-green) 42%, var(--matos-green-dark) 100%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.login-visual img { height: 70px; width: auto; background: #fff; padding: .5rem .8rem; border-radius: 12px; }
.login-visual h2 { color: #fff; font-size: 2rem; line-height: 1.2; max-width: 26rem; margin-top: 3rem; }
.login-visual p { color: #dff0d8; max-width: 26rem; }
.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-form { width: 100%; max-width: 380px; }
.login-form .logo-mobile { display: none; }

/* --------------------------------------------------------------- mobile */
@media (max-width: 900px) {
  .topbar { padding: 0 .8rem; }
  .burger-btn { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 64px; bottom: 0; z-index: 35;
    transform: translateX(-100%); transition: transform .18s ease; height: auto;
    box-shadow: 12px 0 30px rgba(0,0,0,.12); width: 270px; flex-basis: 270px;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after { content: ""; position: fixed; inset: 64px 0 0 0; background: rgba(20,40,28,.35); z-index: 34; }
  .main { padding: 1rem .9rem 4rem; }
  .page-head h1 { font-size: 1.28rem; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-form .logo-mobile { display: block; margin: 0 auto 1.4rem; height: 60px; }
  .topbar .brand-sub { display: none; }
  .table td, .table th { font-size: .84rem; }
  .field.is-grouped { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .topbar .brand img { height: 32px; }
  .topbar .brand-name { display: none; }
  .stat .value { font-size: 1.5rem; }
}
@media print {
  .topbar, .sidebar, .page-actions, .no-print { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .box, .card { box-shadow: none; border: 1px solid #ccc; }
}
