/* DigiSilta AI Intra — local styles on top of colors_and_type.css */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--ds-paper);
  color: var(--ds-fg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* =====================================================
   App shell
   ===================================================== */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.header {
  background: #fff;
  border-bottom: 1px solid var(--ds-border);
  padding: 0.875rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem;
}
.brand {
  display: flex; align-items: center; gap: 0.625rem;
  font-weight: 600; font-size: 15px;
  color: var(--ds-fg);
  cursor: pointer;
}
.brand img { height: 22px; width: auto; display: block; }
.brand-pill {
  background: var(--ds-pink);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 1rem; font-size: 13px; }
.userchip {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--ds-border);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.userchip:hover { background: var(--ds-paper); }
.userchip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ds-pink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.userchip .label { color: var(--ds-fg); font-weight: 500; }
.userchip .caret { color: var(--ds-fg-muted); font-size: 10px; margin-left: 2px; }

.subnav {
  background: #fff;
  border-bottom: 1px solid var(--ds-border);
  padding: 0 1.5rem;
  display: flex; gap: 0.25rem; align-items: center;
  position: sticky; top: 0; z-index: 10;
}
.subnav a {
  font-size: 13px; font-weight: 500;
  color: var(--ds-fg-muted);
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.subnav a:hover { color: var(--ds-fg); }
.subnav a.active { color: var(--ds-pink); border-bottom-color: var(--ds-pink); }
.subnav .spacer { flex: 1; }
.subnav .ping {
  font-size: 12px; color: var(--ds-fg-muted);
  display: inline-flex; align-items: center; gap: 6px;
  padding-right: 4px;
}
.subnav .ping .dot { width: 7px; height: 7px; border-radius: 50%; background: #00d1b2; box-shadow: 0 0 0 3px rgba(0,209,178,.15); }

.main { flex: 1; padding: 1.5rem; max-width: 1440px; margin: 0 auto; width: 100%; }
.main.with-aside {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
}
@media (max-width: 1080px) {
  .main.with-aside { grid-template-columns: 1fr; }
}

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 {
  font-size: 1.5rem; font-weight: 600; line-height: 1.2;
  margin: 0;
  letter-spacing: -.005em;
}
.page-head .lead { margin: 4px 0 0; color: var(--ds-fg-muted); font-size: 13px; }
.page-head .actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* =====================================================
   Buttons
   ===================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.5rem 0.875rem;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, opacity .15s, box-shadow .15s;
  white-space: nowrap;
  line-height: 1;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(250,33,118,.25); }
.btn-primary { background: var(--ds-pink); color: #fff; }
.btn-primary:hover { background: var(--ds-pink-hover); }
.btn-ghost { background: #fff; color: var(--ds-fg); border-color: var(--ds-border); }
.btn-ghost:hover { background: var(--ds-paper); }
.btn-quiet { background: transparent; color: var(--ds-fg-muted); }
.btn-quiet:hover { background: var(--ds-paper); color: var(--ds-fg); }
.btn-danger-quiet { background: transparent; color: var(--ds-fg-muted); }
.btn-danger-quiet:hover { background: rgba(250,33,118,.08); color: var(--ds-pink); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 12px; }
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  justify-content: center;
}

/* =====================================================
   Inputs
   ===================================================== */
.input, .select, .textarea {
  height: 38px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--ds-border);
  background: #fff;
  padding: 0 0.75rem;
  font-size: 13px;
  color: var(--ds-fg);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 0.6rem 0.75rem; min-height: 80px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ds-pink);
  box-shadow: 0 0 0 3px rgba(250,33,118,.18);
}
.input::placeholder { color: var(--ds-fg-muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--ds-fg-muted); font-weight: 500; }
.field .hint { font-size: 11px; color: var(--ds-fg-muted); margin-top: -2px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.875rem; }

.search {
  position: relative;
  width: 280px;
}
.search input {
  padding-left: 34px;
}
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ds-fg-muted); width: 14px; height: 14px;
  pointer-events: none;
}
.search .clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--ds-fg-muted);
  width: 24px; height: 24px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.search .clear:hover { background: var(--ds-paper); color: var(--ds-fg); }

/* =====================================================
   Cards
   ===================================================== */
.card {
  background: #fff;
  border: 1px solid var(--ds-border);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 1.25rem 1.25rem; }
.card-pad-lg { padding: 1.5rem; }
.card-h {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ds-border);
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem;
}
.card-h h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-h .meta { font-size: 12px; color: var(--ds-fg-muted); }

/* =====================================================
   KPI strip
   ===================================================== */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 760px) { .kpi-strip { grid-template-columns: 1fr 1fr; } }
.kpi {
  background: #fff;
  border: 1px solid var(--ds-border);
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  display: flex; flex-direction: column; gap: 4px;
  position: relative;
  overflow: hidden;
}
.kpi .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ds-fg-muted); font-weight: 600;
}
.kpi .value {
  font-size: 26px; font-weight: 700; line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--ds-fg);
}
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--ds-fg-muted); margin-left: 3px; }
.kpi .delta { font-size: 12px; color: var(--ds-fg-muted); display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: #00876f; }
.kpi .delta.down { color: var(--ds-pink); }
.kpi.featured { background: var(--ds-fg); color: var(--ds-fg-on-dark); border-color: var(--ds-fg); }
.kpi.featured .label { color: var(--ds-fg-on-dark-muted); }
.kpi.featured .value { color: #fff; }
.kpi.featured .delta { color: rgba(255,255,255,.7); }
.kpi.featured::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--ds-pink); opacity: .18; filter: blur(6px);
}

/* =====================================================
   Tables
   ===================================================== */
.t-card { overflow: hidden; }
.t {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.t thead th {
  text-align: left;
  font-weight: 500;
  padding: 0.65rem 0.875rem;
  border-bottom: 1px solid var(--ds-border);
  color: var(--ds-fg-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  background: #fcfbfd;
}
.t tbody td { padding: 0.875rem; border-bottom: 1px solid var(--ds-border); vertical-align: middle; }
.t tbody tr:last-child td { border-bottom: none; }
.t tbody tr { transition: background .12s; }
.t tbody tr:hover { background: var(--ds-paper); }
.t .col-actions { width: 1%; white-space: nowrap; }
.t .col-actions .row-actions {
  display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s;
}
.t tbody tr:hover .row-actions { opacity: 1; }
.t .row-clickable { cursor: pointer; }
.t .company {
  display: flex; flex-direction: column; gap: 2px;
}
.t .company .name { font-weight: 600; font-size: 13px; color: var(--ds-fg); }
.t .company .domain { font-size: 11.5px; color: var(--ds-fg-muted); display: flex; align-items: center; gap: 5px; }
.t .company .domain svg { width: 11px; height: 11px; }

/* =====================================================
   Pills / badges
   ===================================================== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill-active { background: rgba(0,209,178,.14); color: #00876f; border: none; cursor: pointer; }
.pill-active .dot { background: #00d1b2; }
.pill-active:hover { background: rgba(0,209,178,.22); }
.pill-inactive { background: var(--ds-border); color: var(--ds-fg-muted); border: none; cursor: pointer; }
.pill-inactive .dot { background: var(--ds-fg-muted); }
.pill-inactive:hover { background: #d5d8dc; }

.pkg {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  letter-spacing: .01em;
}
.pkg-mestari   { background: #efeaf6; color: #4d3768; }
.pkg-paalliko  { background: #fff0e6; color: #8a4a17; }
.pkg-johtaja   { background: rgba(250,33,118,.12); color: #b81857; }

/* =====================================================
   Usage bar
   ===================================================== */
.usage {
  display: flex; flex-direction: column; gap: 5px;
  min-width: 130px;
}
.usage-bar {
  height: 6px; width: 100%;
  background: var(--ds-border);
  border-radius: 999px;
  overflow: hidden;
}
.usage-bar .fill {
  height: 100%;
  background: var(--ds-fg);
  border-radius: 999px;
  transition: width .3s var(--ease);
}
.usage-bar .fill.warn { background: #dba617; }
.usage-bar .fill.over { background: var(--ds-pink); }
.usage-num { font-size: 12px; color: var(--ds-fg-muted); display: flex; gap: 4px; }
.usage-num strong { color: var(--ds-fg); font-weight: 600; }

/* =====================================================
   Activity sidebar
   ===================================================== */
.aside {
  display: flex; flex-direction: column; gap: 1rem;
}
.activity-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.activity-item {
  display: flex; gap: 0.625rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--ds-border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-item .ico {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 8px;
  background: var(--ds-paper);
  color: var(--ds-fg);
  display: inline-flex; align-items: center; justify-content: center;
}
.activity-item .ico svg { width: 14px; height: 14px; }
.activity-item .ico.pink { background: rgba(250,33,118,.1); color: var(--ds-pink); }
.activity-item .ico.green { background: rgba(0,209,178,.15); color: #00876f; }
.activity-item .ico.warn { background: rgba(255,221,87,.25); color: #8a6a00; }
.activity-item .body { flex: 1; min-width: 0; }
.activity-item .ttl { font-weight: 500; color: var(--ds-fg); line-height: 1.35; }
.activity-item .sub { font-size: 12px; color: var(--ds-fg-muted); margin-top: 1px; }

.activity-empty {
  text-align: center; padding: 1rem 0;
  font-size: 13px; color: var(--ds-fg-muted);
}

/* =====================================================
   Drawer
   ===================================================== */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(29, 19, 38, 0.32);
  backdrop-filter: blur(1px);
  animation: fade .15s ease;
}
.drawer {
  position: fixed; right: 0; top: 0; height: 100%; width: min(560px, 92vw);
  background: #fff;
  border-left: 1px solid var(--ds-border);
  box-shadow: var(--shadow-medium);
  z-index: 50;
  display: flex; flex-direction: column;
  animation: slideIn .2s var(--ease);
}
.drawer-h {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--ds-border);
  gap: 1rem;
}
.drawer-h h2 { margin: 0; font-size: 18px; font-weight: 600; }
.drawer-h .sub { margin: 4px 0 0; color: var(--ds-fg-muted); font-size: 13px; }
.drawer-body { flex: 1; padding: 1.25rem 1.5rem; overflow: auto; }
.drawer-foot {
  padding: 0.875rem 1.5rem;
  border-top: 1px solid var(--ds-border);
  display: flex; justify-content: space-between; align-items: center;
  background: #fcfbfd;
}
.icon-btn {
  background: none; border: none;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--ds-fg-muted);
}
.icon-btn:hover { background: var(--ds-paper); color: var(--ds-fg); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Drawer content */
.section-h {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ds-fg-muted);
  font-weight: 600;
  margin: 0 0 0.75rem;
}
.section + .section { margin-top: 1.5rem; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--ds-border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .label-text { font-size: 13px; }
.toggle-row .label-text .desc { font-size: 11.5px; color: var(--ds-fg-muted); margin-top: 2px; }

.toggle {
  width: 36px; height: 20px; border-radius: 999px;
  background: var(--ds-border);
  position: relative; flex-shrink: 0;
  border: none; cursor: pointer;
  transition: background .15s;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: transform .15s var(--ease);
}
.toggle.on { background: var(--ds-pink); }
.toggle.on::after { transform: translateX(16px); }

.usage-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
  margin-bottom: 1rem;
}
.usage-summary .cell {
  background: var(--ds-paper);
  border-radius: 12px;
  padding: 0.75rem 0.875rem;
}
.usage-summary .cell .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ds-fg-muted); font-weight: 600; }
.usage-summary .cell .val { font-size: 18px; font-weight: 700; margin-top: 2px; }
.usage-summary .cell .sub { font-size: 11px; color: var(--ds-fg-muted); margin-top: 2px; }

/* =====================================================
   Login
   ===================================================== */
.login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 80% 10%, rgba(250,33,118,.08), transparent 50%),
    radial-gradient(circle at 10% 90%, rgba(250,33,118,.05), transparent 50%),
    var(--ds-paper);
  padding: 1rem;
}
.login-card {
  background: #fff;
  border: 1px solid var(--ds-border);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
  padding: 2.5rem 2.25rem;
  width: 420px;
  max-width: 100%;
}
.login-card .brand { justify-content: flex-start; font-size: 16px; margin-bottom: 1.75rem; }
.login-card h1 {
  margin: 0 0 0.375rem;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.login-card .lead { margin: 0 0 1.5rem; color: var(--ds-fg-muted); font-size: 13.5px; line-height: 1.55; }
.code-inputs { display: flex; gap: 8px; margin: 4px 0 18px; }
.code-inputs input {
  width: 100%; flex: 1; height: 56px;
  text-align: center;
  font-size: 22px; font-weight: 600;
  font-family: var(--font-mono);
  border: 1px solid var(--ds-border);
  border-radius: 12px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.code-inputs input:focus {
  outline: none;
  border-color: var(--ds-pink);
  box-shadow: 0 0 0 3px rgba(250,33,118,.2);
}
.code-info {
  display: flex; align-items: center; gap: 6px;
  background: var(--ds-paper);
  border-radius: 10px;
  padding: 0.625rem 0.75rem;
  font-size: 12.5px;
  color: var(--ds-fg-muted);
  margin-bottom: 1rem;
}
.code-info strong { color: var(--ds-fg); font-weight: 600; }
.login-foot { font-size: 12px; color: var(--ds-fg-muted); text-align: center; margin-top: 1.5rem; }
.login-foot a { color: var(--ds-pink); cursor: pointer; }
.login-foot a:hover { text-decoration: underline; }

/* =====================================================
   Sales / Myynti
   ===================================================== */
.pkg-card {
  background: #fff;
  border: 1px solid var(--ds-border);
  border-radius: 18px;
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: 0.625rem;
}
.pkg-card .pkg-name {
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
}
.pkg-card .price { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.pkg-card .price small { font-size: 13px; font-weight: 500; color: var(--ds-fg-muted); }
.pkg-card .bar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--ds-border);
}
.pkg-card .bar .cell .l { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ds-fg-muted); font-weight: 600; }
.pkg-card .bar .cell .v { font-size: 15px; font-weight: 600; margin-top: 2px; }

.pkg-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 820px) { .pkg-grid { grid-template-columns: 1fr; } }

/* simple bar chart */
.bars {
  display: flex; align-items: flex-end; gap: 6px;
  height: 120px;
  padding: 0 4px;
}
.bars .bar-col {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ds-fg-muted);
}
.bars .bar-col .b {
  width: 100%; max-width: 28px;
  background: var(--ds-fg);
  border-radius: 6px 6px 0 0;
  transition: height .3s var(--ease);
}
.bars .bar-col .b.current { background: var(--ds-pink); }

/* =====================================================
   Settings
   ===================================================== */
.settings-grid {
  display: grid; grid-template-columns: 1fr; gap: 1rem;
  max-width: 760px;
}
.setting-card {
  background: #fff;
  border: 1px solid var(--ds-border);
  border-radius: 18px;
  padding: 1.25rem 1.5rem;
}
.setting-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.setting-card .desc { margin: 0 0 1rem; font-size: 13px; color: var(--ds-fg-muted); line-height: 1.5; }

.status-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--ds-border);
}
.status-row:last-child { border-bottom: none; }
.status-row .info { display: flex; align-items: center; gap: 0.75rem; }
.status-row .info .name { font-size: 13px; font-weight: 500; }
.status-row .info .when { font-size: 11.5px; color: var(--ds-fg-muted); margin-top: 1px; }

/* =====================================================
   Toast
   ===================================================== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ds-fg);
  color: #fff;
  padding: 0.625rem 1rem;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-soft);
  z-index: 100;
  animation: toastIn .2s var(--ease);
  display: inline-flex; align-items: center; gap: 8px;
}
.toast svg { color: #00d1b2; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* =====================================================
   Utility
   ===================================================== */
.muted { color: var(--ds-fg-muted); }
.fg { color: var(--ds-fg); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.between { justify-content: space-between; }
.center { align-items: center; }
.col { flex-direction: column; }
.tnum { font-variant-numeric: tabular-nums; }
